Add version files and new GIF images for UI components

This commit is contained in:
2025-04-03 06:26:44 +07:00
commit 663c28a2ea
5219 changed files with 772528 additions and 0 deletions

View File

@ -0,0 +1,30 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.saveBackup = function() {
if (!this._backup) {
this._backup = {};
this._backupId = new Date().getTime();
}
this._backup[++this._backupId] = this.getFormData();
return this._backupId;
};
dhtmlXForm.prototype.restoreBackup = function(id) {
if (this._backup != null && this._backup[id] != null) {
this.setFormData(this._backup[id]);
}
};
dhtmlXForm.prototype.clearBackup = function(id) {
if (this._backup != null && this._backup[id] != null) {
this._backup[id] = null;
delete this._backup[id];
}
};

View File

@ -0,0 +1,391 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
/* add item */
dhtmlXForm.prototype.addItem = function(pId, itemData, pos, insertAfter) {
// insertAfter
// if any columns used - item will inserted into colunm where item[pos] positioned, before it
// insertAfter specifies that new item will inserted after item[pos], to add possibility to make new item last in column
// this param ignored when inserting newcolumn
// pId = [id,value] for radiobutton
var pValue = null;
if (pId instanceof Array) {pValue = pId[1];pId = pId[0];}
var f = null;
if (pId != null) {
var f = this._getParentForm(pId, pValue);
// check if item in "f" have nested form
if (f != null) {
if (f.item._list == null) {
// create list
if (!itemData.listParent) itemData.listParent = f.item._idd;
f.form._addItem("list", f.item._idd, [itemData], null, f.item._idd, pos, insertAfter);
} else {
f.item._list[0].addItem(null, itemData, pos, insertAfter);
}
f.form = f.item = null;
f = null;
this._autoCheck();
return;
}
}
this._prepareItem(itemData, pos, insertAfter);
this._autoCheck();
};
/* remove item */
dhtmlXForm.prototype.removeItem = function(id, value) {
this._removeItem(id, value);
};
/* remove newcolumn */
dhtmlXForm.prototype.removeColumn = function(pId, index, removeItems, moveAfter) {
// index of column
// if single column - only items can be deleted if removeItems==true
// if more than one column and removeItems==false, move items to leftmost column (if not exists - to right) and vise versa if moveAfter=true
// pId = [id,value] for radiobutton
var pValue = null;
if (pId instanceof Array) {pValue = pId[1];pId = pId[0];}
if (pId != null) {
var f = this._getParentForm(pId, pValue);
if (f != null) {
if (f.item._list != null && f.item._list[0] != null) {
f.item._list[0].removeColumn(null, index, removeItems, moveAfter);
}
f.form = f.item = null;
f = null;
}
return;
}
// find base
index = Math.min(Math.max(index,0), this.cont.childNodes.length-1); // index [0..length-1)
if (this.cont.childNodes.length == 1) {
// one column
if (removeItems == true) {
// remove items
this._removeItemsInColumn(this.cont.childNodes[index]);
}
} else {
// more than one
if (removeItems == true) {
// remove items
this._removeItemsInColumn(this.cont.childNodes[index]);
} else {
// move items to next column
if (!moveAfter) {
var moveToBase = index-1;
if (moveToBase < 0) moveToBase = index+1;
} else {
var moveToBase = index+1;
if (moveToBase > this.cont.childNodes.length-1) moveToBase = index-1;
}
// console.log("index ",index,"moveToBase",moveToBase)
while (this.cont.childNodes[index].childNodes.length > 0) {
this.cont.childNodes[moveToBase].appendChild(this.cont.childNodes[index].childNodes[0]);
}
}
var t = [];
for (var q=0; q<this.base.length; q++) {
if (this.cont.childNodes[index] != this.base[q]) t.push(this.base[q]);
}
this.base = t;
this.cont.removeChild(this.cont.childNodes[index]);
this.b_index--;
t = null;
}
};
dhtmlXForm.prototype.getColumnNode = function(pId, index) {
var node = null;
var pValue = null;
if (pId instanceof Array) {pValue = pId[1];pId = pId[0];}
if (pId != null) {
var f = this._getParentForm(pId, pValue);
if (f != null) {
if (f.item._list != null && f.item._list[0] != null && node == null) {
node = f.item._list[0].getColumnNode(null, index);
}
f.form = f.item = null;
f = null;
}
return node;
}
if (index < 0 || index > this.cont.childNodes.length-1) return null;
return this.cont.childNodes[index];
};
dhtmlXForm.prototype._removeItemsInColumn = function(base) {
var items = [];
for (var q=0; q<base.childNodes.length; q++) {
var i = base.childNodes[q];
if (i._idd != null && i._type != null) items.push([i._idd, (i._type=="ra"?i._value:null)]);
i = null;
}
for (var q=0; q<items.length; q++) {
this.removeItem(items[q][0],items[q][1]);
}
};
dhtmlXForm.prototype._getParentForm = function(id, value) {
// check if simple item
if (this.itemPull[this.idPrefix+id] != null) {
return {form: this, item: this.itemPull[this.idPrefix+id]};
}
// check if radio
for (var a in this.itemPull) {
if (this.itemPull[a]._type == "ra" && this.itemPull[a]._group == id && this.itemPull[a]._value == value) {
return {form: this, item: this.itemPull[a]};
}
}
var f = null;
for (var a in this.itemPull) {
if (!f && this.itemPull[a]._list != null) {
for (var q=0; q<this.itemPull[a]._list.length; q++) {
if (!f) f = this.itemPull[a]._list[q]._getParentForm(id, value);
}
}
}
return f;
};
(function(){
for (var a in dhtmlXForm.prototype.items) {
if (!dhtmlXForm.prototype.items[a]._getItemNode) dhtmlXForm.prototype.items[a]._getItemNode = function(item){return item;}
}
})();
dhtmlXForm.prototype._getItemNode = function(id, value) {
if (value != null) id = [id, value];
return this.doWithItem(id, "_getItemNode");
};
/* set/clear required flag */
dhtmlXForm.prototype.setRequired = function(id, value, state) {
if (typeof(state) == "undefined") state = value; else id = [id,value];
var item = this._getItemNode(id);
if (!item) return;
state = window.dhx4.s2b(state);
item._required = (state==true);
// validation
if (item._required) {
if (!item._validate) item._validate = [];
var t = false;
for (var q=0; q<item._validate.length; q++) t = (item._validate[q]=="NotEmpty"||t);
if (!t) item._validate.push("NotEmpty");
var p = item.childNodes[item._ll?0:1].childNodes[0];
if (!(p.lastChild && p.lastChild.className && p.lastChild.className.search(/required/) >= 0)) {
var k = document.createElement("SPAN");
k.className = "dhxform_item_required";
k.innerHTML = "*";
p.appendChild(k);
k = p = null;
}
} else {
if (item._validate != null) {
var t = item._validate;
item._validate = [];
for (var q=0; q<t.length; q++) { if (t[q] != "NotEmpty") item._validate.push(t[q]); }
if (item._validate.length == 0) item._validate = null;
}
var p = item.childNodes[item._ll?0:1].childNodes[0];
if (p.lastChild && p.lastChild.className && p.lastChild.className.search(/required/) >= 0) {
p.removeChild(p.lastChild);
p = null;
}
}
this._resetValidateCss(item);
item = null;
};
/* set/clear note */
dhtmlXForm.prototype.setNote = function(id, value, note) {
if (typeof(note) == "undefined") note = value; else id = [id,value];
var item = this._getItemNode(id);
if (!item) return;
var p = this._getNoteNode(item);
if (!p) {
if (!note.width) note.width = item.childNodes[item._ll?1:0].childNodes[0].offsetWidth;
p = document.createElement("DIV");
p.className = "dhxform_note";
if ({"ch":1,"ra":1}[item._type]) {
item.childNodes[item._ll?1:0].insertBefore(p, item.childNodes[item._ll?1:0].lastChild);
} else {
item.childNodes[item._ll?1:0].appendChild(p);
}
}
p.innerHTML = note.text;
if (note.width != null) {
p.style.width = note.width+"px";
p._w = note.width;
}
p = null;
};
dhtmlXForm.prototype.clearNote = function(id, value) {
if (typeof(value) != "undefined") id = [id,value];
var item = this._getItemNode(id);
if (!item) return;
var p = this._getNoteNode(item);
if (p != null) {
p.parentNode.removeChild(p);
p = null;
}
};
dhtmlXForm.prototype._getNoteNode = function(item) {
var p = null;
for (var q=0; q<item.childNodes[item._ll?1:0].childNodes.length; q++) {
if (String(item.childNodes[item._ll?1:0].childNodes[q].className).search(/dhxform_note/) >= 0) {
p = item.childNodes[item._ll?1:0].childNodes[q];
}
}
item = null;
return p;
};
/* set/clear validation */
dhtmlXForm.prototype.setValidation = function(id, value, rule) {
if (typeof(note) == "undefined") rule = value; else id = [id,value];
var item = this._getItemNode(id);
if (!item) return;
// init state, clear prev
if (item._validate != null) for (var q=0; q<item._validate.length; q++) item._validate[q] = null;
item._validate = [];
// apply new rules
if (typeof(rule) == "function" || typeof(window[rule]) == "function") {
item._validate = [rule];
} else {
item._validate = String(rule).split(this.separator);
}
// check required state
if (item._required) {
var r = false;
for (var q=0; q<item._validate.length; q++) r = (item._validate[q]=="NotEmpty"||r);
if (!r) item._validate.push("NotEmpty");
}
item = null;
};
dhtmlXForm.prototype.clearValidation = function(id, value) {
if (typeof(value) != "undefined") id = [id,value];
var item = this._getItemNode(id);
if (!item) return;
// clear
if (item._validate != null) for (var q=0; q<item._validate.length; q++) item._validate[q] = null;
// check required
item._validate = item._required?["NotEmpty"]:null;
item = null;
};
/* reload options */
dhtmlXForm.prototype.reloadOptions = function(name, data) {
var t = this.getItemType(name);
if (!{select:1,multiselect:1,combo:1}[t]) return;
if (t == "select" || t == "multiselect") {
var opts = this.getOptions(name);
while (opts.length > 0) opts.remove(0);
opts.length = 0;
opts = null;
if (typeof(data) == "string") {
this.doWithItem(name, "doLoadOptsConnector", data);
} else if (data instanceof Array) {
this.doWithItem(name, "doLoadOpts", {options:data});
}
}
if (t == "combo") {
var combo = this.getCombo(name);
combo.clearAll();
combo.setComboValue("");
if (typeof(data) == "string") {
this.doWithItem(name, "doLoadOptsConnector", data);
} else if (data instanceof Array) {
var toSelect = null;
for (var q=0; q<data.length; q++) if (window.dhx4.s2b(data[q].selected)) toSelect = data[q].value;
combo.addOption(data);
if (toSelect != null) this.setItemValue(name, toSelect);
combo = null;
}
}
};
/* tooltips */
dhtmlXForm.prototype.setTooltip = function(id, value, tooltip) {
if (typeof(tooltip) == "undefined") tooltip = value; else id = [id,value];
var item = this._getItemNode(id);
if (!item) return;
var node = null;
if (item.childNodes.length == 1) {
node = item.childNodes[0];
} else {
for (var q=0; q<item.childNodes.length; q++) {
if (item.childNodes[q].className != null && item.childNodes[q].className.search("dhxform_label") >= 0) {
node = item.childNodes[q];
}
}
}
if (node != null) {
if (tooltip == null || tooltip.length == 0) {
node.removeAttribute("title");
} else {
node.title = tooltip;
}
}
node = null;
};

View File

@ -0,0 +1,50 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.items.btn2state = {
setChecked: function(item, state) {
item._checked = (state===true?true:false);
item.childNodes[item._ll?1:0].lastChild.className = "dhxform_img "+item._cssName+"_"+(item._checked?"1":"0");
this.doCheckValue(item);
}
};
(function() {
for (var a in dhtmlXForm.prototype.items.checkbox) {
if (!dhtmlXForm.prototype.items.btn2state[a]) dhtmlXForm.prototype.items.btn2state[a] = dhtmlXForm.prototype.items.checkbox[a];
}
})();
dhtmlXForm.prototype.items.btn2state.render2 = dhtmlXForm.prototype.items.btn2state.render;
dhtmlXForm.prototype.items.btn2state.render = function(item, data) {
data._autoInputWidth = false;
this.render2(item, data);
item._type = "btn2state";
item._cssName = (typeof(data.cssName)=="undefined"?"btn2state":data.cssName);
item._updateImgNode = function(){};
item._doOnFocus = function() {
item.getForm().callEvent("onFocus",[item._idd]);
}
item._doOnBlur = function() {
item.getForm().callEvent("onBlur",[item._idd]);
}
item._doOnKeyUpDown = function(evName, evObj, inp) {
this.callEvent(evName, [this.childNodes[this._ll?0:1].childNodes[0], evObj, this._idd]);
}
this.setChecked(item, item._checked);
return this;
};
dhtmlXForm.prototype.setFormData_btn2state = function(name, value) {
this[value==true||parseInt(value)==1||value=="true"||value==this.getItemValue(name)?"checkItem":"uncheckItem"](name);
};
dhtmlXForm.prototype.getFormData_btn2state = function(name) {
return (this.isItemChecked(name)?this.getItemValue(name):0);
};

View File

@ -0,0 +1,189 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.items.calendar = {
render: function(item, data) {
var t = this;
item._type = "calendar";
item._enabled = true;
// dbl-click fix for IE6-8 (i.e. to select date user needs to click twice)
var n = navigator.userAgent;
var dblclickFix = (n.indexOf("MSIE 6.0") >= 0 || n.indexOf("MSIE 7.0") >= 0 || n.indexOf("MSIE 8.0") >= 0);
this.doAddLabel(item, data);
this.doAddInput(item, data, "INPUT", "TEXT", true, true, "dhxform_textarea calendar");
this.doAttachChangeLS(item);
if (dblclickFix) {
item.childNodes[item._ll?1:0].childNodes[0].onfocus2 = item.childNodes[item._ll?1:0].childNodes[0].onfocus;
item.childNodes[item._ll?1:0].childNodes[0].onfocus = function() {
if (this._skipOnFocus == true) {
this._skipOnFocus = false;
return;
}
this.onfocus2.apply(this,arguments);
}
}
item.childNodes[item._ll?1:0].childNodes[0]._idd = item._idd;
item.childNodes[item._ll?1:0].childNodes[0].onblur = function() {
var i = this.parentNode.parentNode;
if (i._c.base._formMouseDown) { // dblclickFix
i._c.base._formMouseDown = false;
this._skipOnFocus = true;
this.focus();
this.value = this.value;
i = null;
return true;
}
var f = i.getForm();
f._ccDeactivate(i._idd);
t.checkEnteredValue(this.parentNode.parentNode);
if (f.live_validate) t._validate(i);
f.callEvent("onBlur",[i._idd]);
if (!i._c.isVisible()) i._tempValue = null;
f = i = null;
}
item._f = (data.dateFormat||null); // formats
item._f0 = (data.serverDateFormat||item._f); // formats for save-load, if set - use them for saving and loading only
var f = item.getForm();
item._c = new dhtmlXCalendarObject(item.childNodes[item._ll?1:0].childNodes[0], data.skin||f.skin||"dhx_skyblue");
item._c._nullInInput = true; // allow null value from input
item._c.enableListener(item.childNodes[item._ll?1:0].childNodes[0]);
if (item._f != null) item._c.setDateFormat(item._f);
if (!window.dhx4.s2b(data.enableTime)) item._c.hideTime();
if (window.dhx4.s2b(data.enableTodayButton)) item._c.showToday();
if (window.dhx4.s2b(data.showWeekNumbers)) item._c.showWeekNumbers();
if (!isNaN(data.weekStart)) item._c.setWeekStartDay(data.weekStart);
if (typeof(data.calendarPosition) != "undefined") item._c.setPosition(data.calendarPosition);
if (data.minutesInterval != null) item._c.setMinutesInterval(data.minutesInterval);
item._c._itemIdd = item._idd;
item._c.attachEvent("onBeforeChange", function(d) {
if (item._value != d) {
// call some events
if (item.checkEvent("onBeforeChange")) {
if (item.callEvent("onBeforeChange",[item._idd, item._value, d]) !== true) {
return false;
}
}
// accepted
item._tempValue = item._value = d;
t.setValue(item, d, false);
item.callEvent("onChange", [this._itemIdd, item._value]);
}
return true;
});
item._c.attachEvent("onClick", function(){
item._tempValue = null;
});
item._c.attachEvent("onHide", function(){
item._tempValue = null;
});
if (dblclickFix) {
item._c.base.onmousedown = function() {
this._formMouseDown = true;
return false;
}
}
this.setValue(item, data.value);
f = null;
return this;
},
getCalendar: function(item) {
return item._c;
},
setSkin: function(item, skin) {
item._c.setSkin(skin);
},
setValue: function(item, value, cUpd) {
if (!value || value == null || typeof(value) == "undefined" || value == "") {
item._value = null;
item.childNodes[item._ll?1:0].childNodes[0].value = "";
} else {
item._value = (value instanceof Date ? value : item._c._strToDate(value, item._f0||item._c._dateFormat));
item.childNodes[item._ll?1:0].childNodes[0].value = item._c._dateToStr(item._value, item._f||item._c._dateFormat);
}
if (cUpd !== false) item._c.setDate(item._value);
},
getValue: function(item, asString) {
var d = item._tempValue||item._c.getDate();
if (asString===true && d == null) return "";
return (asString===true?item._c._dateToStr(d,item._f0||item._c._dateFormat):d);
},
setDateFormat: function(item, dateFormat, serverDateFormat) {
item._f = dateFormat;
item._f0 = (serverDateFormat||item._f);
item._c.setDateFormat(item._f);
this.setValue(item, this.getValue(item));
},
destruct: function(item) {
// unload calendar instance
item._c.disableListener(item.childNodes[item._ll?1:0].childNodes[0]);
item._c.unload();
item._c = null;
try {delete item._c;} catch(e){}
item._f = null;
try {delete item._f;} catch(e){}
item._f0 = null;
try {delete item._f0;} catch(e){}
// remove custom events/objects
item.childNodes[item._ll?1:0].childNodes[0]._idd = null;
item.childNodes[item._ll?1:0].childNodes[0].onblur = null;
// unload item
this.d2(item);
item = null;
},
checkEnteredValue: function(item) {
this.setValue(item, item._c.getDate());
}
};
(function(){
for (var a in {doAddLabel:1,doAddInput:1,doUnloadNestedLists:1,setText:1,getText:1,enable:1,disable:1,isEnabled:1,setWidth:1,setReadonly:1,isReadonly:1,setFocus:1,getInput:1})
dhtmlXForm.prototype.items.calendar[a] = dhtmlXForm.prototype.items.input[a];
})();
dhtmlXForm.prototype.items.calendar.doAttachChangeLS = dhtmlXForm.prototype.items.select.doAttachChangeLS;
dhtmlXForm.prototype.items.calendar.d2 = dhtmlXForm.prototype.items.input.destruct;
dhtmlXForm.prototype.getCalendar = function(name) {
return this.doWithItem(name, "getCalendar");
};
dhtmlXForm.prototype.setCalendarDateFormat = function(name, dateFormat, serverDateFormat) {
this.doWithItem(name, "setDateFormat", dateFormat, serverDateFormat);
};

View File

@ -0,0 +1,112 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.items.colorpicker = {
colorpicker: {}, // colorpicker instances
render: function(item, data) {
var t = this;
item._type = "colorpicker";
item._enabled = true;
this.doAddLabel(item, data);
this.doAddInput(item, data, "INPUT", "TEXT", true, true, "dhxform_textarea");
item._value = (data.value||"");
item.childNodes[item._ll?1:0].childNodes[0].value = item._value;
var conf = {
input: item.childNodes[item._ll?1:0].childNodes[0],
custom_colors: (window.dhx4.s2b(data.enableCustomColors) == true),
skin: item.getForm().skin
};
this.colorpicker[item._idd] = new dhtmlXColorPicker(conf);
this.colorpicker[item._idd]._nodes[0].valueColor = null; // disable input's bg change
this.colorpicker[item._idd].base.className += " dhtmlxcp_in_form";
if (typeof(data.customColors) != "undefined") {
this.colorpicker[item._idd].setCustomColors(data.customColors);
}
if (typeof(data.cpPosition) == "string") {
this.colorpicker[item._idd].setPosition(data.cpPosition);
}
// select handler
this.colorpicker[item._idd].attachEvent("onSelect", function(color){
if (item._value != color) {
// call some events
if (item.checkEvent("onBeforeChange")) {
if (item.callEvent("onBeforeChange",[item._idd, item._value, color]) !== true) {
// do not allow set new value
item.childNodes[item._ll?1:0].childNodes[0].value = item._value;
return;
}
}
// accepted
item._value = color;
t.setValue(item, color);
item.callEvent("onChange", [item._idd, item._value]);
}
});
this.colorpicker[item._idd].attachEvent("onHide", function(color){
var i = item.childNodes[item._ll?1:0].childNodes[0];
if (i.value != item._value) i.value = item._value;
i = null;
});
item.childNodes[item._ll?1:0].childNodes[0]._idd = item._idd;
return this;
},
getColorPicker: function(item) {
return this.colorpicker[item._idd];
},
destruct: function(item) {
// unload color picker instance
if (this.colorpicker[item._idd].unload) this.colorpicker[item._idd].unload();
this.colorpicker[item._idd] = null;
try {delete this.colorpicker[item._idd];} catch(e){}
// remove custom events/objects
item.childNodes[item._ll?1:0].childNodes[0]._idd = null;
// unload item
this.d2(item);
item = null;
},
setSkin: function(item, skin) {
this.colorpicker[item._idd].setSkin(skin);
}
};
(function(){
for (var a in {doAddLabel:1,doAddInput:1,doUnloadNestedLists:1,setText:1,getText:1,enable:1,disable:1,isEnabled:1,setWidth:1,setReadonly:1,isReadonly:1,setValue:1,getValue:1,updateValue:1,setFocus:1,getInput:1})
dhtmlXForm.prototype.items.colorpicker[a] = dhtmlXForm.prototype.items.input[a];
})();
dhtmlXForm.prototype.items.colorpicker.d2 = dhtmlXForm.prototype.items.input.destruct;
dhtmlXForm.prototype.getColorPicker = function(name) {
return this.doWithItem(name, "getColorPicker");
};

View File

@ -0,0 +1,215 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.items.combo = {
render: function(item, data) {
item._type = "combo";
item._enabled = true;
item._value = null;
item._newValue = null;
var skin = item.getForm().skin;
if (typeof(data.inputWidth) != "undefined" && skin == "material" && String(data.inputWidth).match(/^\d*$/) != null) {
data.inputWidth = parseInt(data.inputWidth)+2;
}
this.doAddLabel(item, data);
this.doAddInput(item, data, "SELECT", null, true, true, "dhxform_select");
this.doAttachEvents(item);
this.doLoadOpts(item, data);
// allow selection to prevent broking combo logic
item.onselectstart = function(e){return true;}
// item.childNodes[1].childNodes[0].opt_type = data.comboType||"";
item.childNodes[item._ll?1:0].childNodes[0].setAttribute("mode", data.comboType||"");
if (data.comboImagePath) item.childNodes[item._ll?1:0].childNodes[0].setAttribute("imagePath", data.comboImagePath);
if (data.comboDefaultImage) item.childNodes[item._ll?1:0].childNodes[0].setAttribute("defaultImage", data.comboDefaultImage);
if (data.comboDefaultImageDis) item.childNodes[item._ll?1:0].childNodes[0].setAttribute("defaultImageDis", data.comboDefaultImageDis);
item._combo = new dhtmlXComboFromSelect(item.childNodes[item._ll?1:0].childNodes[0], data.inputWidth);
item._combo.setSkin(skin);
item._combo._currentComboValue = item._combo.getSelectedValue();
item._combo.getInput().id = data.uid;
if (skin == "material") item._combo.list.className += " dhxform_obj_"+skin;
var k = this;
item._combo.attachEvent("onChange", function(){
k.doOnChange(this);
});
if (data.connector) this.doLoadOptsConnector(item, data.connector);
if (data.filtering) {
item._combo.enableFilteringMode(true);
} else if (data.serverFiltering) {
item._combo.enableFilteringMode(true, data.serverFiltering, data.filterCache, data.filterSubLoad);
}
if (data.readonly == true) this.setReadonly(item, true);
if (data.hidden == true) this.hide(item);
if (data.style) item._combo.DOMelem_input.style.cssText += data.style;
item._combo.attachEvent("onFocus", function(){
var item = this.cont.parentNode.parentNode;
var f = item.getForm();
if ((f.skin == "dhx_terrace" || f.skin == "material") && this.cont.className.search(/combo_in_focus/) < 0) this.cont.className += " combo_in_focus";
f.callEvent("onFocus", [item._idd]);
f = item = null;
});
item._combo.attachEvent("onBlur", function(){
var item = this.cont.parentNode.parentNode;
var f = item.getForm();
if ((f.skin == "dhx_terrace" || f.skin == "material") && this.cont.className.search(/combo_in_focus/) >= 0) this.cont.className = this.cont.className.replace(/\s{0,}combo_in_focus/gi,"");
f.callEvent("onBlur", [item._idd]);
f = item = null;
});
return this;
},
destruct: function(item) {
// unload combo
item.childNodes[item._ll?1:0].childNodes[0].onchange = null;
item._combo._currentComboValue = null;
item._combo.unload();
item._combo = null;
// unload item
item._apiChange = null;
this.d2(item);
item = null;
},
doAttachEvents: function(item) {
var that = this;
item.childNodes[item._ll?1:0].childNodes[0].onchange = function() {
that.doOnChange(this);
that.doValidate(this.DOMParent.parentNode.parentNode);
}
},
doValidate: function(item) {
if (item.getForm().hot_validate) this._validate(item);
},
doOnChange: function(combo) {
var item = combo.base.parentNode.parentNode.parentNode;
if (item._apiChange) return;
combo._newComboValue = combo.getSelectedValue();
if (combo._newComboValue != combo._currentComboValue) {
if (item.checkEvent("onBeforeChange")) {
if (item.callEvent("onBeforeChange", [item._idd, combo._currentComboValue, combo._newComboValue]) !== true) {
// restore last value
// not the best solution, should be improved
window.setTimeout(function(){combo.setComboValue(combo._currentComboValue);},1);
return false;
}
}
combo._currentComboValue = combo._newComboValue;
item.callEvent("onChange", [item._idd, combo._currentComboValue]);
}
item._autoCheck();
},
doLoadOptsConnector: function(item, url) {
var that = this;
var i = item;
item._connector_working = true;
item._apiChange = true;
item._combo.load(url, function(){
// try to set value if it was called while options loading was in progress
i.callEvent("onOptionsLoaded", [i._idd]);
i._connector_working = false;
if (i._connector_value != null) {
that.setValue(i, i._connector_value);
i._connector_value = null;
}
i._apiChange = false;
that = i = null;
});
},
enable: function(item) {
if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,"");
item._enabled = true;
item._combo.enable();
},
disable: function(item) {
if (String(item.className).search("disabled") < 0) item.className += " disabled";
item._enabled = false;
item._combo.disable();
},
getCombo: function(item) {
return item._combo;
},
setValue: function(item, val) {
if (item._connector_working) { // attemp to set value while optins not yet loaded (connector used)
item._connector_value = val;
return;
}
item._apiChange = true;
item._combo.setComboValue(val);
item._combo._currentComboValue = item._combo.getActualValue();
item._apiChange = false;
},
getValue: function(item) {
return item._combo.getActualValue();
},
setWidth: function(item, width) {
item.childNodes[item._ll?1:0].childNodes[0].style.width = width+"px";
},
setReadonly: function(item, state) {
if (!item._combo) return;
item._combo_ro = state;
item._combo.readonly(item._combo_ro);
},
isReadonly: function(item, state) {
return item._combo_ro||false;
},
setFocus: function(item) {
if (item._enabled) item._combo.setFocus();
},
_setCss: function(item, skin, fontSize) {
// update font-size for input and list-options div
item._combo.setFontSize(fontSize, fontSize);
}
};
(function(){
for (var a in {doAddLabel:1,doAddInput:1,doLoadOpts:1,doUnloadNestedLists:1,setText:1,getText:1,isEnabled:1,_checkNoteWidth:1})
dhtmlXForm.prototype.items.combo[a] = dhtmlXForm.prototype.items.select[a];
})();
dhtmlXForm.prototype.items.combo.d2 = dhtmlXForm.prototype.items.select.destruct;
dhtmlXForm.prototype.getCombo = function(name) {
return this.doWithItem(name, "getCombo");
};

View File

@ -0,0 +1,64 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.items.container = {
render: function(item, data) {
item._type = "container";
item._enabled = true;
this.doAddLabel(item, data);
this.doAddInput(item, data, "DIV", null, true, true, "dhxform_container");
return this;
},
getContainer: function(item) {
return item.childNodes[item._ll?1:0].childNodes[0];
},
enable: function(item) {
item._enabled = true;
if (String(item.className).search("disabled") >= 0) item.className = String(item.className).replace(/disabled/gi,"");
//
item.callEvent("onEnable",[item._idd]);
},
disable: function(item) {
item._enabled = false;
if (String(item.className).search("disabled") < 0) item.className += " disabled";
//
item.callEvent("onDisable",[item._idd]);
},
doAttachEvents: function(){
},
setValue: function(){
},
getValue: function(){
return null;
}
};
dhtmlXForm.prototype.getContainer = function(name) {
return this.doWithItem(name, "getContainer");
};
(function(){
for (var a in dhtmlXForm.prototype.items.input) {
if (!dhtmlXForm.prototype.items.container[a]) dhtmlXForm.prototype.items.container[a] = dhtmlXForm.prototype.items.input[a];
}
})();

View File

@ -0,0 +1,157 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.items.editor = {
editor: {},
render: function(item, data) {
var ta = (!isNaN(data.rows));
item._type = "editor";
item._enabled = true;
item._editor_id = item.getForm().idPrefix+item._idd;
this.doAddLabel(item, data);
this.doAddInput(item, data, "DIV", null, true, true, "dhxform_item_template");
item._value = (data.value||"");
var that = this;
this.editor[item._editor_id] = new dhtmlXEditor({
parent: item.childNodes[item._ll?1:0].childNodes[0],
content: item._value,
iconsPath: data.iconsPath, // path for toolbar icons
toolbar: data.toolbar,
skin: item.getForm().skin
});
this.editor[item._editor_id].attachEvent("onAccess",function(t, ev){
// generate body click to hide menu/toolbar/calendar/combo/other stuff if any
item.callEvent("_onBeforeEditorAccess", []); // if editor attached to form in popup - do some tricks
_dhxForm_doClick(document.body, "click");
// continue
if (t == "blur") {
that.doOnBlur(item, this);
item.callEvent("onBlur", [item._idd]);
if ({dhx_terrace:1, material: 1}[item.getForm().skin] == 1) {
var css = item.childNodes[item._ll?1:0].className;
if (css.indexOf("dhxeditor_focus") >= 0) item.childNodes[item._ll?1:0].className = (css).replace(/\s{0,}dhxeditor_focus/gi,"");
}
} else {
item.callEvent("onEditorAccess", [item._idd, t, ev, this, item.getForm()]);
item.callEvent("onFocus", [item._idd]);
if ({dhx_terrace:1, material: 1}[item.getForm().skin] == 1) {
var css = item.childNodes[item._ll?1:0].className;
if (css.indexOf("dhxeditor_focus") == -1) item.childNodes[item._ll?1:0].className += " dhxeditor_focus";
}
}
});
this.editor[item._editor_id].attachEvent("onToolbarClick", function(a){
item.callEvent("onEditorToolbarClick", [item._idd, a, this, item.getForm()]);
});
if (data.readonly) this.setReadonly(item, true);
// emulate label-for
item.childNodes[item._ll?0:1].childNodes[0].removeAttribute("for");
item.childNodes[item._ll?0:1].childNodes[0].onclick = function() {
that.editor[item._editor_id]._focus();
}
return this;
},
// destructor for editor needed
doOnBlur: function(item, editor) {
var t = editor.getContent();
if (item._value != t) {
if (item.checkEvent("onBeforeChange")) {
if (item.callEvent("onBeforeChange",[item._idd, item._value, t]) !== true) {
// restore
editor.setContent(item._value);
return;
}
}
// accepted
item._value = t;
item.callEvent("onChange",[item._idd, t]);
}
},
setValue: function(item, value) {
if (item._value == value) return;
item._value = value;
this.editor[item._editor_id].setContent(item._value);
},
getValue: function(item) {
item._value = this.editor[item._editor_id].getContent();
return item._value;
},
enable: function(item) {
if (this.isEnabled(item) != true) {
this.editor[item._editor_id].setReadonly(false);
this.doEn(item);
}
},
disable: function(item) {
if (this.isEnabled(item) == true) {
this.editor[item._editor_id].setReadonly(true);
this.doDis(item);
}
},
setReadonly: function(item, mode) {
this.editor[item._editor_id].setReadonly(mode);
},
getEditor: function(item) {
return (this.editor[item._editor_id]||null);
},
destruct: function(item) {
// custom editor functionality
item.childNodes[item._ll?0:1].childNodes[0].onclick = null;
// unload editor
this.editor[item._editor_id].unload();
this.editor[item._editor_id] = null;
// unload item
this.d2(item);
item = null;
},
setFocus: function(item) {
this.editor[item._editor_id]._focus();
}
};
(function(){
for (var a in {doAddLabel:1,doAddInput:1,doUnloadNestedLists:1,setText:1,getText:1,setWidth:1,isEnabled:1})
dhtmlXForm.prototype.items.editor[a] = dhtmlXForm.prototype.items.template[a];
})();
dhtmlXForm.prototype.items.editor.d2 = dhtmlXForm.prototype.items.select.destruct;
dhtmlXForm.prototype.items.editor.doEn = dhtmlXForm.prototype.items.select.enable;
dhtmlXForm.prototype.items.editor.doDis = dhtmlXForm.prototype.items.select.disable;
dhtmlXForm.prototype.getEditor = function(name) {
return this.doWithItem(name, "getEditor");
};

View File

@ -0,0 +1,183 @@
/*
Product Name: dhtmlxSuite
Version: 5.2.0
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
*/
dhtmlXForm.prototype.items.image = {
_dimFix: true,
render: function(item, data) {
item._type = "image";
item._enabled = true;
item._fr_name = "dhxform_image_"+window.dhx4.newId();
item._url = (typeof(data.url)=="undefined"||data.url==null?"":data.url);
if (data.inputWidth == "auto") data.inputWidth = 120;
if (data.inputHeight == "auto") data.inputHeight = data.inputWidth;
this.doAddLabel(item, data);
this.doAddInput(item, data, "DIV", null, true, true, "dhxform_image");
var t = item.childNodes[item._ll?1:0].childNodes[0];
t.style.height = parseInt(t.style.height)-dhtmlXForm.prototype.items[this.t]._dim+"px";
var w = (typeof(data.imageWidth)!="undefined"?parseInt(data.imageWidth):data.inputWidth);
var h = (typeof(data.imageHeight)!="undefined"?parseInt(data.imageHeight):data.inputHeight);
if (h == "auto") h = w;
item._dim = {mw: data.inputWidth-this._dim, mh: data.inputHeight-this._dim, w: w, h: h};
t.innerHTML = "<img class='dhxform_image_img' border='0' style='visibility:hidden;'>"+
"<iframe name='"+item._fr_name+"' style='position: absolute; width:0px; height:0px; top:-10px; left:-10px;' frameBorder='0' border='0'></iframe>"+
"<div class='dhxform_image_wrap'>"+
"<form action='"+item._url+"' method='POST' enctype='multipart/form-data' target='"+item._fr_name+"' class='dhxform_image_form'>"+
"<input type='hidden' name='action' value='uploadImage'>"+
"<input type='hidden' name='itemId' value='"+item._idd+"'>"+
"<input type='file' name='file' class='dhxform_image_input'>"+
"</form>";
"</div>";
this.adjustImage(item);
// file selection
t.childNodes[2].firstChild.lastChild.onchange = function() {
item._is_uploading = true;
this.parentNode.submit();
this.parentNode.parentNode.className = "dhxform_image_wrap dhxform_image_in_progress";
this.value = ""; // prevent update on cancel click in chrome
}
// iframe updates
var that = this;
if (window.navigator.userAgent.indexOf("MSIE") >= 0) {
t.childNodes[1].onreadystatechange = function() {if (this.readyState == "complete") that.doOnUpload(item);}
} else {
t.childNodes[1].onload = function(){that.doOnUpload(item);}
}
this._moreClear = function() {
that = null;
}
// initial value
this.setValue(item, data.value||"");
t = null;
return this;
},
destruct: function(item) {
// custom functionality
var t = item.childNodes[item._ll?1:0].childNodes[0];
t.childNodes[2].firstChild.lastChild.onchange = null;
t.childNodes[1].onreadystatechange = null;
t.childNodes[1].onload = null;
this._moreClear();
// common form's unload
this.d2(item);
item = null;
},
doAttachEvents: function() {
},
setValue: function(item, value) {
item._value = (value==null?"":value);
var u = item._url+
(item._url.indexOf("?")>=0?"&":"?")+"action=loadImage"+
"&itemId="+encodeURIComponent(item._idd)+
"&itemValue="+encodeURIComponent(item._value)+
window.dhx4.ajax._dhxr("&")
var currentImg = item.childNodes[item._ll?1:0].childNodes[0].firstChild;
if (currentImg.nextSibling.tagName.toLowerCase() == "img") {
currentImg.nextSibling.src = u; // new img created and still loaded from prev setValue() call
} else {
var img = document.createElement("IMG");
img.className = "dhxform_image_img";
img.style.visibility = "hidden";
img.onload = function() {
this.style.visibility = "visible";
this.parentNode.removeChild(this.nextSibling);
this.onload = this.onerror = null;
}
img.onerror = function() {
this.onload.apply(this, arguments);
this.style.visibility = "hidden";
}
currentImg.parentNode.insertBefore(img, currentImg);
img.src = u;
img = null;
this.adjustImage(item);
}
currentImg = null;
},
getValue: function(item) {
return item._value;
},
doOnUpload: function(item) {
if (item._is_uploading == true) {
var fr = item.childNodes[item._ll?1:0].childNodes[0].lastChild.previousSibling; // iframe
var r = dhx4.s2j(fr.contentWindow.document.body.innerHTML);
if (typeof(r) == "object" && r != null && r.state == true && r.itemId == item._idd) {
this.setValue(item, r.itemValue, true);
item.getForm().callEvent("onImageUploadSuccess", [r.itemId, r.itemValue, r.extra])
} else {
// show empty field, r can be null
item.getForm().callEvent("onImageUploadFail", [item._idd, (r?r.extra:null)]);
}
r = fr = null;
window.setTimeout(function(){
item.childNodes[item._ll?1:0].childNodes[0].lastChild.className = "dhxform_image_wrap"; // div
item._is_uploading = false; // ready to new upload
},50);
}
},
adjustImage: function(item) {
var i = item.childNodes[item._ll?1:0].childNodes[0].firstChild; // image
var w = Math.min(item._dim.mw, item._dim.w);
var h = Math.min(item._dim.mh, item._dim.h);
i.style.width = w+"px";
i.style.height = h+"px";
i.style.marginLeft = Math.max(0, Math.round(item._dim.mw/2-w/2))+"px";
i.style.marginTop = Math.max(0, Math.round(item._dim.mh/2-h/2))+"px";
i = item = null;
}
};
(function(){
for (var a in dhtmlXForm.prototype.items.input) {
if (!dhtmlXForm.prototype.items.image[a]) dhtmlXForm.prototype.items.image[a] = dhtmlXForm.prototype.items.input[a];
}
})();
dhtmlXForm.prototype.items.image.d2 = dhtmlXForm.prototype.items.input.destruct;
dhtmlXForm.prototype.setFormData_image = function(name, value) {
this.setItemValue(name, value);
};
dhtmlXForm.prototype.getFormData_image = function(name) {
return this.getItemValue(name);
};

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,777 @@
/*! SWFObject v2.2 <http://code.google.com/p/swfobject/>
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject = function() {
var UNDEF = "undefined",
OBJECT = "object",
SHOCKWAVE_FLASH = "Shockwave Flash",
SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
FLASH_MIME_TYPE = "application/x-shockwave-flash",
EXPRESS_INSTALL_ID = "SWFObjectExprInst",
ON_READY_STATE_CHANGE = "onreadystatechange",
win = window,
doc = document,
nav = navigator,
plugin = false,
domLoadFnArr = [main],
regObjArr = [],
objIdArr = [],
listenersArr = [],
storedAltContent,
storedAltContentId,
storedCallbackFn,
storedCallbackObj,
isDomLoaded = false,
isExpressInstallActive = false,
dynamicStylesheet,
dynamicStylesheetMedia,
autoHideShow = true,
/* Centralized function for browser feature detection
- User agent string detection is only used when no good alternative is possible
- Is executed directly for optimal performance
*/
ua = function() {
var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
u = nav.userAgent.toLowerCase(),
p = nav.platform.toLowerCase(),
windows = p ? /win/.test(p) : /win/.test(u),
mac = p ? /mac/.test(p) : /mac/.test(u),
webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
playerVersion = [0,0,0],
d = null;
if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
d = nav.plugins[SHOCKWAVE_FLASH].description;
if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
plugin = true;
ie = false; // cascaded feature detection for Internet Explorer
d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
}
}
else if (typeof win.ActiveXObject != UNDEF) {
try {
var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
if (a) { // a will return null when ActiveX is disabled
d = a.GetVariable("$version");
if (d) {
ie = true; // cascaded feature detection for Internet Explorer
d = d.split(" ")[1].split(",");
playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
}
catch(e) {}
}
return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
}(),
/* Cross-browser onDomLoad
- Will fire an event as soon as the DOM of a web page is loaded
- Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/
- Regular onload serves as fallback
*/
onDomLoad = function() {
if (!ua.w3) { return; }
if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically
callDomLoadFunctions();
}
if (!isDomLoaded) {
if (typeof doc.addEventListener != UNDEF) {
doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
}
if (ua.ie && ua.win) {
doc.attachEvent(ON_READY_STATE_CHANGE, function() {
if (doc.readyState == "complete") {
doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
callDomLoadFunctions();
}
});
if (win == top) { // if not inside an iframe
(function(){
if (isDomLoaded) { return; }
try {
doc.documentElement.doScroll("left");
}
catch(e) {
setTimeout(arguments.callee, 0);
return;
}
callDomLoadFunctions();
})();
}
}
if (ua.wk) {
(function(){
if (isDomLoaded) { return; }
if (!/loaded|complete/.test(doc.readyState)) {
setTimeout(arguments.callee, 0);
return;
}
callDomLoadFunctions();
})();
}
addLoadEvent(callDomLoadFunctions);
}
}();
function callDomLoadFunctions() {
if (isDomLoaded) { return; }
try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
t.parentNode.removeChild(t);
}
catch (e) { return; }
isDomLoaded = true;
var dl = domLoadFnArr.length;
for (var i = 0; i < dl; i++) {
domLoadFnArr[i]();
}
}
function addDomLoadEvent(fn) {
if (isDomLoaded) {
fn();
}
else {
domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
}
}
/* Cross-browser onload
- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
- Will fire an event as soon as a web page including all of its assets are loaded
*/
function addLoadEvent(fn) {
if (typeof win.addEventListener != UNDEF) {
win.addEventListener("load", fn, false);
}
else if (typeof doc.addEventListener != UNDEF) {
doc.addEventListener("load", fn, false);
}
else if (typeof win.attachEvent != UNDEF) {
addListener(win, "onload", fn);
}
else if (typeof win.onload == "function") {
var fnOld = win.onload;
win.onload = function() {
fnOld();
fn();
};
}
else {
win.onload = fn;
}
}
/* Main function
- Will preferably execute onDomLoad, otherwise onload (as a fallback)
*/
function main() {
if (plugin) {
testPlayerVersion();
}
else {
matchVersions();
}
}
/* Detect the Flash Player version for non-Internet Explorer browsers
- Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
a. Both release and build numbers can be detected
b. Avoid wrong descriptions by corrupt installers provided by Adobe
c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
- Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
*/
function testPlayerVersion() {
var b = doc.getElementsByTagName("body")[0];
var o = createElement(OBJECT);
o.setAttribute("type", FLASH_MIME_TYPE);
var t = b.appendChild(o);
if (t) {
var counter = 0;
(function(){
if (typeof t.GetVariable != UNDEF) {
var d = t.GetVariable("$version");
if (d) {
d = d.split(" ")[1].split(",");
ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
else if (counter < 10) {
counter++;
setTimeout(arguments.callee, 10);
return;
}
b.removeChild(o);
t = null;
matchVersions();
})();
}
else {
matchVersions();
}
}
/* Perform Flash Player and SWF version matching; static publishing only
*/
function matchVersions() {
var rl = regObjArr.length;
if (rl > 0) {
for (var i = 0; i < rl; i++) { // for each registered object element
var id = regObjArr[i].id;
var cb = regObjArr[i].callbackFn;
var cbObj = {success:false, id:id};
if (ua.pv[0] > 0) {
var obj = getElementById(id);
if (obj) {
if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
setVisibility(id, true);
if (cb) {
cbObj.success = true;
cbObj.ref = getObjectById(id);
cb(cbObj);
}
}
else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
var att = {};
att.data = regObjArr[i].expressInstall;
att.width = obj.getAttribute("width") || "0";
att.height = obj.getAttribute("height") || "0";
if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
// parse HTML object param element's name-value pairs
var par = {};
var p = obj.getElementsByTagName("param");
var pl = p.length;
for (var j = 0; j < pl; j++) {
if (p[j].getAttribute("name").toLowerCase() != "movie") {
par[p[j].getAttribute("name")] = p[j].getAttribute("value");
}
}
showExpressInstall(att, par, id, cb);
}
else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
displayAltContent(obj);
if (cb) { cb(cbObj); }
}
}
}
else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
setVisibility(id, true);
if (cb) {
var o = getObjectById(id); // test whether there is an HTML object element or not
if (o && typeof o.SetVariable != UNDEF) {
cbObj.success = true;
cbObj.ref = o;
}
cb(cbObj);
}
}
}
}
}
function getObjectById(objectIdStr) {
var r = null;
var o = getElementById(objectIdStr);
if (o && o.nodeName == "OBJECT") {
if (typeof o.SetVariable != UNDEF) {
r = o;
}
else {
var n = o.getElementsByTagName(OBJECT)[0];
if (n) {
r = n;
}
}
}
return r;
}
/* Requirements for Adobe Express Install
- only one instance can be active at a time
- fp 6.0.65 or higher
- Win/Mac OS only
- no Webkit engines older than version 312
*/
function canExpressInstall() {
return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
}
/* Show the Adobe Express Install dialog
- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
*/
function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
isExpressInstallActive = true;
storedCallbackFn = callbackFn || null;
storedCallbackObj = {success:false, id:replaceElemIdStr};
var obj = getElementById(replaceElemIdStr);
if (obj) {
if (obj.nodeName == "OBJECT") { // static publishing
storedAltContent = abstractAltContent(obj);
storedAltContentId = null;
}
else { // dynamic publishing
storedAltContent = obj;
storedAltContentId = replaceElemIdStr;
}
att.id = EXPRESS_INSTALL_ID;
if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
fv = "MMredirectURL=" + encodeURI(window.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
if (typeof par.flashvars != UNDEF) {
par.flashvars += "&" + fv;
}
else {
par.flashvars = fv;
}
// IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
// because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
if (ua.ie && ua.win && obj.readyState != 4) {
var newObj = createElement("div");
replaceElemIdStr += "SWFObjectNew";
newObj.setAttribute("id", replaceElemIdStr);
obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf
obj.style.display = "none";
(function(){
if (obj.readyState == 4) {
obj.parentNode.removeChild(obj);
}
else {
setTimeout(arguments.callee, 10);
}
})();
}
createSWF(att, par, replaceElemIdStr);
}
}
/* Functions to abstract and display alternative content
*/
function displayAltContent(obj) {
if (ua.ie && ua.win && obj.readyState != 4) {
// IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
// because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
var el = createElement("div");
obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
el.parentNode.replaceChild(abstractAltContent(obj), el);
obj.style.display = "none";
(function(){
if (obj.readyState == 4) {
obj.parentNode.removeChild(obj);
}
else {
setTimeout(arguments.callee, 10);
}
})();
}
else {
obj.parentNode.replaceChild(abstractAltContent(obj), obj);
}
}
function abstractAltContent(obj) {
var ac = createElement("div");
if (ua.win && ua.ie) {
ac.innerHTML = obj.innerHTML;
}
else {
var nestedObj = obj.getElementsByTagName(OBJECT)[0];
if (nestedObj) {
var c = nestedObj.childNodes;
if (c) {
var cl = c.length;
for (var i = 0; i < cl; i++) {
if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
ac.appendChild(c[i].cloneNode(true));
}
}
}
}
}
return ac;
}
/* Cross-browser dynamic SWF creation
*/
function createSWF(attObj, parObj, id) {
var r, el = getElementById(id);
if (ua.wk && ua.wk < 312) { return r; }
if (el) {
if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
attObj.id = id;
}
if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
var att = "";
for (var i in attObj) {
if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
if (i.toLowerCase() == "data") {
parObj.movie = attObj[i];
}
else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
att += ' class="' + attObj[i] + '"';
}
else if (i.toLowerCase() != "classid") {
att += ' ' + i + '="' + attObj[i] + '"';
}
}
}
var par = "";
for (var j in parObj) {
if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
par += '<param name="' + j + '" value="' + parObj[j] + '" />';
}
}
el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
r = getElementById(attObj.id);
}
else { // well-behaving browsers
var o = createElement(OBJECT);
o.setAttribute("type", FLASH_MIME_TYPE);
for (var m in attObj) {
if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
o.setAttribute("class", attObj[m]);
}
else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
o.setAttribute(m, attObj[m]);
}
}
}
for (var n in parObj) {
if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
createObjParam(o, n, parObj[n]);
}
}
el.parentNode.replaceChild(o, el);
r = o;
}
}
return r;
}
function createObjParam(el, pName, pValue) {
var p = createElement("param");
p.setAttribute("name", pName);
p.setAttribute("value", pValue);
el.appendChild(p);
}
/* Cross-browser SWF removal
- Especially needed to safely and completely remove a SWF in Internet Explorer
*/
function removeSWF(id) {
var obj = getElementById(id);
if (obj && obj.nodeName == "OBJECT") {
if (ua.ie && ua.win) {
obj.style.display = "none";
(function(){
if (obj.readyState == 4) {
removeObjectInIE(id);
}
else {
setTimeout(arguments.callee, 10);
}
})();
}
else {
obj.parentNode.removeChild(obj);
}
}
}
function removeObjectInIE(id) {
var obj = getElementById(id);
if (obj) {
for (var i in obj) {
if (typeof obj[i] == "function") {
obj[i] = null;
}
}
obj.parentNode.removeChild(obj);
}
}
/* Functions to optimize JavaScript compression
*/
function getElementById(id) {
var el = null;
try {
el = doc.getElementById(id);
}
catch (e) {}
return el;
}
function createElement(el) {
return doc.createElement(el);
}
/* Updated attachEvent function for Internet Explorer
- Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
*/
function addListener(target, eventType, fn) {
target.attachEvent(eventType, fn);
listenersArr[listenersArr.length] = [target, eventType, fn];
}
/* Flash Player and SWF content version matching
*/
function hasPlayerVersion(rv) {
var pv = ua.pv, v = rv.split(".");
v[0] = parseInt(v[0], 10);
v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
v[2] = parseInt(v[2], 10) || 0;
return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
}
/* Cross-browser dynamic CSS creation
- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
*/
function createCSS(sel, decl, media, newStyle) {
if (ua.ie && ua.mac) { return; }
var h = doc.getElementsByTagName("head")[0];
if (!h) { return; } // to also support badly authored HTML pages that lack a head element
var m = (media && typeof media == "string") ? media : "screen";
if (newStyle) {
dynamicStylesheet = null;
dynamicStylesheetMedia = null;
}
if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
// create dynamic stylesheet + get a global reference to it
var s = createElement("style");
s.setAttribute("type", "text/css");
s.setAttribute("media", m);
dynamicStylesheet = h.appendChild(s);
if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
}
dynamicStylesheetMedia = m;
}
// add style rule
if (ua.ie && ua.win) {
if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
dynamicStylesheet.addRule(sel, decl);
}
}
else {
if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
}
}
}
function setVisibility(id, isVisible) {
if (!autoHideShow) { return; }
var v = isVisible ? "visible" : "hidden";
if (isDomLoaded && getElementById(id)) {
getElementById(id).style.visibility = v;
}
else {
createCSS("#" + id, "visibility:" + v);
}
}
/* Filter to avoid XSS attacks
*/
function urlEncodeIfNecessary(s) {
var regex = /[\\\"<>\.;]/;
var hasBadChars = regex.exec(s) != null;
return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
}
/* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
*/
var cleanup = function() {
if (ua.ie && ua.win) {
window.attachEvent("onunload", function() {
// remove listeners to avoid memory leaks
var ll = listenersArr.length;
for (var i = 0; i < ll; i++) {
listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
}
// cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
var il = objIdArr.length;
for (var j = 0; j < il; j++) {
removeSWF(objIdArr[j]);
}
// cleanup library's main closures to avoid memory leaks
for (var k in ua) {
ua[k] = null;
}
ua = null;
for (var l in swfobject) {
swfobject[l] = null;
}
swfobject = null;
});
}
}();
return {
/* Public API
- Reference: http://code.google.com/p/swfobject/wiki/documentation
*/
registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
if (ua.w3 && objectIdStr && swfVersionStr) {
var regObj = {};
regObj.id = objectIdStr;
regObj.swfVersion = swfVersionStr;
regObj.expressInstall = xiSwfUrlStr;
regObj.callbackFn = callbackFn;
regObjArr[regObjArr.length] = regObj;
setVisibility(objectIdStr, false);
}
else if (callbackFn) {
callbackFn({success:false, id:objectIdStr});
}
},
getObjectById: function(objectIdStr) {
if (ua.w3) {
return getObjectById(objectIdStr);
}
},
embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
var callbackObj = {success:false, id:replaceElemIdStr};
if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
setVisibility(replaceElemIdStr, false);
addDomLoadEvent(function() {
widthStr += ""; // auto-convert to string
heightStr += "";
var att = {};
if (attObj && typeof attObj === OBJECT) {
for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
att[i] = attObj[i];
}
}
att.data = swfUrlStr;
att.width = widthStr;
att.height = heightStr;
var par = {};
if (parObj && typeof parObj === OBJECT) {
for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
par[j] = parObj[j];
}
}
if (flashvarsObj && typeof flashvarsObj === OBJECT) {
for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
if (typeof par.flashvars != UNDEF) {
par.flashvars += "&" + k + "=" + flashvarsObj[k];
}
else {
par.flashvars = k + "=" + flashvarsObj[k];
}
}
}
if (hasPlayerVersion(swfVersionStr)) { // create SWF
var obj = createSWF(att, par, replaceElemIdStr);
if (att.id == replaceElemIdStr) {
setVisibility(replaceElemIdStr, true);
}
callbackObj.success = true;
callbackObj.ref = obj;
}
else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install
att.data = xiSwfUrlStr;
showExpressInstall(att, par, replaceElemIdStr, callbackFn);
return;
}
else { // show alternative content
setVisibility(replaceElemIdStr, true);
}
if (callbackFn) { callbackFn(callbackObj); }
});
}
else if (callbackFn) { callbackFn(callbackObj); }
},
switchOffAutoHideShow: function() {
autoHideShow = false;
},
ua: ua,
getFlashPlayerVersion: function() {
return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
},
hasFlashPlayerVersion: hasPlayerVersion,
createSWF: function(attObj, parObj, replaceElemIdStr) {
if (ua.w3) {
return createSWF(attObj, parObj, replaceElemIdStr);
}
else {
return undefined;
}
},
showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
if (ua.w3 && canExpressInstall()) {
showExpressInstall(att, par, replaceElemIdStr, callbackFn);
}
},
removeSWF: function(objElemIdStr) {
if (ua.w3) {
removeSWF(objElemIdStr);
}
},
createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
if (ua.w3) {
createCSS(selStr, declStr, mediaStr, newStyleBoolean);
}
},
addDomLoadEvent: addDomLoadEvent,
addLoadEvent: addLoadEvent,
getQueryParamValue: function(param) {
var q = doc.location.search || doc.location.hash;
if (q) {
if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark
if (param == null) {
return urlEncodeIfNecessary(q);
}
var pairs = q.split("&");
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
}
}
}
return "";
},
// For internal usage only
expressInstallCallback: function() {
if (isExpressInstallActive) {
var obj = getElementById(EXPRESS_INSTALL_ID);
if (obj && storedAltContent) {
obj.parentNode.replaceChild(storedAltContent, obj);
if (storedAltContentId) {
setVisibility(storedAltContentId, true);
if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
}
if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
}
isExpressInstallActive = false;
}
}
};
}();

Binary file not shown.