'use strict';
/* jshint undef: true, unused: false, strict: true, curly: false, funcscope: true, globalstrict: true, proto: true, shadow: false, quotmark: single, eqnull: true, eqeqeq: true */
/* global __METHOD__, AppBase, WindowLib, setTimeout, AppStaticLib, window, console, document, navigator, jQuery, unescape, alert, Element, __LINE__ */
/*AppStaticLib START*/
if (typeof(String.getHash) === 'undefined') {
Object.defineProperty(String.prototype, 'hashCode', {
value: function() {
return this.split('').reduce(function(a,b) {
a=((a<<5)-a)+b.charCodeAt(0);
return a&a;
},
0);
}
});
}
if (!Number.isInteger) {
Number.isInteger = function(value) {
return typeof value === 'number' &&
isFinite(value) &&
Math.floor(value) === value;
};
}
// Production steps of ECMA-262, Edition 6, 22.1.2.1
if (!Array.from) {
Array.from = (function () {
var symbolIterator;
try {
symbolIterator = window.Symbol.iterator ? window.Symbol.iterator : 'Symbol(Symbol.iterator)';
} catch (e) {
symbolIterator = 'Symbol(Symbol.iterator)';
}
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
return (
typeof fn === 'function' ||
toStr.call(fn) === '[object Function]'
);
};
var toInteger = function (value) {
var number = Number(value);
if (isNaN(number)) return 0;
if (number === 0 || !isFinite(number)) return number;
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function (value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var setGetItemHandler = function setGetItemHandler(isIterator, items) {
var iterator = isIterator && items[symbolIterator]();
return function getItem(k) {
return isIterator ? iterator.next() : items[k];
};
};
var getArray = function getArray(
T,
A,
len,
getItem,
isIterator,
mapFn
) {
// 16. Let k be 0.
var k = 0;
// 17. Repeat, while k < len… or while iterator is done (also steps a - h)
while (k < len || isIterator) {
var item = getItem(k);
var kValue = isIterator ? item.value : item;
if (isIterator && item.done) {
return A;
} else {
if (mapFn) {
A[k] =
typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
}
k += 1;
}
if (isIterator) {
throw new TypeError(
'Array.from: provided arrayLike or iterator has length more then 2 ** 52 - 1'
);
} else {
A.length = len;
}
return A;
};
// The length property of the from method is 1.
return function from(arrayLikeOrIterator /*, mapFn, thisArg */) {
// 1. Let C be the this value.
var C = this;
// 2. Let items be ToObject(arrayLikeOrIterator).
var items = Object(arrayLikeOrIterator);
var isIterator = isCallable(items[symbolIterator]);
// 3. ReturnIfAbrupt(items).
if (arrayLikeOrIterator == null && !isIterator) {
throw new TypeError(
'Array.from requires an array-like object or iterator - not null or undefined'
);
}
// 4. If mapfn is undefined, then let mapping be false.
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
var T;
if (typeof mapFn !== 'undefined') {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError(
'Array.from: when provided, the second argument must be a function'
);
}
// 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 2) {
T = arguments[2];
}
}
// 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length);
// 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method
// of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
return getArray(
T,
A,
len,
setGetItemHandler(isIterator, items),
isIterator,
mapFn
);
};
})();
}
/* developer code start */
window.opencount = 0;
/* developer code end */
window.emulationMode = 0;
if (true) {
window.AppStaticLib = {
StrictifyAppCode: function(code, url, controls) {
var whereToStore = function() {
var App=1;
window.Framework.prop.ClassCollection[1] = App;
};
var stringLocation = whereToStore.toString();
var insertIndex = stringLocation.indexOf('=1;') + 3;
stringLocation = stringLocation.substring(0, (stringLocation.length - 1));
stringLocation = stringLocation.substring(insertIndex);
insertIndex = (stringLocation.indexOf('[1]') + 1);
var finalResult = stringLocation.substring(0, insertIndex) + '\'' + url + '\'' + stringLocation.substring(insertIndex + 1);
var othercontrols = '';
if (Array.isArray(controls) === true) {
var name = '';
var enddot = -1;
var endslash = -1;
var bit = null;
for (var i = 0; i < controls.length; i++) {
name = controls[i];
enddot = -1;
endslash = -1;
bit = null;
//var str = 'platform/system/js/calculator.js';
for (var j = (name.length - 1); j >= 0; j--) {
bit = name[j];
if ((bit === '.')){// && (enddot === -1)) {
enddot = j;
continue;
}
if ((bit === '/') && (endslash === -1)) {
endslash = j;
break;
}
}
name = name.substr((endslash + 1), (enddot - endslash - 1));
assertgroup('appbubble', 'This is where we should fill the local variables from hidden global memory pool');
//othercontrols += 'var ' + name + ';\n';
}
}
return '\'use strict\';\n' + othercontrols + code + finalResult;
},
//Private - Passed a Row-record and a Display-key-string, it uses the string to figure out how you want the row displayed to the user, filling that skeleton with actual data
_DisplayRecord: function(record, display) {
if ((typeof(record) === 'undefined') || (record === null)) return;
if (typeof(record) !== 'object') return record;
if (window.Framework.prop.developer) {
console.log(record);
}
var currentString = display;
var returnString = '';
//var closeIndex = -1;
var start = display.indexOf('{');
//var index = 0;
var value = '';
var end = null;
var colName = null;
//If it's just a string, assume it refers to a single column
if (start === -1) {
//So wrap it the way column names normally are
currentString = '{' + display + '}';
start = 0;
}
while (start > -1) {
//Get everything from the start to the first tag (ignoring the tag's contents)
returnString += currentString.substr(0, start);
end = currentString.indexOf('}');
//get colName (the tag's content is the Column name)
colName = currentString.substr((start + 1), (end - start - 1));
//Strip out the part we have processed so far
currentString = currentString.substr((end + 1));
value = record[colName];
if ((typeof(value) === 'undefined') || (value === null)) { value = ''; }
//Add the value of the Column
returnString += value;
//Then check if there are remaining column-names to replace
start = currentString.indexOf('{');
}
//Recombine the processed part and the remainder, then return it
return returnString + currentString;
},
clone: function(item) {
if (!item) { return item; } // null, undefined values check
var types = [ Number, String, Boolean ];
var result;
// normalizing primitives if someone did new String('aaa'), or new Number('444');
types.forEach(function(type) {
if (typeof(type) === 'undefined') throw new Error(__METHOD__ + ' reports that the type was not found on line ' + __LINE__);
if (item instanceof type) {
result = type( item );
}
});
if (typeof(result) === 'undefined') {
if (Object.prototype.toString.call(item) === '[object Array]') {
result = [];
item.forEach(function(child, index) {
result[index] = AppStaticLib.clone(child);
});
} else if (typeof(item) === 'object') {
if (AppStaticLib.IsAnApp(item) ) {
return item;
} else if ((item.nodeType) && (typeof(item.cloneNode) === 'function')) {
// testing that this is DOM
result = item.cloneNode( true );
} else if (!item.prototype) { // check that this is a literal
if (item instanceof Date) {
result = new Date(item);
} else {
// it is an object literal
result = {};
for (var i in item) {
result[i] = AppStaticLib.clone(item[i]);
}
}
} else {
// depending what you would like here,
// just keep the reference, or create new object
if (item.constructor) {
// would not advice to do that, reason? Read below
result = new item.constructor();
} else {
result = item;
}
}
} else {
result = item;
}
}
return result;
},
Hyphenate: function(str, len) {
var res = '';
for (var i = 0; i < str.length; i += len) {
if (res !== '') res += '-';
res += str.substr(i, len);
}
return res;
},
IsFileCall: function(str) {
var type = typeof(str);
if (str === null) return false;
if (type === 'string') {
var parts = str.split('\'');
if (parts.length < 3) return false;
if (parts[0] !== Object.keys({url:0})[0] + ':(' ) return false;
if (parts[parts.length - 1] !== ');' ) return false;
return true;
} else if (type === 'object') {
if (typeof(str.url) === 'string') return true;
return false;
}
return false;
},
IsAppCall: function(str) {
var type = typeof(str);
if (str === null) return false;
if (type === 'string') {
var parts = str.split('(')[0];
if (parts !== (Object.keys({app:0}) + ':')) {
return false;
}
return true;
} else if (type === 'object') {
if (typeof(str.app) === 'object') return true;
return false;
}
return false;
},
ExplodeAppCall: function(str) {
//if (StaticLib.Empty(str) && typeof(str) === 'object') return;
var type = typeof(str);
if (str === null) return;
if (type === 'string') {
var raw_api = str.split('app:(')[1];
var api = '{' +raw_api.split(');')[0]+ '}';
try {
return JSON.parse(api);
} catch(e) {
throw new Error('Can\'t Explode App Call API because incorrect Syntax of JSON String. Example use \' instead of \' ');
}
} else if (type === 'object') {
if ((typeof(str.app) === 'object') && (str.app !== null)) return str.app;
return;
}
return;
},
ExplodeUrl: function(str) {
var type = typeof(str);
if (str === null) return null;
if (type === 'string') {
var parts = str.split('\'');
if (!AppStaticLib.IsFileCall(str)) return null;
var newStr = '';
for (var i = 1; i < (parts.length - 1); i++) {
if (newStr !== '') newStr += '\'';
newStr += parts[i];
}
return newStr;
} else if (type === 'object') {
if (typeof(str.url) === 'string') return str.url;
return null;
}
return null;
},
Layer5: function(encode, searchText) {
var openTagText = '';
var optionalTagText = '\' title=\'';
var closeTagText = '';
//Argument(encode) is expected in order to inform behaviour, and is therefore required
if (typeof(encode) !== 'boolean') throw new Error('AppStaticLib.Layer5: Argument 1 is expected to be a boolean (used to determine logic, whether to encode/decode the searchText [Arg 2])');
//
if (StaticLib.Empty(searchText)) return searchText;
if (typeof(searchText) !== 'string') throw new Error('AppStaticLib.Layer5: Argument 2 is expected to be a String variable, with a value we will encode/decode based on the boolean 1st argument)');
if (encode) {
return AppStaticLib._DoLayer5(searchText, openTagText, openTagText2, openTagText3, closeTagText, optionalTagText);
} else {
return AppStaticLib._UndoLayer5(searchText, openTagText, openTagText2, openTagText3, closeTagText);
}
},
_UndoLayer5: function(searchText, openTagText, openTagText2, openTagText3, closeTagText) {
var start = -1;
var before = '';
var after = '';
var end = -1;
//find the openTag
start = searchText.search(openTagText);
while (start > -1) {
end = (start + openTagText.length);
before = searchText.substr(0, start);
after = searchText.substr(end);
searchText = before+after;
//find the closeTag
start = searchText.indexOf(closeTagText);
if (start > -1) {
end = (start + closeTagText.length);
before = searchText.substr(0, start);
after = searchText.substr(end);
searchText = before+after;
}
start = searchText.search(openTagText);
}
//alert(searchText);
return searchText;
},
_DoLayer5: function(searchText, openTagText, openTagText2, openTagText3, closeTagText, optionalTagText) {
var emailPattern = /([\s'']|^)[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?(?=[.,\s''<]|$)/i;
var emailPattern2 = /(?:[\s'']|^)(["]?[^&]+(?:(?:<(' ')?)|("\s)))([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?(?:>)?)(?=[.,\s''<]|$)/i;
var start = -1;
var before = '';
var after = '';
var end = -1;
var count = 0;
var currentEmail = '';
var untrimmedEmail = '';
var newText = '';
var modifier = 0;
//find the openTag
start = searchText.search(emailPattern);
while (start > -1) {
start++;
untrimmedEmail = emailPattern.exec(searchText)[0];//.toString();
currentEmail = jQuery.trim(untrimmedEmail);//currentEmail.substr(1, currentEmail.length-2);
end = (start + currentEmail.length);
modifier = 0;
if (currentEmail.length === untrimmedEmail.length) {
modifier = -1;
}
before = searchText.substr(0, (start + modifier));
after = searchText.substr(end);
//newText = newText + before+openTagText+currentEmail+closeTagText;
newText = newText + before+openTagText+currentEmail+openTagText2+openTagText3+currentEmail+closeTagText;
searchText = after;
start = searchText.search(emailPattern);
count++;
}
start = searchText.search(emailPattern2);
searchText = newText+searchText;
if (start > -1) {
start = searchText.search(emailPattern2);
while (start > -1) {
untrimmedEmail = emailPattern2.exec(searchText)[0];//.toString();
currentEmail = jQuery.trim(untrimmedEmail);//"ludespatch@crossdocks.com.au" <ludespatch@crossdocks.com.au>
end = (start + currentEmail.length);
currentEmail= currentEmail.split(/(?:(?:<)|(?:"\s))/i);
var emailAddress = currentEmail[1];
emailAddress = emailAddress.replace('<', '');
emailAddress = emailAddress.replace('>', '');
var emailContactName = currentEmail[0];
emailContactName = emailContactName.replace(/"/g, '');
modifier = 0;
if (currentEmail.length === untrimmedEmail.length) {
modifier = -1;
}
before = searchText.substr(0, (start + modifier));
after = searchText.substr(end);
//newText = newText + before+openTagText+currentEmail+closeTagText;
newText = newText + before+openTagText+emailAddress+openTagText2+optionalTagText+emailAddress+openTagText3+emailContactName+closeTagText;
searchText = after;
start = searchText.search(emailPattern2);
count++;
}
searchText = newText+searchText;
}
return searchText;
},
//! IsAnApp taking one argument and returns a boolean about whether the argument is an App.
/*!
\param dom element or jquery selected element (example this, jQuery('#thisId')).
\return boolean
*/
IsAnApp: function(suspect) {
if (typeof(AppBase) === 'undefined') return false;
if (suspect instanceof(AppBase)) return true;
if (suspect === null) return false;
if (typeof suspect !== 'object') return false;
if (typeof suspect.OnLoad !== 'function') return false;
if (typeof suspect.FormObjects !== 'object') return false;
if (typeof suspect.BindFormObjects !== 'function') return false;
//suspect has been interrogated and SEEMS to probably be an App...
return true;
},
IsControl: function(suspect) {
if (suspect === null) return false;
if (typeof(suspect)!== 'object') return false;
if (typeof(window.Framework) !== 'object') return false;
if (typeof(window.FrameworkControls) !== 'object') return false;
if (typeof(window.Framework.Controls.AppButtonControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.AppButtonControl)) return true;
}
if (typeof(window.Framework.Controls.AvailableSearch) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.AvailableSearch)) return true;
}
if (typeof(window.Framework.Controls.DateControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.DateControl)) return true;
}
if (typeof(window.Framework.Controls.EmailSelectControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.EmailSelectControl)) return true;
}
if (typeof(window.Framework.Controls.FileSystem) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.FileSystem)) return true;
}
if (typeof(window.Framework.Controls.FileUploadControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.FileUploadControl)) return true;
}
if (typeof(window.Framwork.Controls.GridControl) !== 'undefined') {
if (suspect instanceof(window.Framwork.Controls.GridControl)) return true;
}
if (typeof(window.Framework.Controls.HTMLControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.HTMLControl)) return true;
}
if (typeof(IFrameControl) !== 'undefined') {
//if (suspect instanceof(IFrameControl)) return true;
throw new Error(__METHOD__ + ' reports that the IFrameControl can no longer be tested this way on line ' + __LINE__);
}
if (typeof(window.Framework.Controls.InvoiceEngine) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.InvoiceEngine)) return true;
}
if (typeof(window.Framework.Controls.SelectBoxControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.SelectBoxControl)) return true;
}
if (typeof(window.Framework.Controls.SelectBoxButtonControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.SelectBoxButtonControl)) return true;
}
if (typeof(window.Framework.Controls.ServletTreeView) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.ServletTreeView)) return true;
}
if (typeof(window.Framework.Controls.SmartGrid) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.SmartGrid)) return true;
}
if (typeof(window.Framework.Controls.SuggestiveSearchControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.SuggestiveSearchControl)) return true;
}
if (typeof(window.Framework.Controls.TabControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.TabControl)) return true;
}
/*if (typeof(TaskManagerControl) !== 'undefined') {
if (suspect instanceof(TaskManagerControl)) return true;
}
if (typeof(TreeView) !== 'undefined') {
if (suspect instanceof(TreeView)) return true;
}
if (typeof(Wsywig) !== 'undefined') {
if (suspect instanceof(Wsywig)) return true;
}*/
if (typeof(window.Framework.Controls.EmailControl) !== 'undefined') {
if (suspect instanceof(window.Framework.Controls.EmailControl)) return true;
}
//suspect has been interrogated and doesn't SEEM to match current controls...
return false;
},
GetGridFromElement: function(element) {
var isAGrid = function(subject) {
if (typeof(subject) !== 'object') return false;
if (typeof(subject.GetControlName) !== 'function') return false;
return (subject.GetControlName() === 'GridControl');
};
if ((element === null) || (typeof(element) !== 'object')) throw new Error('AppStaticLib can\'t GetGridFromElement from a non-object');
//if (element instanceof GridControl) return element;
if (isAGrid(element)) return element;
if ((typeof(element.grid) !== 'undefined') && (isAGrid(element.grid))) return element.grid;
if (typeof(element.StoredParent) !== 'undefined') element = element.StoredParent;
var parentApp = AppStaticLib.GetThisApp(element);
return parentApp._controls.Grids[jQuery(element).parents('.gridContainer').attr('id')];
},
GetThisAppAndIgnoreTheseThings: function(element) {
var IgnoreIDs = ['selenium-ide-indicator', 'ROMMissing', 'LoadingScreen', 'ID', 'ROMDebugInfo', 'ClassName', 'LoadingScreen', 'desktop', 'hovered', 'dialog-extend-fixed-container', 'themeSelector', 'ROMBuild'];
var IgnoreClasses = ['ClassName', 'ROMDebugInfo', 'ROMBlueScreen', 'cke', 'cke_panel_frame', 'CodeMirror-lint-tooltip', 'CodeMirror-hint', 'CodeMirror-hints', 'CodeMirror-lint-message-error', 'CodeMirror-lint-message-warning', 'ui-front', 'h1', 'notification', 'ui-widget-overlay'];
var IgnoreMe = false;
var count = 0;
for (count = 0; ((count < IgnoreClasses.length) && (IgnoreMe === false)); count++) {
if (jQuery(element).hasClass(IgnoreClasses[count])) {
IgnoreMe = true;
break;
}
}
if (IgnoreMe !== true) {
for (count = 0; ((count < IgnoreIDs.length) && (IgnoreMe === false)); count++) {
if ((jQuery(element)[0].id === IgnoreIDs[count]) || (jQuery(element).parents('#' + IgnoreIDs[count]).length >= 1)) {
IgnoreMe = true;
break;
}
}
}
var parent = null;
if (IgnoreMe !== true) {
try {
parent = AppStaticLib.GetThisAppOf(element);
} catch (err) {
parent = null;
}
}
return parent;
},
//! GetThisApp taking one argument and returns an object, either the argument itself if it is an App, or the App instance associated with it otherwise.
/*!
\param dom element or jquery selected element (example this, jQuery('#thisId')).
\return App WindowStruct as an object
*/
GetThisApp: function(element) {
//On the off chance the context is the Window...
if (this.App) {
if (AppStaticLib.IsAnApp(this.App)) return this.App;
}
//On the off chance we are already in context, check
if (AppStaticLib.IsAnApp(element)) return element;
//Otherwise find the App based on the element
return AppStaticLib.GetThisAppOf(element);
},
//! GetStructOf taking one argument and returns the App WindowStruct associated with that argument as an object.
/*!
\param dom element or jquery selected element (example this, jQuery('#thisId')).
\return App WindowStruct as an object
\sa Uses GetCollectionOf() to get all objects associated with that element, then returns just the WindowStruct
*/
GetStructOf: function(element) {
//For the item we are sent, find the collection that includes the App instance
var collection = AppStaticLib.GetCollectionOf(element);
//If found...
if (typeof collection === 'undefined') return null;
//return the App instance
return collection.struct;
},
//! GetThisAppOf taking one argument and returns the App instance associated with that argument as an object.
/*!
\param dom element or jquery selected element (example this, jQuery('#thisId')).
\return App WindowStruct as an object
*/
GetThisAppOf: function(element) {
if (typeof(jQuery(element)[0]) === 'undefined') throw new Error('Invalid element');
if ((element.length === 0) || (typeof(jQuery(element)[0]) === 'undefined')) return null;
if (jQuery(element)[0].tagName === 'BODY') return null;
if ((element.type) && (element.target)) {
element = element.target;
}
//For the item we are sent, find the collection that includes the App instance
var collection = AppStaticLib.GetCollectionOf(element);
//If found...
if ((typeof(collection) === 'undefined') || (collection === null)) return null;
//return the App instance
return collection.instance;
},
//! GetCollectionOf taking one argument and returns an object containing references (App instance, WindowStruct, Window id) associated with that argument.
/*!
\param dom element or jquery selected element (example this, jQuery('#thisId')).
\return App WindowStruct as an object
*/
GetWindowOf: function(element) {
var elementsWindow = '';
if ((typeof(element.length) === 'number') && (element.length > 0) && (typeof(element[0].nodeName) === 'string') && (typeof(element[0].nodeType) === 'number')) element = element[0];
if ((typeof(element.AppDetails) !== 'object') && (document.body.contains(jQuery(element)[0]) !== true)) {
if (document.body.contains(jQuery(element)[0].StoredParent)) {
element = element.StoredParent;
} else {
return null;
}
}
if (element.parentElement === null) {
return null;
}
if (
((typeof(element.parentElement) !== 'undefined') && (element.parentElement !== null)) &&
((element.id === 'AppTopMenu') || (element.id === 'AppBottomMenu') || (element.id === 'AppLeftMenu') || (element.id === 'AppRightMenu') ||
(element.parentElement.id === 'AppTopMenu') || (element.parentElement.parentElement.id === 'AppTopMenu') || (jQuery(element.parentElement).hasClass('ui-dialog')) ||
((element.parentElement.id === 'AppBottomMenu') || (element.parentElement.parentElement.id === 'AppBottomMenu')) ||
((element.parentElement.id === 'AppLeftMenu') || (element.parentElement.parentElement.id === 'AppLeftMenu')) ||
((element.parentElement.id === 'AppRightMenu') || (element.parentElement.parentElement.id === 'AppRightMenu')) ||
/*(jQuery(element.parentElement).hasClass('ui-dialog-titlebar')) || (jQuery(element).hasClass('ui-dialog-titlebar')) ||
((element.parentElement.parentElement !== null) && (jQuery(element.parentElement.parentElement).hasClass('ui-dialog-titlebar'))) || */
(jQuery(element).parents('.ui-dialog-titlebar').length === 1) ||
(jQuery(element).parents('.WindowPosition').length) || (jQuery(element).parents('#AppTopMenu').length) || (jQuery(element).parents('#AppBottomMenu').length) ||
(jQuery(element).parents('#AppLeftMenu').length) || (jQuery(element).parents('#AppRightMenu').length))
) {
var container = AppStaticLib.GetContainerOf(element);
if (container.hasClass('containedapp')) return container;
elementsWindow = container.children('.ui-dialog-content');
if (elementsWindow.length === 0) {
elementsWindow = container.children('.ui-dialog-inner').children('[instance]');
}
} else {
if ((jQuery(element).hasClass('ui-dialog-maximized')) || (jQuery(element).hasClass('ui-dialog-normal')) || (jQuery(element).hasClass('containedapp'))) {
elementsWindow = jQuery(element);
} else {
if (AppStaticLib.IsAnApp(element)) {
//elementsWindow = jQuery(element.prop.handle);
elementsWindow = jQuery(element.prop.popup);
} else {
if (jQuery(element).hasClass('ui-dialog')) {
elementsWindow = jQuery(element).children('[instance]');
if (elementsWindow.length === 0) {
elementsWindow = jQuery(element).children('.ui-dialog-inner').children('[instance]');
}
} else {
elementsWindow = jQuery(element).parents('.containedapp');
if (elementsWindow.length === 0) {
elementsWindow = jQuery(element).parents('[instance]');
if (elementsWindow.length === 0) {
elementsWindow = jQuery(element).children('.ui-dialog-inner').children('[instance]');
}
}
}
}
}
}
//Check that JQuery found atleast one object
if (elementsWindow.length === 0) {
if (StaticLib.Empty(element.id) === true) return null;
/* jshint debug: true */debugger;
/* developer code start */
var error = 'Developer Error A1: The argument provided is not associated with any App. for element ID [' + element.id + '] InnerText: [' + element.innerText + ']';
if (window.Framework.prop.developer) {
debugger;
window.Framework.UI.MsgBox({title:'Developer Notification', message: error, modal: true, width: 400, height: 300});
}
/* developer code end */
return null;
}
return elementsWindow;
},
GetContainerOf: function(element) {
if ((element === null) || (typeof(element) === 'undefined')) return null;
var elementsWindow = '';
if ((jQuery(element).hasClass('ui-dialog')) || (jQuery(element).hasClass('containedapp'))) {
elementsWindow = jQuery(element);
return (elementsWindow.length === 0) ? null : elementsWindow;
}
if (element !== jQuery(element)[0]) element = element[0];
if (AppStaticLib.IsAnApp(element)) {
if (element.prop === null) return null;
if (element.prop.handle === null) return null;
elementsWindow = jQuery(element.prop.handle).parents('.ui-dialog');
return (elementsWindow.length === 0) ? null : elementsWindow;
}
//} else {
elementsWindow = jQuery(element).parents('.ui-dialog');
if (elementsWindow.length === 0) {
elementsWindow = jQuery(element).parents('.containedapp');
}
var temp = null;
if (elementsWindow.length === 0) {
temp = jQuery(element)[0];
if (temp === null) {
/* jshint debug: true */debugger;
// we lost our app context?
return null;
}
//if (jQuery(element)[0].id === 'AppTopMenu') elementsWindow = jQuery(element);
//else elementsWindow = jQuery(element).parents('#AppTopMenu');
if (typeof(temp) === 'undefined') return null;
if (temp.id === 'AppTopMenu') elementsWindow = temp;
else elementsWindow = jQuery(temp).parents('#AppTopMenu');
if (elementsWindow.length !== 0) {
//elementsWindow = jQuery(element).parents('#AppTopMenu').parent().children('.ui-dialog');
if (jQuery(element)[0].id === 'AppTopMenu') elementsWindow = jQuery(element);
else elementsWindow = jQuery(element).parents('#AppTopMenu');
temp = elementsWindow.parent().children('.ui-dialog');
if (temp.length === 0) elementsWindow = elementsWindow.parent().children('.AppContainer').children('.containedapp');
else elementsWindow = temp;
return (elementsWindow.length === 0) ? null : elementsWindow;
}
elementsWindow = jQuery(element).parents('#AppLeftMenu');
if (elementsWindow.length !== 0) {
//elementsWindow = jQuery(element).parents('#AppLeftMenu').parent().children('.ui-dialog');
if (jQuery(element)[0].id === 'AppLeftMenu') elementsWindow = jQuery(element);
else elementsWindow = jQuery(element).parents('#AppLeftMenu');
temp = elementsWindow.parent().children('.ui-dialog');
if (temp.length === 0) elementsWindow = elementsWindow.parent().parent().children('.containedapp');
else elementsWindow = temp;
}
if (elementsWindow.length === 0) {
elementsWindow = jQuery(element).parents('#AppRightMenu');
if (elementsWindow.length !== 0) {
//elementsWindow = jQuery(element).parents('#AppRightMenu').parent().children('.ui-dialog');
if (jQuery(element)[0].id === 'AppRightMenu') elementsWindow = jQuery(element);
else elementsWindow = jQuery(element).parents('#AppRightMenu');
temp = elementsWindow.parent().parent().children('.ui-dialog');
if (temp.length === 0) elementsWindow = elementsWindow.parent().parent().children('.containedapp');
else elementsWindow = temp;
}
}
if (elementsWindow.length === 0) {
elementsWindow = jQuery(element).parents('#AppBottomMenu');
if (elementsWindow.length !== 0) {
//elementsWindow = jQuery(element).parents('#AppBottomMenu').parent().children('.ui-dialog');
if (jQuery(element)[0].id === 'AppBottomMenu') elementsWindow = jQuery(element);
else elementsWindow = jQuery(element).parents('#AppBottomMenu');
temp = elementsWindow.parent().children('.ui-dialog');
if (temp.length === 0) elementsWindow = elementsWindow.parent().children('.AppContainer').children('.containedapp');
else elementsWindow = temp;
}
}
}
return (elementsWindow.length === 0) ? null : elementsWindow;
},
GetOuterWindowOf: function(element, getOutermost) {
if (typeof(element) === 'undefined') {
/* jshint debug: true */debugger;
throw new Error(__METHOD__ + ' reports that the element is undefined on line ' + __LINE__);
}
if (window.Framework.prop.developer) console.log('' + __METHOD__);
if (getOutermost !== true) getOutermost = false;
var elementsWindow = '';
if (jQuery(element).hasClass('ui-dialog-titlebar-close')) {
var container = WindowLib.GetContainerOf(element);
elementsWindow = container.children('.ui-dialog-content');
} else{
if (jQuery(element).hasClass('ui-dialog-content')) {
elementsWindow = jQuery(element);
} else {
if (AppStaticLib.IsAnApp(element)) {
elementsWindow = jQuery(element.prop.handle);
} else {
elementsWindow = jQuery(element).parents('.containedapp');
if (elementsWindow.length === 0) elementsWindow = jQuery(element).parents('.ui-dialog-content');
if (getOutermost === true) {
var depth = 0;
var temp = jQuery(elementsWindow);
while ((temp.length !== 0) && (depth < 15)) {
depth++;
temp = jQuery(elementsWindow).parents('.containedapp');
if (temp.length !== 0) elementsWindow = temp;
}
elementsWindow = elementsWindow.parents('.ui-dialog-content');
}
}
}
}
//Check that JQuery found atleast one object
if (elementsWindow.length === 0) {
if (window.Framework.prop.developer) {
console.log('---WARNING: COULDN\'T FIND CONTEXT, RETURNING DOCUMENT--- for ' + element[0].id);
}
return jQuery('html');
}
return elementsWindow;
},
GetCollectionOf: function(element) {
if (element.App) {
if (AppStaticLib.IsAnApp(element.App)) element = element.App;
}
//For the item we are sent, find the object that contains it with a dialog window class...
var elementsWindow = AppStaticLib.GetWindowOf(element);
//Check that JQuery found atleast one object
if (elementsWindow === null) {
return null;
}
if ((elementsWindow.length === null) || (elementsWindow.length === 0)) return null;
//from that dialog's ID, then use that to look up the list of stored instances for that window
return window.Framework.prop.WindowCollection.items[elementsWindow.attr('id')];
},
SetupWhenReady: function(test, callThis, checkEvery) {
var obj = {
'test':test,
'callThis':callThis,
'checkEvery': checkEvery,
'CheckIsReady': function() {
if (this.test() === true) {
this.callThis();
} else {
setTimeout(jQuery.proxy(this.CheckIsReady, this), (this.checkEvery * 1000) );
}
}
};
obj.CheckIsReady();
}
};
}
/*AppStaticLib END */
var __EventRegister = [];
function HasEvent(target, name, func) {
var e = null;
for (var i = 0; i < __EventRegister.length; i++) {
e = __EventRegister[i];
if ((target.id === e.target.id) && (e.name === name) && (e.func === func)) return true;
}
return false;
}
function AddEvent(target, name, func, optionalArg, strict) {
var expected = __METHOD__ + ' expects a HTML object, name of event and the function to call';
if (typeof(target) !== 'object') throw new Error(expected);
if ((typeof(name) !== 'string') || (name.length === 0)) throw new Error(expected);
if (typeof(func) !== 'function') throw new Error(expected);
if (typeof(strict) !== 'boolean') strict = true;
var e = null;
for (var i = 0; i < __EventRegister.length; i++) {
e = __EventRegister[i];
if ((target.id === e.target.id) && (e.name === name) && (e.func === func)) {
if (strict === true) throw new Error(__METHOD__ + ' reports that the specified event [' + name + '] has already been registered for target [' + target.id + ']');
return;
}
}
if ((typeof(optionalArg) !== 'undefined') && (optionalArg !== null)) {
target.addEventListener(name, func, optionalArg);
} else {
target.addEventListener(name, func);
}
__EventRegister.push({target: target, name: name, func: func});
}
function RemoveEvent(target, name, func) {
var expected = __METHOD__ + ' expects a HTML object, name of event and the function to call';
if (typeof(target) !== 'object') throw new Error(expected);
if ((typeof(name) !== 'string') || (name.length === 0)) throw new Error(expected);
if (typeof(func) !== 'function') throw new Error(expected);
var e = null;
for (var i = 0; i < __EventRegister.length; i++) {
e = __EventRegister[i];
if (!((target.id === e.target.id) && (e.name === name) && (e.func === func))) continue;
target.removeEventListener(name, func);
__EventRegister.splice(i, 1);
return;
}
throw new Error(__METHOD__ + ' reports that the specified event [' + name + '] was not found for element [' + target.id + ']');
}
/* developer code start */
(function() {
Element.prototype._addEventListener = Element.prototype.addEventListener;
Element.prototype.addEventListener = function(a,b,c) {
if (c === undefined) c = false;
this._addEventListener(a, b, c);
if (!this.eventListenerList) this.eventListenerList = {};
if (!this.eventListenerList[a]) this.eventListenerList[a] = [];
//this.removeEventListener(a,b,c); // TODO - handle duplicates..
this.eventListenerList[a].push({listener:b,useCapture:c});
};
Element.prototype.getEventListeners = function(a){
if (!this.eventListenerList) this.eventListenerList = {};
if (a === undefined) return this.eventListenerList;
return this.eventListenerList[a];
};
Element.prototype.clearEventListeners = function(a){
if (!this.eventListenerList) this.eventListenerList = {};
if (a === undefined){
for(var x in (this.getEventListeners())) this.clearEventListeners(x);
return;
}
var el = this.getEventListeners(a);
if (el === undefined) return;
for(var i = el.length - 1; i >= 0; --i) {
var ev = el[i];
this.removeEventListener(a, ev.listener, ev.useCapture);
}
};
Element.prototype._removeEventListener = Element.prototype.removeEventListener;
Element.prototype.removeEventListener = function(a,b,c) {
if (c === undefined) c=false;
this._removeEventListener(a,b,c);
if (!this.eventListenerList) this.eventListenerList = {};
if (!this.eventListenerList[a]) this.eventListenerList[a] = [];
// Find the event in the list
for(var i=0;i.toString (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:188:10)"
5: " at window.AppBase.eval (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :751:54)"
6: " at window.AppBase.proxy [as OpenAppErrorWindow] (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13)"
7: " at window.AppBase.eval (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :732:10)"
8: " at App.proxy [as AddAppError] (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13)"
9: " at Object.processOne (https://bluesafe.mobylink.com/core/framework/js/WndPrcHandler.class.js:419:18)"
10: " at Object.process (https://bluesafe.mobylink.com/core/framework/js/WndPrcHandler.class.js:629:20)"
*/
// 1: 10: process -> 9: processOne -> 8: App.proxy(AddAppError) -> 7: window.AppBase.eval -> 6: window.AppBase.proxy(OpenAppErrorWindow)
// 8 = Caller Function = re = /\s+at\sApp\.proxy\s\[as\s(\w+)\].*/g;
// 7 = Line Number = re = /\s+at\swindow.AppBase\.eval\s.*:([0-9]+):[0-9]+$/g;
// 6 = Error Function = re = /\s+at\swindow.AppBase\.proxy\s\[as (\w+)\].*$/;
/*
0: "Error"
1: " at Object._GetFunctionDetails [as func] (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:86:10)"
2: " at Object.jQuery.proxy.func (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:229:15)"
3: " at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13)"
4: " at Object.window..toString (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:239:10)"
5: " at AddEvent (https://bluesafe.mobylink.com/core/framework/js/windowpopup.js:37:29)"
6: " at new window.WindowPopup (https://bluesafe.mobylink.com/core/framework/js/windowpopup.js:452:3)"
7: " at Object._CreateWindow (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :2696:16)"
8: " at GetApp.invoke (https://bluesafe.mobylink.com/core/framework/js/Action.class.js:364:17)"
9: " at App.Callback_GridSelect (eval at (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13)), :287:10)"
10: " at Object.eval (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :1400:19)"
*/
// 2: Grid RowA
/*
0: "Error"
1: " at Object._GetFunctionDetails [as func] (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:86:10)"
2: " at Object.jQuery.proxy.func (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:229:15)"
3: " at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13)"
4: " at Object.window..toString (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:239:10)"
5: " at AddEvent (https://bluesafe.mobylink.com/core/framework/js/windowpopup.js:37:29)"
6: " at new window.WindowPopup (https://bluesafe.mobylink.com/core/framework/js/windowpopup.js:259:2)"
7: " at Object._CreateWindow (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :2696:16)"
8: " at GetApp.invoke (https://bluesafe.mobylink.com/core/framework/js/Action.class.js:364:17)"
9: " at window.SuggestiveSearchControl.Restore (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :458:12)"
10: " at window.SuggestiveSearchControl.ctor (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :237:8)"
*/
// 3: SuggestiveSearch
/*
0: "Error"
1: " at Object._GetFunctionDetails [as func] (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:86:10)"
2: " at Object.jQuery.proxy.func (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:289:15)"
3: " at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13)"
4: " at Object.window..toString (https://bluesafe.mobylink.com/core/framework/js/StaticLib.class.js:299:10)"
5: " at window.GridControl.ProcessRowClick (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :7692:29)"
6: " at HTMLTableRowElement.eval (eval at proxy (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:10505:13), :7686:17)"
7: " at HTMLTableRowElement.dispatch (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:5240:27)"
8: " at HTMLTableRowElement.elemData.handle (https://bluesafe.mobylink.com/core/framework/js/thirdparty/jquery/jquery.v2.1.3.min.js:5047:28)"
*/
var re = null;
/*
var from = {
process: false,
processPos: -1,
processOne: false,
caller: false,
callerFn: '',
line: false,
lineNumber: -1,
proxy: false,
proxyFn: '',
APICall: {
},
HTML: {
location: false,
},
};
var x = e.length;
while (x--) {
if (x === e.length) continue;
if (typeof(e[x]) !== 'string') continue;
if (from.process === true) continue;
if (from.HTML.location === true) continue;
if (x === (e.length - 1)) {
if (e[x].includes('at HTMLTableRowElement') === true) {
from.HTML = true;
continue;
} if (e[x].includes('at Object.process ') === true) {
// API callback from server
from.process = true;
while (x--) {
if (from.processOne === false) {
if (e[x].includes('at Object.processOne') !== true) continue;
from.processOne = true;
continue;
}
if (from.caller === false) {
*/
//re = /\s+at\sApp\.proxy\s\[as\s(\w+)\].*/g;
/*
from.caller = true;
from.callerFn = e[x].replace(re, '$1');
continue;
}
debugger;
if (from.line === false) {
re = /\s+at\swindow.AppBase\.eval\s.*:([0-9]+):[0-9]+\)$/g;
from.line = true;
from.lineNumber = e[x].replace(re, '$1');
continue;
}
if (from.proxy === false) {
re = /\s+at\swindow.AppBase\.proxy\s\[as (\w+)\].*$/;
from.proxy = true;
from.proxyFn = e[x].replace(re, '$1');
continue;
}
debugger;
// breakout the loop
if ((from.processOne === true) && (from.caller === true) && (from.line === true) && (from.proxy === true)) x = e.length;
continue;
} // end while
} // end else if
continue;
}
}
*/
for (var i = 0; i < e.length; i++) {
if (isSafari === false) {
if (e[i].indexOf('at Object.window..toString (') === -1) continue;
e = e[(i + 1)];
found = true;
break;
} else if (isSafari === true) {
found = true;
break;
}
}
if (!found) e = e[2];
if (typeof(e) === 'undefined') return;
/* jshint -W049: true */
re = /^\s+at\s+(\w+\.\w+)\s.*\:([0-9]+):([0-9]+).*/g;
/* jshint +W049: false */
//var name = e.replace(re, '$1');
var temp = null;
if (isSafari !== true) {
//re = /(?<=\s*at \s*)(?:[\w\.])*/m;
temp = e.replace(re, '$1');
//name = temp.substring((temp.indexOf('.') + 1));
result.name = temp.substring((temp.indexOf('.') + 1));
result.line = e.replace(re, '$2');
result.pos = e.replace(re, '$3');
result.all = e.replace(re, 'Function: $1 on line $2 at pos $3');
result.className = temp.substring(0, temp.indexOf('.'));
result.method = result.className + '.' + result.name;
result.stack = e;
} else if (isSafari === true) {
re = /^(\w+)@https:\/\/.*:([0-9]+):([0-9]+)$/g;
result.name = e[1].replace(re, '$1');
result.line = e[1].replace(re, '$2');
result.pos = e[1].replace(re, '$3');
result.className = 'unknown';
result.method = 'Safari.' + result.name;
result.stack = e;
}
return result;
};
var _GetFunctionDetails = function(type) {
if (typeof(Error) === 'undefined') return 'Not available';
var expected = '_GetFunctionDetails reports required \'type\' was not specified. Valid types are [1: name, 2: line, 3: pos, 4: all, 5: class, 6: method, 7: stack]';
if (typeof(type) === 'undefined') throw new Error(expected);
if (typeof(type) === 'string') type = type.toLowerCase();
var e = new Error();
if (typeof(null) === 'undefined') return 'unknown';
var result = _ProcessStack(e);
switch (type) {
case 1:
case 'name': {
return result.name;
}
case 2:
case 'line': {
return result.line;
}
case 3:
case 'pos': {
return result.pos;
}
case 4:
case 'all': {
return result.all;
}
case 5:
case 'class': {
return result.className;
}
case 6:
case 'method': {
return result.method;
}
case 7:
case 'stack': {
return result.stack;
}
default: {
throw new Error(expected);
}
}
};
function macro(name, retFunc, funcArgs) {
if ((typeof(name) !== 'string') || (name.length === 0)) throw new Error('macro expects the first argument to be the name of the macro you want to create');
if ((typeof(retFunc) !== 'function') || (name.length === 0)) throw new Error('macro expects the second argument to be a function you want the return value to be');
if (typeof(window[name]) !== 'undefined') throw new Error('Macro already exists for ' + name);
if (typeof(funcArgs) === 'undefined') funcArgs = null;
var z = jQuery.proxy(function(){
return this.func(this.arg);
}, {func: retFunc, arg: funcArgs});
window[name] = {};
Object.defineProperty(window[name], 'name', {
get: function() {
return z();
}
});
window[name].toString = function() {
return z();
};
}
macro('__FUNCTION__', _GetFunctionDetails, 1);
macro('__LINE__', _GetFunctionDetails, 2);
macro('__POS__', _GetFunctionDetails, 3);
macro('__ALL__', _GetFunctionDetails, 4);
macro('__CLASS__', _GetFunctionDetails, 5);
macro('__METHOD__', _GetFunctionDetails, 6);
macro('__STACK__', _GetFunctionDetails, 7);
var StaticLib = {
GetRandom: function(min, max) {
return Math.random() * (max - min) + min;
},
CompareVersions: function(versionStr1, versionStr2) {
var errMsg = 'CompareVersions expects 2 string arguments, both of which are version-strings [0.0.0] for example';
if (typeof(versionStr1) !== 'string') throw new Error(errMsg);
if (typeof(versionStr2) !== 'string') throw new Error(errMsg);
versionStr1 = versionStr1.split('.');
versionStr2 = versionStr2.split('.');
if ((versionStr1.length !== 3) || (versionStr1.length !== 3)) throw new Error(errMsg);
if (parseInt(versionStr1[0]) === parseInt(versionStr2[0])) {
if (parseInt(versionStr1[1]) === parseInt(versionStr2[1])) {
if (parseInt(versionStr1[2]) === parseInt(versionStr2[2])) return 0;
if (parseInt(versionStr1[2]) < parseInt(versionStr2[2])) return -1;
return 1;
} else {
if (parseInt(versionStr1[1]) < parseInt(versionStr2[1])) return -1;
return 1;
}
} else {
if (parseInt(versionStr1[0]) < parseInt(versionStr2[0])) return -1;
return 1;
}
},
ClearSelection: function() {
if (document.getSelection) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(document.createRange());
} else if (window.getSelection) {
if (window.getSelection().removeAllRanges) {
window.getSelection().removeAllRanges();
window.getSelection().addRange(document.createRange());
} else if (window.getSelection().empty) {
window.getSelection().empty();
}
} else if (document.selection) {
document.selection.empty();
}
},
GetSubPropertyNames: function(data, isSubProperty) {
/**
* Get Sub Property name from object
* @function GetSubPropertyNames
* @memberof StaticLib
* @param {object} data data object
* @param {Boolean} isSubProperty
* @inner
*/
var keyValues = {};
var keys = null;
if (StaticLib.IsPropBaseInstance(data)) {
keys = data.GetPropList();
} else {
keys = Object.keys(data);
}
for (var count = 0; count < keys.length; count++) {
var val = keys[count];
if ((typeof(data[keys[count]]) === 'object') && (data[keys[count]] !== null)){
if (Array.isArray(data[keys[count]])) continue;
if (keys[count] === '__OriginalState') continue;
val = StaticLib.GetSubPropertyNames(data[keys[count]], true);
var keys2 = null;
keys2 = Object.keys(val);
for (var count2 = 0; count2 < keys2.length; count2++) {
val[(keys[count] + '.' + val[keys2[count2]])] = keys[count] + '.' + val[keys2[count2]];
keyValues[(keys[count] + '.' + val[keys2[count2]])] = keys[count] + '.' + val[keys2[count2]];
delete val[keys2[count2]];
}
}
if (typeof(data[keys[count]]) !== 'object') {
keyValues[keys[count]] = val;
}
}
//keyValues[''] = '{unbound}';
if (isSubProperty !== true) keyValues['{unbound}'] = '';
return keyValues;
},
QuickObjCompare: function(obj1, obj2) {
/**
* Compare two objects
* @function QuickObjCompare
* @memberof StaticLib
* @param {object} obj1
* @param {object} obj2
* @returns {Boolean}
* @inner
*/
return StaticLib.DeepObjCompare(obj1, obj2, false);
},
DeepObjCompare: function(obj1, obj2, doDeepComparison) {
/**
* Compare two objects in detail
* @function DeepObjCompare
* @memberof StaticLib
* @param {object} obj1
* @param {object} obj2
* @param {boolean} doDeepComparison
* @returns {Boolean}
* @inner
*/
var type = typeof(obj1);
if (type !== typeof(obj2)) return false;
//SHOULDN'T have passed me a non-object, but it's not hard for me to handle for you I guess...
if (type !== 'object') return (obj1 === obj2);
var keys = Object.keys(obj1);
for (var i = 0; i < keys.length; i++) {
//Compare VALUES not Object references!
if (typeof(obj1[keys[i]]) !== 'object') {
if (obj1[keys[i]] !== obj2[keys[i]]) return false;
} else if (doDeepComparison) {
if (StaticLib.DeepObjCompare(obj1, obj2, true) !== true) return false;
}
}
return true;
},
IsGUID: function(value) {
/**
* Check if string is a valid GUID
* @function IsGUID
* @memberof StaticLib
* @param {String} value
* @returns {Boolean}
* @inner
*/
if (typeof(value) !== 'string') return false;
if (value.length !== 36) return false;
var regex = /^([A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12})$/gm;
return (regex.exec(value) !== null);
},
Dev:{
setPrototypeOf: function(obj, newParent) {
if (typeof(Object.setPrototypeOf) === 'function') {
Object.setPrototypeOf(obj, newParent);
} else {
if (typeof(obj.__proto__) !== 'undefined') {
assertian();
obj.__proto__ = newParent;
} else if (typeof(obj.prototype) !== 'undefined') {
obj.prototype = newParent;
}
}
},
getPrototypeOf: function(obj) {
if (typeof(Object.getPrototypeOf) === 'function') {
return Object.getPrototypeOf(obj);
} else {
if (typeof(obj.__proto__) !== 'undefined') {
assertian();
return obj.__proto__;
} else if (typeof(obj.prototype) !== 'undefined') {
return obj.prototype;
}
}
}
},
UI: {
WhenClicked: function(event, doThis) {
var element = jQuery(event.target);
var context = {obj:element, func:doThis};
var _clickFunction = jQuery.proxy(StaticLib.UI._clickEvent, context);
var _unclickFunction = jQuery.proxy(function(event){
this.obj.isLoading = false;
this.obj.removeClass('disabled');
this.obj.find('i.progress-icon').remove();
this.obj.attr('disabled', false);
}, context);
context.undo = _unclickFunction;
_clickFunction();
},
Click: function(element, doThis) {
if (typeof(element) !== 'object') throw new Error('StaticLib.Click should not be called without an element argument');
element = jQuery(element);
var context = {obj:element, func: jQuery.proxy(doThis, element)};
var _clickFunction = jQuery.proxy(StaticLib.UI._clickEvent, context);
var _unclickFunction = jQuery.proxy(function(event){
this.obj.isLoading = false;
this.obj.removeClass('disabled');
this.obj.find('i.progress-icon').remove();
this.obj.attr('disabled', false);
}, context);
context.undo = _unclickFunction;
debugger;
element.unbind('click');
element.bind('click', _clickFunction);
},
_clickEvent: function(event){
if (this.obj.isLoading) return;
this.obj.isLoading = true;
this.obj.addClass('disabled');
this.obj.prepend('');
this.obj.attr('disabled', true);
window.setTimeout(this.undo, 3500);
this.func(event);
},
GetContextOfDialog: function(item) {
var handle = null;
var subject = jQuery(item);
if (subject.hasClass('.ui-dialog-normal')) {
handle = subject;
} else {
handle = subject.parents('.ui-dialog-normal');
}
if (handle.length === 0) return null;
//return window.Framework.prop.WindowCollection.items[handle.attr('id')].instance;
//For the item we are sent, find the object that contains it with a dialog window class...
//fetch that dialog's ID, then use that to look up the list of stored instances for that window
var obj = window.Framework.prop.WindowCollection.items[handle.attr('id')];
if ((typeof(obj) === 'undefined') || (obj === null)) return null;
return window.Framework.prop.WindowCollection.items[handle.attr('id')].instance;
},
SelectElementText: function(el) {
StaticLib.UI.RemoveTextSelections();
var range;
if (document.selection) {
range = document.body.createTextRange();
range.moveToElementText(el);
range.select();
} else if (window.getSelection) {
range = document.createRange();
range.selectNode(el);
window.getSelection().addRange(range);
}
},
// Deselects all text in the page.
RemoveTextSelections: function() {
if (document.selection) document.selection.empty();
else if (window.getSelection) window.getSelection().removeAllRanges();
},
isFullScreen: false,
ToggleFullscreen: function() {
/**
* Launch/Exit full screen
* @function ToggleFullscreen
* @memberof StaticLib
* @inner
*/
if (StaticLib.UI.isFullScreen) {
StaticLib.UI.ExitFullscreen();
} else {
StaticLib.UI.LaunchFullscreen();
}
},
LaunchFullscreen: function() {
/**
* Launch full screen
* @function LaunchFullscreen
* @memberof StaticLib
* @inner
*/
debugger;
var element = document.documentElement;
//if (document.fullscreenEnabled === true) {
if (typeof(element.webkitRequestFullscreen) === 'function') {
element.webkitRequestFullscreen();
} else if (typeof(element.requestFullscreen) === 'function') {
element.requestFullscreen();
} else if (typeof(element.mozRequestFullScreen) === 'function') {
element.mozRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (typeof(element.msRequestFullscreen) === 'function') {
element.msRequestFullscreen();
}
//}
},
ExitFullscreen: function() {
/**
* Exit full screen
* @function ExitFullscreen
* @memberof StaticLib
* @inner
*/
//if ((document.fullscreenElement !== null) && (document.fullscreenEnabled === true)) {
if (document.fullscreenElement !== null) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}
},
HasSameKeys: function(array1, array2) {
/**
* Compare two arrays if they have same keys
* @function HasSameKeys
* @memberof StaticLib
* @param {array} array1
* @param {array} array2
* @returns {Boolean}
* @inner
*/
var keys1 = Object.keys(array1);
var keys2 = Object.keys(array2);
keys1.sort();
keys2.sort();
var missing = [];
var extra = [];
var offset = 0;
for (var count = 0; count < keys1.length; count++) {
/*if (typeof(array2[keys1[count]]) === 'undefined') {
missing.push(keys1[count]);
continue;
}*/
var index = keys2.indexOf(keys1[count]);
if (index === -1) {
missing.push(keys1[count]);
offset++;
} else if (index !== (count - offset)) {
extra.push(keys1[count]);
offset--;
}
}
if ((missing.length === 0) && (extra.length === 0)) return true;
return {missing:missing, extra:extra};
},
MergeVals: function(array1, array2) {
/**
* Merge array values between two array
* @function MergeVals
* @memberof StaticLib
* @param {array1} array1
* @param {array2} array2
* @returns {array}
* @inner
*/
if (typeof Object.assign !== 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, 'assign', {
value: function assign(target, varArgs) { // .length of function is 2
if (target === null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource !== null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
return Object.assign(array1, array2);
},
EscapeHtml: function(rawStr) {
/**
* Escape HTML from string
* @function EscapeHtml
* @memberof StaticLib
* @param {string} rawStr
* @returns {string}
* @inner
*/
var type = typeof(rawStr);
if (type === 'function') return '';
if (type !== 'string') return rawStr;
return rawStr.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
return ''+i.charCodeAt(0)+';';
});
},
EscapeAttribute: function(rawStr) {
/**
* Escape double quotes and slashes from string
* @function EscapeAttribute
* @memberof StaticLib
* @param {string} rawStr
* @returns {string}
* @inner
*/
rawStr = StaticLib.EscapeHtml(rawStr);
if ((typeof(rawStr) !== 'string') || (rawStr === '')) return rawStr;
rawStr = rawStr.replace('"', '"');
rawStr = rawStr.replace('\'', ''');
return rawStr;
},
ImagifyHTMLorCSS: function(htmlOrCss) {
debugger;
return htmlOrCss;
},
StripJS: function(content, silent) {
/**
* Remove JS Code from content
* @function StripJS
* @memberof StaticLib
* @param {string} content
* @param {boolean}|{function} silent can be a bool true | false or msgbox function
* @returns {string}
* @inner
*/
if (typeof(content) !== 'string') throw new Error('.StripJS expects a single string argument. ("' + typeof(content) + '" received instead)');
var onEvents = new RegExp('[\\s]on[a-zA-z]+[\\s]*=[\\s]*[\\"\\\']', 'i');
var equalsPos = -1;
var seperator = '';
var errorCount = 0;
var index = content.search(onEvents);
while (index !== -1) {
errorCount++;
equalsPos = content.indexOf('=', index);
seperator = content.substr((equalsPos+1), 1);
content = StaticLib.StripBetween(content, index, (content.indexOf(seperator, (equalsPos + 2) ) + 1) );
index = content.search(onEvents);
}
var otherEvents = new RegExp('(animationend|animationiteration|animationstart|transitionend)[\\s]*=[\\s]*[\\"\\\']', 'i');
index = content.search(otherEvents);
while (index !== -1) {
errorCount++;
equalsPos = content.indexOf('=', index);
seperator = content.substr((equalsPos+1), 1);
content = StaticLib.StripBetween(content, index, (content.indexOf(seperator, (equalsPos + 2) ) + 1) );
index = content.search(otherEvents);
}
index = content.search('