///
Array.Clone = function(array) {
if (!array) { return null; }
return Array.clone(array);
}
Array.Find = function(array, func, context, start, length) {
var index = Array.FindIndex.apply(Array, arguments);
if (index >= 0) { return array[index]; }
return null;
};
Array.FindAll = function(array, func, context, start, length) {
start = start ? start : 0;
length = length ? length : array.length;
var result = [];
for (var i = start; i < length; i++) {
var res = func.call(context, array[i], i, array);
if (res) { result[result.length] = array[i]; }
}
return -1;
};
Array.FindIndex = function(array, func, context, start, length) {
start = start ? start : 0;
length = length ? length : array.length;
for (var i = start; i < length; i++) {
var res = func.call(context, array[i], i, array);
if (res) { return i; }
}
return -1;
};
Array.FindLast = function(array, func, context, start, length) {
var index = Array.FindLastIndex.apply(Array, arguments);
if (index >= 0) { return array[index]; }
return null;
};
Array.FindLastIndex = function(array, func, context, start, length) {
start = start == null ? start : array.length - 1; // 0 is false
length = length == null ? array.length : length;
for (var i = start, l = start - length; i > l; i--) {
var res = func.call(context, array[i], i, array);
if (res) { return i; }
}
return -1;
};
Array.getRange = function(array, index, length) {
return array.slice(index, index + length);
};
Array.InsertRange = function(array, index, insertArray) {
var temp = [];
Array.addRange(temp, array.slice(0, index));
Array.addRange(temp, insertArray);
Array.addRange(temp, array.slice(index));
Array.clear(array);
Array.addRange(array, temp);
};
Array.IsArray = function(obj) {
if (obj.constructor == Array) { return true; }
return false;
};
Array.IsNullOrEmpty = function(value) {
if (!value) { return true; }
if (!Array.IsArray(value)) { return true; }
if (value.length == 0) { return true; }
return false;
};
Array.Load = function(obj, source, start, length) {
obj = obj ? obj : [];
start = start ? start : 0;
length = length ? length : source.length;
var data = source;
if (Array.IsArray(data)) {
if (start > 0) { data.slice(start); };
if (length < data.length) { data.slice(0, length - 1); }
}
else {
data = [];
for (var i = start, ilen = start + length; i < ilen; i++) {
if (i >= source.length) { break; }
data[data.length] = source[i];
}
}
if (!Array.IsArray(obj)) { obj.length = 0; }
Array.prototype.push.apply(obj, data);
return obj;
};
Array.RemoveRange = function(array, index, count) {
array.splice(index, count);
};
Cloneable = function(){ };
Cloneable.Clone = function(obj) {
var s = Sys.Serialization.JavaScriptSerializer.serialize(obj);
var result = Sys.Serialization.JavaScriptSerializer.deserialize(s);
return result;
};
Function.NotImplemented = function(message) {
return function() { alert(this.constructor.getName() + ': ' + message + ' not implemented'); };
};
Function.NotImplementedMethod = Function.NotImplementedFunction = function() { throw Error.notImplemented(message); };
Object.Extend = function(destination, source) {
for (var propertyName in source)
{
if (typeof(destination[propertyName]) == 'undefined')
{
destination[propertyName] = source[propertyName];
}
}
return destination;
};
Object.Sync = function(destination, source) {
for (var propertyName in source)
{
if (typeof (destination[propertyName]) != 'undefined')
{
destination[propertyName] = source[propertyName];
}
}
return destination;
}
String.IsNullOrEmpty = function(value) {
return !value;
};
String.PadLeft = function(s, padding, maxLength) {
var st = s + '';
while (st.length < maxLength)
{
st = padding + st;
}
return st;
};
String.PadRight = function(s, padding, maxLength) {
var st = s + '';
while (st.length < maxLength)
{
st += padding;
}
return st;
};
Sys.UI.DomElement.setClassname = function(element, className) {
if (!element) { return ''; }
if (!className)
{
element.className = '';
element.removeAttribute("class", 0); //Moz
element.removeAttribute("classname", 0); //IE
}
else
{
element.className = className;
}
}
Sys.UI.DomElement.getElementParentByTag = function(element, tagName) {
if (null == element) { return null; }
if (null == tagName) { return element; }
try
{
while (element && null != element.tagName && element.tagName != tagName)
{
element = element.parentNode;
}
return ((element.tagName == tagName) ? element : null);
}
catch (e) { return null; }
}
Sys.UI.DomElement.getOuterHTML = function(element) {
if (element.outerHTML) { return element.outerHTML; }
else
{
var elementCopy = element.cloneNode(true);
var tmpDiv = element.ownerDocument.createElement("DIV");
tmpDiv.appendChild(elementCopy);
return tmpDiv.innerHTML;
}
}
Sys.UI.DomElement.Clear = function(element) {
if (element)
{
if (element.childNodes)
{
while (element.childNodes.length > 0)
{
var child = element.childNodes[0];
if (typeof(child.outerHTML) != 'undefined')
{
try { child.outerHTML = ''; }
catch (e) { element.removeChild(child); }
}
else { element.removeChild(child); }
delete child;
}
}
}
}
Sys.UI.DomElement.setInnerHTML = function(element, content) {
Sys.UI.DomElement.Clear(element);
if (element)
{
try { element.innerHTML = ' ' + content; }
catch (ex)
{
try
{
var tmpDiv = element.ownerDocument.createElement("DIV");
tmpDiv.innerHTML = ' ' + content;
while (tmpDiv.childNodes.length > 0)
{
element.appendChild(tmpDiv.childNodes[0]);
}
}
catch (ex1) { return; }
}
element.removeChild(element.firstChild);
}
}
Sys.UI.DomEvent.prototype.Kill = function() {
this.stopPropagation();
this.preventDefault();
return false;
};
Type.prototype.AddElementToStore = function(elementName) {
var storeName = Contensis.Web.UI.$Contensis.PrivateStoreName;
this.CreatePrivateStore();
this.prototype[storeName].HTMLElements[this.prototype[storeName].HTMLElements.length] = elementName;
};
Type.prototype.CreatePrivateStore = function() {
var storeName = Contensis.Web.UI.$Contensis.PrivateStoreName;
if (typeof (this.prototype[storeName]) == 'undefined') {
this.prototype[storeName] = { HTMLElements: [] };
}
};
Type.prototype._registerClass = Type.prototype.registerClass;
Type.prototype.registerClass = function() {
if (typeof(this.prototype.Properties) != 'undefined')
{
for (var propertyName in this.prototype.Properties)
{
if (this.prototype.Properties.hasOwnProperty(propertyName))
{
if (typeof(this.prototype.Properties[propertyName]) != 'function')
{
var defaultDefinition = {type:Object, readOnly:false, writeOnly:false, initialValue:null, clone:true};
var definition = this.prototype.Properties[propertyName];
definition = Object.Extend(definition, defaultDefinition);
if ((definition.clone) && (typeof(definition.type.Clone) == 'function'))
{
definition.initialValue = definition.type.Clone(definition.initialValue);
}
var doRead = true;
if (definition.writeOnly) { doRead = false; }
var doWrite = true;
if (definition.readOnly) { doWrite = false; }
if (doRead) { this.registerGetter(propertyName, definition); }
if (doWrite) { this.registerSetter(propertyName, definition.type); }
}
}
}
}
if (typeof(this.prototype.Events) != 'undefined')
{
for (var eventName in this.prototype.Events)
{
if (this.prototype.Events.hasOwnProperty(eventName))
{
var defaultDefinition = {};
var definition = this.prototype.Events[eventName];
definition = Object.Extend(definition, defaultDefinition);
this.registerEvent(eventName, definition);
}
}
}
Type.prototype._registerClass.apply(this, arguments);
Type.prototype.LoadInterfaces.apply(this, arguments);
}
Type.prototype._initializeBase = Type.prototype.initializeBase;
Type.prototype.initializeBase = function(instance, baseArguments) {
Type.prototype._initializeBase.apply(this, arguments);
if (typeof (this.prototype.Properties) != 'undefined') {
for (var propertyName in this.prototype.Properties) {
if (this.prototype.Properties.hasOwnProperty(propertyName)) {
if (typeof (this.prototype.Properties[propertyName]) != 'function') {
var defaultDefinition = { type: Object, readOnly: false, writeOnly: false, initialValue: null, jQuery: false };
var definition = this.prototype.Properties[propertyName];
definition = Object.Extend(definition, defaultDefinition);
var initialValue = definition.initialValue;
if ((definition.clone) && (typeof (definition.type.Clone) == 'function')) {
initialValue = definition.type.Clone(initialValue);
}
instance['_' + propertyName] = initialValue;
}
}
}
}
if (typeof (this.prototype.Private) != 'undefined') {
for (var privateName in this.prototype.Private) {
if (this.prototype.Private.hasOwnProperty(privateName)) {
var defaultDefinition = { type: Object, initialValue: null, clone: true };
var definition = this.prototype.Private[privateName];
definition = Object.Extend(definition, defaultDefinition);
var initialValue = definition.initialValue;
if ((definition.clone) && (typeof (definition.type.Clone) == 'function')) {
initialValue = definition.type.Clone(initialValue);
}
instance['_' + privateName] = initialValue;
}
}
}
}
Type.prototype.registerEvent = function(eventName, definition) {
var addFunc = function(handler) { this.get_events().addHandler(eventName, handler); };
if (typeof(this.prototype.Events['add_' + eventName]) == 'function')
{
addFunc = this.prototype.Events['add_' + eventName];
}
this.prototype['add_' + eventName] = addFunc;
var removeFunc = function(handler) { this.get_events().removeHandler(eventName, handler); };
if (typeof(this.prototype.Events['remove_' + eventName]) == 'function')
{
removeFunc = this.prototype.Events['remove_' + eventName];
}
this.prototype['remove_' + eventName] = removeFunc;
var raiseFunc = function(args) {
var handler = this.get_events().getHandler(eventName);
if (handler) {
if (!args) { args = Sys.EventArgs.Empty; }
handler(this, args);
}
};
if (typeof(this.prototype.Events['raise_' + eventName]) == 'function')
{
raiseFunc = this.prototype.Events['raise_' + eventName];
}
this.prototype['raise_' + eventName] = raiseFunc;
}
Type.prototype.registerGetter = function(propertyName, definition) {
var privateName = '_' + propertyName;
if (definition.type == Sys.UI.DomElement) { this.AddElementToStore(privateName); }
var f = function() { return this[privateName]; };
if (typeof(this.prototype.Properties['get_' + propertyName]) == 'function')
{
f = this.prototype.Properties['get_' + propertyName];
}
this.prototype['get_' + propertyName] = f;
}
Type.prototype.registerSetter = function(propertyName, definition) {
var privateName = '_' + propertyName;
if (definition.type == Sys.UI.DomElement) { this.AddElementToStore(privateName); }
var f = function(value) {
if (this[privateName] !== value) {
this[privateName] = value;
if (typeof(this.raisePropertyChanged) == 'function')
{
this.raisePropertyChanged(propertyName);
}
}
};
if (typeof(this.prototype.Properties['set_' + propertyName]) == 'function')
{
f = this.prototype.Properties['set_' + propertyName];
}
this.prototype['set_' + propertyName] = f;
}
Type.prototype._registerInterface = Type.prototype.registerInterface;
Type.prototype.registerInterface = function() {
if (typeof(this.prototype.Properties) != 'undefined')
{
for (var propertyName in this.prototype.Properties)
{
if (this.prototype.Properties.hasOwnProperty(propertyName))
{
if (typeof(this.prototype.Properties[propertyName]) != 'function')
{
var defaultDefinition = {readOnly:false, writeOnly:false};
var definition = this.prototype.Properties[propertyName];
definition = Object.Extend(definition, defaultDefinition);
var doRead = true;
if (definition.writeOnly) { doRead = false; }
var doWrite = true;
if (definition.readOnly) { doWrite = false; }
if (doRead) { this.registerInterfaceGetter(propertyName); }
if (doWrite) { this.registerInterfaceSetter(propertyName); }
}
}
}
}
if (typeof(this.prototype.Methods) != 'undefined')
{
for (var methodName in this.prototype.Methods)
{
if (this.prototype.Methods.hasOwnProperty(methodName))
{
var defaultDefinition = {};
var definition = this.prototype.Methods[methodName];
definition = Object.Extend(definition, defaultDefinition);
this.registerInterfaceMethod(methodName);
}
}
}
Type.prototype._registerInterface.apply(this, arguments);
}
Type.prototype.registerInterfaceGetter = function(propertyName) {
this.prototype['get_' + propertyName] = Function.NotImplemented('get_' + propertyName);
}
Type.prototype.registerInterfaceSetter = function(propertyName) {
this.prototype['set_' + propertyName] = Function.NotImplemented('set_' + propertyName);
}
Type.prototype.registerInterfaceMethod = function(methodName) {
this.prototype[methodName] = Function.NotImplemented(methodName);
}
Type.prototype.Create = function() {
var f = function() {};
f.prototype = this.prototype;
f.prototype.constructor = this;
var result = new f();
this.apply(result, arguments);
return result;
}
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();