var AjaxQueue_queue = []; var AjaxQueue_inQueue = false; var AjaxLogonError = function() { }; var AjaxRecoverError = function(msg, detail) { this.msg = msg; this.detail = detail; }; var AjaxNoRecoverError = function(msg, detail) { this.msg = msg; this.detail = detail; }; var AjaxHandleWCF = function(msg) { //alert(JSON.stringify(msg)); if (!msg._detail) { msg._detail = {ErrorCode:'Unknown', Message:msg._message +'\n\nStackTrace:\n'+msg._stackTrace}; } if (msg._detail.ErrorCode == 'AuthenticationLoggedOff') return new AjaxLogonError(); else return new AjaxRecoverError(msg._detail.ErrorCode + '\n\n' + msg._detail.Message, msg); }; var AjaxAbort = function() { var oldqueue = AjaxQueue_queue; AjaxQueue_queue = []; AjaxQueue_inQueue = false; var count = 0; for(var i in oldqueue) { if (count != 0) { var code = oldqueue[i]; code(); } count ++; } }; var AjaxRetry = function() { var oldqueue = AjaxQueue_queue; AjaxQueue_queue = []; AjaxQueue_inQueue = false; for(var i in oldqueue) { // setTimeout(function() { AjaxQueue(oldqueue[i]); // },100); } }; var AjaxQueue = function(code) { var failed = function(msg) { var e = AjaxHandleWCF(msg); if ((e instanceof AjaxRecoverError) || (e instanceof AjaxLogonError)) { if (!AjaxQueue_inQueue) { AjaxQueue_inQueue = true; AjaxQueue_queue.push(code); if (e instanceof AjaxLogonError) { // show logonwindow jAppML.utils.getGlobalControl('master').LoaderClose(); jAppML.utils.getGlobalControl('master').popup(new oculos.epd2.ErrorLogonPopup()); } else { // show error-retry window jAppML.utils.getGlobalControl('master').LoaderClose(); jAppML.utils.getGlobalControl('master').popup(new oculos.epd.ErrorServiceRetryPopup({msg:e.msg, detail:e.detail})); } } else { //alert('queued'); AjaxQueue_queue.push(code); } } else if (e instanceof AjaxNoRecoverError) { // show error window jAppML.utils.getGlobalControl('master').LoaderClose(); jAppML.utils.getGlobalControl('master').popup(new oculos.epd.ErrorServicePopup({msg:e.msg, detail:e.detail})); } }; try { code(failed); } catch (ex) { var msg = {exception:ex, _detail:{ErrorCode:'Javascript Error', Message:'' + ex.message + '\n\nFilename:\n' + ex.fileName + '\n\nLinenumber:\n' + ex.lineNumber + ' \n\nStack:\n' + ex.stack}}; jAppML.utils.getGlobalControl('master').LoaderClose(); failed(msg); } }; jAppML.controls.Browser = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlBrowser"; if (typeof(this.params.mode) == 'undefined') this.params.mode = "details"; if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); var me = this; this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); this._dataSource.registerEventHandler("DataChange", this, this.onDataChange); }, onDataChange: function() { var me = this; this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); }, prepareAttributes: function() { this._super(); }, onDomHeaderClick: function(param, elem) { var me = this; var oldSort = this.sort(); var newSort = []; var tempSort = this.params.columnSettings[param].sort; for(var i in tempSort) { newSort.push(tempSort[i]); } var isSameSort = me._dataSource.compareSortKeys(oldSort, newSort); if (isSameSort) { for(var i in newSort) { if (newSort[i].direction == 'asc') newSort[i].direction = 'desc'; else newSort[i].direction = 'asc'; } } this.params.data = null; this.sort(newSort); this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); }, onDomHeaderMouseOver: function(param, elem) { elem.className = 'hover'; }, onDomHeaderMouseOut: function(param, elem) { elem.className = ''; }, onDomCellMouseOver: function(param, elem) { elem.parentNode.className = 'hover'; }, onDomCellMouseOut: function(param, elem) { elem.parentNode.className = ''; }, onDomThumbMouseOver: function(param, elem) { elem.className = 'thumbdiv thumbdiv_hover'; }, onDomThumbMouseOut: function(param, elem) { elem.className = 'thumbdiv'; }, onDomCellClick: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { me.fireEvent('Click', data); }); //this.fireEvent('Click', this.data()[param]); }, onDomMouseDown: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { jAppML.utils.dragObject(data); }); //this.fireEvent('Click', this.data()[param]); }, onDomCellContext: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { me.fireEvent('ItemContext', {data:data, evt:evt, index:parseInt(param, 10)}); }); //jAppML.utils.context(evt, [{cssClass:'icon_rename', text:T('gui_rename')},{cssClass:'icon_delete', text:T('gui_delete')}]); return false; }, renderContents: function() { var out = []; var mode = this.mode(); var oldSort = this.sort(); if (mode == "details") { out.push(''); for(var i in this.params.columnSettings) { out.push(''); } out.push(''); } else if (mode == "thumbs") { } if (this.data()) { var data = this.data(); for(var y in data) { if (mode == "details") { out.push(''); for(var x in this.params.columnSettings) { out.push(''); } out.push(''); } else if (mode == "thumbs") { out.push('
'); if (data[y].HasUpdates) { out.push('
'); } out.push('
'); if (oldSort) { if (this._dataSource.compareSortKeys(this.params.columnSettings[i].sort, oldSort)) { out.push('
'); } } var headerKey = this.params.columnSettings[i].header; if (!headerKey) headerKey = this._dataSource.getHeaderForProperty(this.params.columnSettings[i].property); if (!headerKey) headerKey = this._dataSource.getHeaderForProperty(this.params.columnSettings[i].eval); out.push(T(headerKey)); out.push('
'); var expr = this.params.columnSettings[x].eval; if (!expr) expr = this.params.columnSettings[x].property; with(data[y]) { out.push(eval(expr)); } out.push('
'); var thumbField = this.params.thumbField; var thumbId = (data[y])[thumbField]; if (thumbId) { out.push(''); } else out.push('
' + (this.params.thumbMissingText ? this.params.thumbMissingText : '') + '
'); out.push('
'); var expr = this.params.textField; if (!expr) expr = "Id"; with(data[y]) { out.push(eval(expr)); } out.push('
'); out.push(''); } } } else { if (mode == "details") out.push('...loading'); else out.push('...loading'); } if (mode == "details") { out.push(''); } else if (mode == "thumbs") { if (data) { if (data.length > 0) { out.push(''); } } } return out.join(''); }, mode: function(value) { if (typeof(value) !== 'undefined') { if (this.params.mode != value) { this.params.mode = value; this.invalidate(true); this.fireEvent('ModeChanged'); } } else return this.params.mode; }, data: function(value) { if (typeof(value) !== 'undefined') { if (this.params.data != value) { this.params.data = value; this.invalidate(true); this.fireEvent('DataChanged'); } } else return this.params.data; }, sort: function(value) { if (typeof(value) !== 'undefined') { if (this.params.sort != value) { this.params.sort = value; this.invalidate(true); this.fireEvent('SortChanged'); } } else return this.params.sort; }, search: function(value) { if (typeof(value) !== 'undefined') { if (this.params.search != value) { this.params.search = value; this.invalidate(true); var me = this; this._dataSource.getAll(this.sort(), value, function(sort, search2, data) { me.sort(sort); me.data(data); }); //this.fireEvent('SearchChanged'); } } else return this.params.search; }, saveObject: function(obj, callback) { this._dataSource.saveObject(obj, callback); }, deleteObject: function(obj, callback) { this._dataSource.deleteObject(obj, callback); }, addSavedObject: function(obj, callback) { this._dataSource.addSavedObject(obj, callback); }, removeDeletedObject: function(obj, callback) { this._dataSource.removeDeletedObject(obj, callback); }, renameObject: function(obj, newName, callback) { this._dataSource.renameObject(obj, newName, callback); }, moveObject: function(obj, newpath, callback) { this._dataSource.moveObject(obj, newpath, callback); }, getObjectTemplate: function(callback) { this._dataSource.getObjectTemplate(callback); } });jAppML.controls.CheckBox = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'input'); this._checked = (''+ this.params.checked).toLowerCase() == "true"; this.attributes['type'] = 'checkbox'; this.fixedClass = "jmlInput jmlCheckBox"; this._hasFocus = false; }, prepareAttributes: function() { this._super(); this.attributes[''] = this._checked ? "checked" : ""; this.attributes['onclick'] = this.renderCallback('domOnClick', null); this.attributes['onblur'] = this.renderCallback('domOnBlur', null); this.attributes['onfocus'] = this.renderCallback('domOnFocus', null); this.attributes['onmouseover'] = this.renderCallback('domOnMouseOver', null); this.attributes['onmouseout'] = this.renderCallback('domOnMouseOut', null); this.attributes['onkeydown'] = this.renderCallback('domOnKeyDown', null); }, checked: function(value) { if (typeof(value) !== 'undefined') { var realvalue = false; if (('' + value).toLowerCase() == 'true') value = true; else value = false; if (this._checked != value) { this._checked = value; try{document.getElementById(this.domId).checked = value;}catch(ex){} this.invalidate(); this.fireEvent('CheckedChange'); this.fireEvent('ValueChange'); } } else { if (typeof(this._checked) === 'undefined') this._checked = false; return this._checked; } }, value: function(value) { return this.checked(value); }, clear: function() { this.value(false); }, focus: function(value) { document.getElementById(this.domId).focus(); }, domOnFocus: function(param, domElement) { $(domElement).removeClass('jmlCheckBox_hover'); $(domElement).addClass('jmlCheckBox_focus'); this._hasFocus = true; this.fireEvent('Focus'); }, domOnBlur: function(param, domElement) { $(domElement).removeClass('jmlCheckBox_hover'); $(domElement).removeClass('jmlCheckBox_focus'); this._hasFocus = false; this.fireEvent('Blur'); }, domOnKeyDown: function(param, elem, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; var me = this; if (keyCode == 9) { evt.cancelBubble = true; if (shiftKey) this.fireEvent('MoveLeft'); else this.fireEvent('MoveRight'); } else if (keyCode == 37 && !shiftKey) { evt.cancelBubble = true; this.fireEvent('MoveLeft'); } else if (keyCode == 39 && !shiftKey) { evt.cancelBubble = true; this.fireEvent('MoveRight'); } else if (keyCode == 40 && !shiftKey) { evt.cancelBubble = true; this.fireEvent('MoveDown'); } else if (keyCode == 38 && !shiftKey) { evt.cancelBubble = true; this.fireEvent('MoveUp'); } }, domOnMouseOver: function(param, domElement) { if (!this._hasFocus) $(domElement).addClass('jmlCheckBox_hover'); }, domOnMouseOut: function(param, domElement) { $(domElement).removeClass('jmlCheckBox_hover'); }, domOnClick: function(param, domElement) { this.value(domElement.checked); }, display: function(value) { return jAppML.controls.CheckBox.display(value); }, display2: function(value) { return jAppML.controls.CheckBox.display2(value); } }); jAppML.controls.CheckBox.display = function(value) { if (value == true || value == "True" || value == "true" || value == "TRUE") return "X"; else return " "; }; jAppML.controls.CheckBox.display2 = function(value) { if (value == true || value == "True" || value == "true" || value == "TRUE") return T("check_true"); else return T("check_false"); }; if (!window.T) { T = function(text) { return "Text not loaded error"; }; } else { window.TT = window.T; window.THash = []; window.T = function(text) { var r = window.TT(text); if (r.indexOf('?') == 0) { // r = r.replace('?', '', 'g'); // alert(r); if (!window.THash[r]) { window.THash[r] = r; } } return r; }; window.T.data = window.TT.data; window.TDebug = function() { var out = []; for (var i in window.THash) { out.push(window.THash[i]); } var div = document.createElement('div'); div.innerHTML = '
' + out.join('
') + '
'; document.body.appendChild(div); }; } Controller = {}; Controller.Open = function(text) { if (text == "UserList") { } }; var userColumnSettings = [ {property:"Name", header:"epdclassprop_fullname", eval:"LastName + ', ' + FirstName", sort:[{key:"LastName", direction:"asc"},{key:"FirstName", direction:"asc"}]}, {property:"Email", sort:[{key:"Email", direction:"asc"}]}, {property:"Phone", sort:[{key:"Phone", direction:"asc"}]}, {property:"Mobile", sort:[{key:"Mobile", direction:"asc"}]}, {property:"IsActive",sort:[{key:"IsActive", direction:"asc"}]} ]; var departmentColumnSettings = [ {property:"Name", sort:[{key:"Name", direction:"asc"}]}, {property:"Email", sort:[{key:"Email", direction:"asc"}]}, {property:"Phone", sort:[{key:"Phone", direction:"asc"}]}, {property:"Fax", sort:[{key:"Fax", direction:"asc"}]}, {property:"IsActive",sort:[{key:"IsActive", direction:"asc"}]} ]; var usergroupsColumnSettings = [ {property:"Name", sort:[{key:"Name", direction:"asc"}]}, {property:"Priority",sort:[{key:"Priority", direction:"asc"}]} ]; var subscribergroupsColumnSettings = [ {property:"Name", sort:[{key:"Name", direction:"asc"}]} ]; var departmentgroupsColumnSettings = [ {property:"Name", sort:[{key:"Name", direction:"asc"}]}, {property:"Priority",sort:[{key:"Priority", direction:"asc"}]} ]; var mmfileColumnSettings = [ {property:"Name", sort:[{key:"Name", direction:"asc"}]}, {property:"Mime", sort:[{key:"Mime", direction:"asc"}]}, {property:"Bytes", sort:[{key:"Bytes", direction:"asc"}]} ]; var documentsColumnSettings = [ {property:"Name", sort:[{key:"Name", direction:"asc"}]} ]; var exporttemplatesColumnSettings = [ {property:"Name", sort:[{key:"Name", direction:"asc"}]} ]; var defaultImageSearch = [ {key:'PathId', op:'=', param1:null}] var upload_params = function() { return {}; }; var upload_notify = function() { return {}; }; jAppML.utils.dragObject = function(value) { if (typeof(value) !== 'undefined') { jAppML.utils.dragObject.ob = value; } else return jAppML.utils.dragObject.ob; }; jAppML.utils.dragObject.ob = {}; function ConfirmClose() { // $.ajax({ // type: "POST", // url: "JS/LogOff.ashx", // success: function(msg){ // document.location = "/"; // }, // failure: function(){ // } // }); } var calculations = {}; calculations.data = []; calculations._lookupData = []; calculations.save = function(data2) { var data = '' + data2; var company = window.company; var foundpol = null; for(var i in company.DepartmentPolicies) { var pol = company.DepartmentPolicies[i]; if (pol.Id == 'ae9e100e-2aa3-4bce-9545-acc1d9316327') { foundpol = pol; } } if (!foundpol) { foundpol = {Id:'ae9e100e-2aa3-4bce-9545-acc1d9316327',ValueForSelf:{Value:data}}; company.DepartmentPolicies.push(foundpol); } else { if (!foundpol.ValueForSelf) { foundpol.ValueForSelf = {}; } foundpol.ValueForSelf.Value = data; } AjaxQueue(function(failed) { jAppML.utils.getGlobalControl('master').Loader(T('gui_saving_settings')); Oculos.Epd.Web.WcfService.DepartmentSave(window.impersonation, company, function(msg) { window.company = msg; jAppML.utils.getGlobalControl('master').refreshCompanyDetails(); // regenerate resolved policies AjaxQueue(function(failed) { Oculos.Epd.Web.WcfService.GetResolvedDepartmentPoliciesForMyCompany(window.impersonation, function(msg2) { // regenerate resolved policies var temp = []; for(var i in msg2) { var u = msg2[i]; temp[u.Id] = u; } window.resolvedDepartmentPolicies = temp; jAppML.utils.getGlobalControl('master').refreshUserDetails(); jAppML.utils.getGlobalControl('master').refreshCompanyDetails(); calculations.regenData(); }, function(msg) { failed(msg); }); }); jAppML.utils.getGlobalControl('master').LoaderClose(); }, function(msg) { failed(msg); }); }); }; calculations.regenData = function() { var data = resolvedDepartmentPolicies['ae9e100e-2aa3-4bce-9545-acc1d9316327'].Value; if (!data) data = ""; var rows = data.split('\n'); for(var i in rows) { rows[i] = rows[i].split('§'); } calculations.data = rows; calculations._lookupData = []; if (window.editorcontroller) window.editorcontroller.recalcAll(); }; calculations.findmatch = function(match, col) { if (calculations._lookupData[match]) { if (calculations._lookupData[match][col]) return calculations._lookupData[match][col]; if (calculations._lookupData[match][col] === '') return ''; } var found = ''; for(var y in calculations.data) { var row = calculations.data[y]; var cell = row[col]; if (!cell) cell = ''; var regexp = new RegExp(row[0], "gi"); if (regexp.test(match)) { if (cell) { if (cell != '') { found = cell; break; } } } } if (!calculations._lookupData[match]) { calculations._lookupData[match] = []; } calculations._lookupData[match][col] = found; return found; }; calculations.CalcDealerCarMargin = function(name, inprice, intax, yeartax, fmargin, vmargin, shipping, pricemod, round) { if (vmargin == '' || vmargin == null) vmargin = calculations.findmatch(name, 6); if (fmargin == '' || fmargin == null) fmargin = calculations.findmatch(name, 5); if (yeartax == '' || yeartax == null) yeartax = calculations.findmatch(name, 4); if (shipping == '' || shipping == null) shipping = calculations.findmatch(name, 1); if (pricemod == '' || pricemod == null) pricemod = calculations.findmatch(name, 2); if (round == '' || round == null) round = calculations.findmatch(name, 3); shipping = parseFloat(shipping); if (isNaN(shipping)) shipping = 0; yeartax = parseFloat(yeartax); if (isNaN(yeartax)) yeartax = 0; fmargin = parseFloat(fmargin); if (isNaN(fmargin)) fmargin = 0; vmargin = parseFloat(vmargin); if (isNaN(vmargin)) vmargin = 0; return calculations.Round(inprice * (fmargin + vmargin), "1"); }; calculations.CalcDealerCarTax = function(name, inprice, intax, yeartax, fmargin, vmargin, shipping, pricemod, round) { if (vmargin == '' || vmargin == null) vmargin = calculations.findmatch(name, 6); if (fmargin == '' || fmargin == null) fmargin = calculations.findmatch(name, 5); if (yeartax == '' || yeartax == null) yeartax = calculations.findmatch(name, 4); if (shipping == '' || shipping == null) shipping = calculations.findmatch(name, 1); if (pricemod == '' || pricemod == null) pricemod = calculations.findmatch(name, 2); if (round == '' || round == null) round = calculations.findmatch(name, 3); shipping = parseFloat(shipping); if (isNaN(shipping)) shipping = 0; yeartax = parseFloat(yeartax); if (isNaN(yeartax)) yeartax = 0; fmargin = parseFloat(fmargin); if (isNaN(fmargin)) fmargin = 0; vmargin = parseFloat(vmargin); if (isNaN(vmargin)) vmargin = 0; return calculations.Round(intax + yeartax, "1"); }; calculations.CalcDealerCarPrice = function(name, inprice, intax, yeartax, fmargin, vmargin, shipping, pricemod, round) { if (vmargin == '' || vmargin == null) vmargin = calculations.findmatch(name, 6); if (fmargin == '' || fmargin == null) fmargin = calculations.findmatch(name, 5); if (yeartax == '' || yeartax == null) yeartax = calculations.findmatch(name, 4); if (shipping == '' || shipping == null) shipping = calculations.findmatch(name, 1); if (pricemod == '' || pricemod == null) pricemod = calculations.findmatch(name, 2); if (round == '' || round == null) round = calculations.findmatch(name, 3); shipping = parseFloat(shipping); if (isNaN(shipping)) shipping = 0; yeartax = parseFloat(yeartax); if (isNaN(yeartax)) yeartax = 0; fmargin = parseFloat(fmargin); if (isNaN(fmargin)) fmargin = 0; vmargin = parseFloat(vmargin); if (isNaN(vmargin)) vmargin = 0; return calculations.Round(calculations.Pricemod(inprice,pricemod) + shipping + (calculations.Round(intax + yeartax, "1")),round) - calculations.Round(intax + yeartax, "1"); }; calculations.CalcDealerCarTotalPrice = function(name, inprice, intax, yeartax, fmargin, vmargin, shipping, pricemod, round) { if (vmargin == '' || vmargin == null) vmargin = calculations.findmatch(name, 6); if (fmargin == '' || fmargin == null) fmargin = calculations.findmatch(name, 5); if (yeartax == '' || yeartax == null) yeartax = calculations.findmatch(name, 4); if (shipping == '' || shipping == null) shipping = calculations.findmatch(name, 1); if (pricemod == '' || pricemod == null) pricemod = calculations.findmatch(name, 2); if (round == '' || round == null) round = calculations.findmatch(name, 3); shipping = parseFloat(shipping); if (isNaN(shipping)) shipping = 0; yeartax = parseFloat(yeartax); if (isNaN(yeartax)) yeartax = 0; fmargin = parseFloat(fmargin); if (isNaN(fmargin)) fmargin = 0; vmargin = parseFloat(vmargin); if (isNaN(vmargin)) vmargin = 0; return calculations.Round(calculations.Pricemod(inprice,pricemod) + shipping + (calculations.Round(intax + yeartax, "1")),round); }; calculations.CalcDealerEq = function(name, inprice, pricemod, round) { if (pricemod == '' || pricemod == null) pricemod = calculations.findmatch(name, 7); if (round == '' || round == null) round = calculations.findmatch(name, 8); return calculations.Round(calculations.Pricemod(inprice, pricemod), round); }; calculations.CalcDealerLocalEq = function(name, partsprice, hours, hourprice, round) { if (hours == '' || hours == null) hours = calculations.findmatch(name, 10); if (hourprice == '' || hourprice == null) hourprice = calculations.findmatch(name, 9); if (round == '' || round == null) round = calculations.findmatch(name, 11); hours = parseFloat(hours); if (isNaN(hours)) hours = 0; hourprice = parseFloat(hourprice); if (isNaN(hourprice)) hourprice = 0; return calculations.Round(partsprice + (hours * hourprice), round); }; calculations.Round = function(price,mod) { if (!mod || mod == '') return price; var roundMode = "c"; if (mod.substr(0,1) == "+") { mod = mod.substr(1, mod.length-1); roundMode = "u"; } else if (mod.substr(0,1) == "-") { mod = mod.substr(1, mod.length-1); roundMode = "d"; } else { roundMode = "c"; } mod = parseFloat(mod); if (isNaN(mod)) return price; var floor = Math.floor(price / mod) * mod; var ceil = (floor != price) ? floor + mod : floor; if (roundMode == "c") return Math.abs(floor - price) < Math.abs(ceil-price) ? floor : ceil; else if (roundMode == "u") return ceil; else if (roundMode == "d") return floor; }; calculations.Pricemod = function(price,mod) { if (!mod || mod == '') return price; try { if (mod.substr(mod.length -1, 1) == "%") { mod = mod.substr(0, mod.length-1); if (mod.substr(0,1) == "+") { mod = mod.substr(1, mod.length-1); return price*(1+(parseFloat(mod)/100)); } else if (mod.substr(0,1) == "-") { mod = mod.substr(1, mod.length-1); return price*(1-(parseFloat(mod)/100)); } else { return price*((parseFloat(mod)/100)); } } else { if (mod.substr(0,1) == "+") { mod = mod.substr(1, mod.length-1); return price+parseFloat(mod); } else if (mod.substr(0,1) == "-") { mod = mod.substr(1, mod.length-1); return price-parseFloat(mod); } else { return parseFloat(mod); } } } catch (e) { if (price) alert(e); return 0; } }; /** * jQuery.ScrollTo - Easy element scrolling using jQuery. * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com * Dual licensed under MIT and GPL. * Date: 9/11/2008 * @author Ariel Flesler * @version 1.4 * * http://flesler.blogspot.com/2007/10/jqueryscrollto.html */ ;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery); freezeTableHeader = function(container, e, widthadjust) { var timer = 0; var timer_id; var onstartcount = function() { timer = 10; if (freezeTableHeader.floatingDiv) { try {freezeTableHeader.floatingDiv.parentNode.removeChild(freezeTableHeader.floatingDiv);} catch (e) { } } }; var func = function() { var table = $(e); var domtable = table.get(0); if (!domtable) { $(container).unbind("scroll", onstartcount); $(container).unbind("resize", onstartcount); clearInterval(timer_id); return; } var win = $(container); var winheight = win.height(); var winwidth = win.width(); var winscrolltop = win.scrollTop(); var winscrollleft = win.scrollLeft(); var thead = $(domtable.tHead); var tableheight = table.height(); var tablewidth = table.width(); var headerheight = thead.height(); var headerwidth = thead.width(); //var tableoffset = table.offset(); var tableoffset ={top:0,left:0}; //var headeroffset = thead.offset(); var headeroffset ={top:0,left:0}; var hide = true; if (freezeTableHeader.floatingDiv) { try {freezeTableHeader.floatingDiv.parentNode.removeChild(freezeTableHeader.floatingDiv);} catch (e) { } } // check if table is visible if (tableoffset.top < (winscrolltop + winheight) && tableoffset.top > (winscrolltop - tableheight)) { if (headeroffset.top < (winscrolltop + winheight) && headeroffset.top > (winscrolltop - headerheight)) { hide = true; } else { var floatDiv = document.createElement("div"); floatDiv.style.padding = "none"; floatDiv.style.margin = "none"; freezeTableHeader.floatingDiv = floatDiv; container.appendChild(floatDiv); $(floatDiv).hide(); var newtable = document.createElement("table"); floatDiv.appendChild(newtable); floatDiv.style.position="absolute"; floatDiv.style.left = tableoffset.left + "px"; //floatDiv.style.left = "0px"; floatDiv.style.top = winscrolltop + "px"; $(newtable).attr("style", table.attr("style")); $(newtable).attr("class", table.attr("class")); newtable.cellSpacing = domtable.cellSpacing; newtable.cellPadding = domtable.cellPadding; //newtable.border = domtable.border; newtable.style.width = (tablewidth +widthadjust ) + "px"; // //var newThead = document.createElement("thead"); // //newtable.appendChild(newThead); // // $(newtable).append(jQuery(thead.html())); // // //newtable.innerHTML = thead.html(); // // var rows1 = thead.children("tr"); // var rows2 = $(newtable).children("tr"); // for(var r = 0; r < rows1.length; r++) { // // var row1 = $(rows1[r]); // var row2 = $(rows2[r]); // var cells1 = row1.children("th"); // var cells2 = row2.children("th"); // // for(var c = 0; c < cells1.length; c++) { // // var cell1 = cells1[c]; // var cell2 = cells2[c].get(0); // // cell2.style.width = cell1.width() + "px"; // cell2.style.height = cell1.height() + "px"; // // } // // // } var newthead = document.createElement("thead"); newtable.appendChild(newthead); for(var theadindex in domtable.tHead.rows) { var row = domtable.tHead.rows[theadindex]; var newrow = document.createElement("tr"); newrow.className = row.className; $(newrow).attr("style", $(row).attr("style")); newthead.appendChild(newrow); if (row.cells) { for (var c = 0; c < row.cells.length; c ++) { var cell = row.cells[c]; var newcell = cell.cloneNode(true); //newcell.innerHTML = cell.innerHTML; var jcell = $(cell); newcell.style.width = jcell.width() + "px"; newcell.style.height = jcell.height() + "px"; newrow.appendChild(newcell); } } //alert(JSON.stringify(thead)); } $(floatDiv).fadeIn(500); } //$("#floatingHeader table").append(thead.clone(true)); } }; $(container).bind("scroll", onstartcount); $(container).bind("resize", onstartcount); timer_id = setInterval(function() { timer--; if (timer < 0) timer = -1; if (timer == 0) { func(); } },50); }; freezeTableHeader.floatingDiv = null; ensureElementIsVisible = function(container, e) { var win = $(container); var winheight = win.height(); var winwidth = win.width(); var winscrolltop = win.scrollTop(); var winscrollleft = win.scrollLeft(); var elem = $(e); var winoffset = win.offset(); var offset = elem.offset(); offset.left -= winoffset.left; offset.left += winscrollleft; offset.top -= winoffset.top; offset.top += winscrolltop; //alert(JSON.stringify(winoffset)); //alert(JSON.stringify(offset)); var height = elem.height(); var width = elem.width(); var ymargin = 60; var xmargin = 30; var newy = winscrolltop; var newx = winscrollleft; if ((offset.top + ymargin + height) > winheight + winscrolltop) newy = (offset.top + height + ymargin) - winheight; if ((offset.top - ymargin) < winscrolltop) newy = offset.top - ymargin; if ((offset.left + xmargin + width) > winwidth + winscrollleft) { newx = (offset.left + width + xmargin) - winwidth; } if ((offset.left - xmargin) < winscrollleft) { newx = offset.left - xmargin; } if (newy < 0) newy = 0; if (newx < 0) newx = 0; if (newx != winscrollleft || newy != winscrolltop) { // setTimeout(function() { win.scrollTo({ top:newy, left:newx },100,{axis:'yx'}); // },10); } }; window.FixPricelistSubscriberMappings = function() { Oculos.Epd.Web.WcfService.FixPricelistSubscriberMappings(window.impersonation, function(result) { alert('ok'); }, function(result) { alert(JSON.stringify(result)); }); }; window.RepublishAllFix = function() { Oculos.Epd.Web.WcfService.RepublishAll(window.impersonation,function() { alert('ok'); }, function(result2) { alert(JSON.stringify(result2)); }); }; window.SubscriberGroupMakeAllPublic = function() { Oculos.Epd.Web.WcfService.SubscriberGroupMakeAllPublic(window.impersonation,function() { alert('ok'); }, function(result2) { alert(JSON.stringify(result2)); }); }; var Script = {}; Script.SetupWizard = {type:'page', ctrl:'oculos.epd2.WizardSetup'}; Script.TrialWarning = {type:'popup', ctrl:''}; Script.Welcome = {};//jAppML.controls.DataSource = jAppML.controls.Control.extend({ // init: function(params1, params2, parent) { // this._super(params1, params2, parent, 'div'); // this.fixedClass = ""; // // }, // data: function(value) { // if (typeof(value) !== 'undefined') { // if (this.params.data != value) { // this.params.data = value; // this.invalidate(true); // this.fireEvent('DataChanged'); // } // } // else return this.params.data; // } // //}); var dataSourceService = 'Oculos.Epd.Web.WcfService'; jAppML.controls.DataSource = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = ""; // find functions var s = this.source().split('.'); var className = s[s.length-1]; if (this.params.methodClass) className = this.params.methodClass; this._template = null; this._service = eval(dataSourceService); var me = this; this._searches = []; var getAllMethod = className + 'GetAll'; if (this.params.getAllMethod) getAllMethod = this.params.getAllMethod; if (this.params.getAllFunc) { this._getAll = function(onSuccess) { AjaxQueue(function(failed) { me.namingContainer[me.params.getAllFunc](window.impersonation, function(result) { me._searches[""] = []; me._searches[""].count = result.length; me._searches[""].sorted = []; me._searches[""].sorted[""] = result; onSuccess(); }, function(failure) { failed(failure); }); }); }; } else if (this._service[getAllMethod]) { this._getAll = function(onSuccess) { AjaxQueue(function(failed) { me._service[getAllMethod](window.impersonation, function(result) { me._searches[""] = []; me._searches[""].count = result.length; me._searches[""].sorted = []; me._searches[""].sorted[""] = result; onSuccess(); }, function(failure) { failed(failure); }); }); }; } else { //alert('Cant find service for:' + className); } if (this._service[className + 'Save']) { this._save = function(obj, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Save'](window.impersonation, obj, function(result) { onSuccess(result); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Delete']) { this._delete = function(id, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Delete'](window.impersonation, id, function(result) { onSuccess(); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Rename']) { this._rename = function(id, newName, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Rename'](window.impersonation, id, newName, function(result) { onSuccess(result); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Move']) { this._move = function(id, newid, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Move'](window.impersonation, id, newid, function(result) { onSuccess(result); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'GetTemplate']) { this._getTemplate = function(onSuccess) { AjaxQueue(function(failed) { me._service[className + 'GetTemplate'](window.impersonation, function(result) { me._template = result; onSuccess(); }, function(failure) { failed(failure); }); }); }; } }, getHeaderForProperty: function(prop) { var currentClass = this.source(); var parts = prop.split("."); while(parts.length > 1) { var currentClass = jAppML.user.getClass(currentClass)[parts[0]].type; parts.shift(); } return jAppML.user.getClass(currentClass)[parts[0]].name; }, getEditorForProperty: function(prop,params,container) { var currentClass = this.source(); var parts = prop.split("."); while(parts.length > 1) { var currentClass = jAppML.user.getClass(currentClass)[parts[0]].type; parts.shift(); } var dt = jAppML.user.getDataType(jAppML.user.getClass(currentClass)[parts[0]].datatype) var z = eval(dt.editor); return new z(dt.params,params,container); //return new jAppML.controls.TextBox(); }, generateSortKey: function(sort) { var result = []; if (!sort) return ""; for(var i in sort) { result.push(sort[i].key + ':' + sort[i].direction + ':'); } return result.join('\n'); }, compareSortKeys: function(sort1, sort2) { var key1 = this.generateSortKey(sort1); var key2 = this.generateSortKey(sort2); key1 = key1.replace(":desc:", ":asc:"); key2 = key2.replace(":desc:", ":asc:"); return key1 == key2; }, generateSearchKey: function(search) { var result = []; if (!search) return ""; // TODO: sort search so that key is equal when search equal but formattet in a different order for(var i in search) { result.push(search[i].key + ':' + search[i].op + ':' + search[i].param1 + '^^' + search[i].param2); } return result.join('\n'); }, loadSearch: function(sort, search, range, callback) { //alert('loadSearch'); var me = this; var sortKey = me.generateSortKey(sort); var searchKey = me.generateSearchKey(search); // just load from all for now if (!me._searches[""]) { me._getAll(function() { me.loadSearch(sort, search, range, callback); }); return; } if (!me._searches[searchKey]) { var source = me._searches[""].sorted[""]; var dest = []; for(var i in source) { // check search var match = true; if (search) { for(var s in search) { var checkValue = ''; var checkExpr = search[s].key; with(source[i]) { checkValue = eval(checkExpr); } //var checkValue = source[i][search[s].key]; if (search[s].op == "=") { if (checkValue != search[s].param1) { match = false; break; } } if (search[s].op == "notnull") { if (!checkValue) { match = false; break; } } if (search[s].op == "isnull") { if (checkValue) { match = false; break; } } if (search[s].op == "containsAll") { // if (!search[s].param1regex) { // //alert(search[s].param1.split(/\W+/gi).join('|')); var regexparts = search[s].param1.split(/[^\S\|]+/gi); if (regexparts) { for(var rp in regexparts) { if (regexparts[rp]) { var regexp = new RegExp(regexparts[rp], "gi"); if (!regexp.test(checkValue)) { match = false; break; } } } } } } } if (match) dest.push(source[i]); } me._searches[searchKey] = {}; me._searches[searchKey].sorted = []; me._searches[searchKey].sorted[""] = dest; me._searches[searchKey].count = dest.length; } callback(); }, loadSort: function(sort, search, range, callback) { //alert('loadSort'); var me = this; var sortKey = me.generateSortKey(sort); var searchKey = me.generateSearchKey(search); // just copy for now var source = me._searches[searchKey].sorted[""]; var dest = []; for(var i in source) { dest.push(source[i]); } // sort dest.sort(function(objA,objB) { var result = 0; for(var i in sort) { var valA = ''; with(objA) { valA = eval(sort[i].key); } var valB = ''; with(objB) { valB = eval(sort[i].key); } if (!valA) valA = ''; if (!valB) valB = ''; var s = ""; if (typeof(valA) == 'string') valA = valA.toUpperCase(); if (typeof(valB) == 'string') valB = valB.toUpperCase(); if (valA == valB) result = 0; else if (valA > valB) result = 1; else if (valB > valA) result = -1; if (sort[i].direction == 'desc') result = result * (-1); if (result != 0) { break; } } return result; }); me._searches[searchKey].sorted[sortKey] = dest; callback(); }, getObjectTemplate: function(callback) { var me = this; if (!me._template) { me._getTemplate(function() { me.getObjectTemplate(callback); }); return; } callback(jAppML.utils.cloneObject(me._template)); }, saveObject: function(obj, callback) { var me = this; var isNew = true; if (obj.Id) isNew = false; me._save(obj, function(newob) { if (isNew) me.addSavedObject(newob, callback); else me.updateUpdatedObject(newob, callback); // me.addSavedObject(obj, callback); // me._searches = []; // if (callback) callback(); // me.fireEvent('DataChange'); }); }, deleteObject: function(obj, callback) { var me = this; me._delete(obj.Id, function() { me.removeDeletedObject(obj, callback); // me._searches = []; // if (callback) callback(); // me.fireEvent('DataChange'); }); }, renameObject: function(obj, newName, callback) { var me = this; me._rename(obj.Id, newName, function(newob) { me.updateUpdatedObject(newob, callback); // me._searches = []; // if (callback) callback(); // me.fireEvent('DataChange'); }); }, moveObject: function(obj, newpath, callback) { var me = this; if (newpath == "") newpath = null; me._move(obj.Id, newpath, function(newob) { me.updateUpdatedObject(newob, callback); // me._searches = []; // if (callback) callback(); // me.fireEvent('DataChange'); }); }, addSavedObject: function(obj, callback) { var me = this; var oldsearches = me._searches[""]; var oldsorted = me._searches[""].sorted[""]; me._searches = []; me._searches[""] = oldsearches; oldsearches.count ++; oldsearches.sorted = []; oldsearches.sorted[""] = oldsorted; oldsearches.sorted[""].push(obj); if (callback) callback(); me.fireEvent('DataChange'); }, removeDeletedObject: function(obj, callback) { var me = this; var oldsearches = me._searches[""]; var oldsorted = me._searches[""].sorted[""]; me._searches = []; me._searches[""] = oldsearches; oldsearches.sorted = []; oldsearches.sorted[""] = []; for (var i in oldsorted) { if (obj.Id != oldsorted[i].Id) oldsearches.sorted[""].push(oldsorted[i]); } oldsearches.count = oldsearches.sorted[""].length; if (callback) callback(); me.fireEvent('DataChange'); }, updateUpdatedObject: function(obj, callback) { var me = this; var oldsearches = me._searches[""]; var oldsorted = me._searches[""].sorted[""]; me._searches = []; me._searches[""] = oldsearches; oldsearches.sorted = []; oldsearches.sorted[""] = []; for (var i in oldsorted) { if (obj.Id != oldsorted[i].Id) oldsearches.sorted[""].push(oldsorted[i]); else oldsearches.sorted[""].push(obj); } oldsearches.count = oldsearches.sorted[""].length; if (callback) callback(); me.fireEvent('DataChange'); }, getAll: function(sort,search,callback) { var me = this; me.getCount(search, function(search2, count) { me.getRange(sort, search2, [0,count-1], callback); }); }, getByIndex: function(sort, search, index, callback) { var me = this; me.getRange(sort, search, [index,index], function(sort, search2, data) { callback(sort,search2, data[0]); }); }, getById: function(id, callback) { var me = this; me.getAll(null, null, function(a,b,data) { for (var i in data) { if (data[i].Id == id) callback(data[i]); } }); }, getRange: function(sort, search, range, callback) { //alert('getRange'); var me = this; var sortKey = me.generateSortKey(sort); var searchKey = me.generateSearchKey(search); if (!me._searches[searchKey]) { me.loadSearch(sort, search, range, function() { me.getRange(sort, search, range, callback); }); return; } if (!me._searches[searchKey].sorted[sortKey]) { me.loadSort(sort, search, range, function() { me.getRange(sort, search, range, callback); }); return; } var source = me._searches[searchKey].sorted[sortKey]; var dest = []; for(var i = range[0]; i<= range[1]; i++) { dest.push(source[i]); } callback(sort, search, dest); }, getCount: function(search, callback) { var me = this; var searchKey = me.generateSearchKey(search); if (!me._searches[searchKey]) { me.loadSearch(null, search, null, function() { me.getCount(search, callback); }); return; } callback(search, me._searches[searchKey].count); }, refresh: function(sort, search) { var me = this; me._searches = []; me.fireEvent('DataChange'); }, source: function(value) { if (typeof(value) !== 'undefined') { if (this.params.source != value) { this.params.source = value; this.invalidate(true); this.fireEvent('SourceChanged'); } } else return this.params.source; } });jAppML.controls.DropDown = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlInput jmlDropDown jmlComboBox"; if (!this.params.selectedIndex) this.params.selectedIndex = 0; else this.params.selectedIndex = parseInt(this.params.selectedIndex); this._hasResolvedSelectedIndex = false; this._opened = false; this._realValue = null; this._realHasFocus = false; this._focusCounter = 10; this._focusIsCounting = false; this._preventBlur = false; var me = this; setInterval(function() { if (me._focusIsCounting) { me._focusCounter--; if (me._focusCounter <= 0) { me._realHasFocus = false; me._focusIsCounting = false; me.onRealBlur(); } } }, 30); if (this.params.possibleValues) { this.children = this.params.possibleValues; } if (this.params.dataSource) { if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); this._dataSource.getAll(null, null, function(sort, search, data) { me.children = []; me.children.push({text:" - ",value:null}); for(var i in data) { if (me.params.skipTranslation) { me.children.push({text:data[i].Name,value:data[i].Id}); } else me.children.push({text:T(data[i].Name),value:data[i].Id}); } //if (me.params.addBlank) { //} me.value(data[0].Id); me.invalidate(true); me.fireEvent('Redraw'); }); } //this._dataSource.registerEventHandler("DataChange", this, this.onDataChange); }, // onDataChange: function() { // var me = this; // // // this._dataSource.getAll(null,null, function(sort, search, data) { // me.data(data); // }); // }, prepareAttributes: function() { this._super(); this.attributes["onmouseover"] = this.renderCallback('domOnMouseOver'); this.attributes["onmouseout"] = this.renderCallback('domOnMouseOut'); //this.attributes['onchange'] = this.renderCallback('domOnChange', null); }, addControl: function(ctrl) { if (ctrl instanceof jAppML.controls.ListItem) this.children.push(ctrl.params); }, domOnMouseOver: function(param, domElement) { if (!this._hasFocus) $(domElement).addClass('jmlComboBox_hover'); }, domOnMouseOut: function(param, domElement) { $(domElement).removeClass('jmlComboBox_hover'); }, domOnFocus: function(param, domElement) { if (!this._realHasFocus) { this._realHasFocus = true; this.onRealFocus(); } this._focusCounter = 10; this._focusIsCounting = false; }, allowBlur: function() { this._preventBlur = false; this.refreshFocus(); }, preventBlur: function() { this._preventBlur = true; }, domOnBlur: function(param, domElement) { if(this._realHasFocus && !this._preventBlur) { this._focusIsCounting = true; } }, onRealFocus: function() { $('#' + this.domId).addClass('jmlComboBox_focus'); this.fireEvent("Focus"); }, onRealBlur: function() { $('#' + this.domId).removeClass('jmlComboBox_focus'); if (this._opened) this.close(); this.fireEvent("Blur"); }, onClickerClick: function() { if (!this._opened) this.open(); else this.close(); }, open: function() { document.getElementById(this.domId + "_dd").style.visibility='visible'; this._opened = true; this.invalidate(true); this.refreshFocus(); }, close: function() { document.getElementById(this.domId + "_dd").style.visibility='hidden'; this._opened = false; }, focus: function() { this.refreshFocus(); }, select: function() { document.getElementById(this.domId + '_input').select(); }, refreshFocus: function() { document.getElementById(this.domId + '_input').focus(true); this._realHasFocus = true; this._focusIsCounting = false; $('#' + this.domId).addClass('jmlComboBox_focus'); }, onClickItem: function(index) { this.close(); this.value(this.children[index].value); //this.refreshFocus(); var me = this; setTimeout(function() { me._preventBlur = false; me.refreshFocus(); }, 20); }, resolveRealValue: function() { if (!this._realValue) { this._realValue = {}; for(var i in this.children) { if (this.children[i].value == this.params.value) { this._realValue = this.children[i]; break; } } } }, renderContents: function() { this._opened = false; var out = []; out.push('
'); out.push(''); out.push(''); out.push(''); out.push(''); out.push(''); out.push('
'); out.push(''); out.push(''); out.push(''); out.push('
'); out.push('
'); //out.push(this.value()); out.push(''); } out.push(''); return out.join(''); }, value: function(value) { if (typeof(value) !== 'undefined') { if (this.params.value != value) { this.params.value = value; this._realValue = null; this.resolveRealValue(); var el = document.getElementById(this.domId + '_input'); if (el) el.value = this._realValue.text; //else alert(value + " " + JSON.stringify(this._realValue)); //alert(document.getElementById(this.domId + '_input').value); // = value; this.fireEvent("ValueChange"); this.invalidate(false); } } else return this.params.value; }, display: function(value) { var out = " "; for(var i in this.children) { if (this.children[i].value == value) { out = this.children[i].text; break; } } return out; }, selectedIndex: function(value) { // if (typeof(value) !== 'undefined' && !this._hasResolvedSelectedIndex) { // for(var i = 0; i < this.children.length; i++) { // var item = this.children[i]; // if ((item.value == this.params.selectedValue && this.params.selectedValue) || (item.text == this.params.selectedText && this.params.selectedText) || item.selected) {this.params.selectedIndex = i;break;} // } // this._hasResolvedSelectedIndex = true; // } // if (typeof(value) !== 'undefined') { // if (this.params.selectedIndex != value) { // this.params.selectedIndex = value; // try{document.getElementById(this.domId).selectedIndex = value; this.params.selectedIndex = i; this._hasResolvedSelectedIndex = true;}catch(ex){} // this.invalidate(); // this.fireEvent('Change'); // } // } // else return this.params.selectedIndex; }, selectedValue: function(value) { // if (typeof(value) !== 'undefined') { // for(var i = 0; i < this.children.length; i++) { // if (this.children[i].value == value) {this.selectedIndex(i);return;} // } // } // else return this.children[this.selectedIndex()].value; }, selectedText: function(value) { // if (typeof(value) !== 'undefined') { // for(var i = 0; i < this.children.length; i++) { // if (this.children[i].text == value) {this.selectedIndex(i);return;} // } // } // else return this.children[this.selectedIndex()].text; }, domOnChange: function(param, domElement) { // if (this.params.selectedIndex != domElement.selectedIndex) { // this.params.selectedIndex = domElement.selectedIndex; // this.invalidate(); // this.fireEvent('SelectedIndexChanged'); // } }, domOnKeyUp: function(param, domElement, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; this.fireEvent('KeyUp', {keyCode:keyCode, shiftKey:shiftKey}); }, domOnKeyDown: function(param, elem, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; var me = this; if (keyCode == 9) { evt.cancelBubble = true; if (shiftKey) this.fireEvent('MoveLeft'); else this.fireEvent('MoveRight'); } else if ((keyCode == 37 || keyCode == 39) && !shiftKey) { var sel = false; if (document.selection) { if (document.selection.createRange().duplicate().text != '') sel = true; } else { if (elem.selectionStart != elem.selectionEnd) sel = true; } if (sel) { if (elem.selectionEnd) { var newpos = 0; if (keyCode == 37) newpos = elem.selectionStart+1; if (keyCode == 39) newpos = elem.selectionEnd-1; if (newpos < 0) newpos = 0; if (newpos > elem.value.length) newpos = elem.value.length; setCaretPosition(elem,newpos); } return; } var pos = doGetCaretPosition(elem); if (keyCode == 37 && pos == 0) { var evt2 = {keyCode:9,shiftKey:true}; this.domOnKeyDown(param, elem, evt2); return; } else if (keyCode == 39 && pos == elem.value.length) { var evt2 = {keyCode:9,shiftKey:false}; this.domOnKeyDown(param, elem, evt2); return; } } else if (keyCode == 40 && !shiftKey) { this.fireEvent('MoveDown'); } else if (keyCode == 38 && !shiftKey) { this.fireEvent('MoveUp'); } } }); jAppML.controls.Editor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = ""; if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); }, data: function(value) { if (typeof(value) !== 'undefined') { if (this.params.data != value) { this.params.data = value; this.invalidate(true); this.fireEvent('DataChanged'); } } else return this.params.data; }, save: function(callback) { this._dataSource.saveObject(this.data(), callback); }, del: function(callback) { this._dataSource.deleteObject(this.data(), callback); }, getEditorForProperty: function(prop, params, container) { return this._dataSource.getEditorForProperty(prop,params, container); } });jAppML.HandleErrorOverride2 = function(err) { alert(JSON.stringify(err)); };jAppML.controls.IdFilteredDataSource = jAppML.controls.DataSource.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); var me = this; this._getAll = function(onSuccess) { me._dataSource.getAll(null, null, function(sort,search,data) { var result = []; var filter = me.filter(); for(var i in data) { var found = false; for(var ii in filter) { if (data[i].Id == filter[ii].Id) { result.push(data[i]); } } } me._searches[""] = []; me._searches[""].count = result.length; me._searches[""].sorted = []; me._searches[""].sorted[""] = result; onSuccess(); }); }; }, filter: function(value) { if (typeof(value) !== 'undefined') { if (this._filter != value) { this._filter = value; this.refresh(); } } else { if (typeof(this._filter) === 'undefined') this._filter = []; return this._filter; } } });jAppML.controls.ImageBox = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlImageBoxDiv"; this.registerEventHandler("PopupClose", this, this.onPopupClose); this._loadedThumb = false; this._thumb = null; this._loadedImage = false; this._image = null; }, onPopupClose: function(param) { this._popupIsOpened = false; this.focus(); if (param) this.value(param); }, prepareAttributes: function() { if (!this.params.height) this.params.height = '100px'; if (!this.params.width) this.params.width = '100px'; var style = ""; if (this.params.height) style += "height:" + this.params.height + ";max-height:" + this.params.height + ";min-height:" + this.params.height + ";"; if (this.params.width) style += "width:" + this.params.width + ";max-width:" + this.params.width + ";min-width:" + this.params.width + ";"; this.params.style = style; this._super(); this.attributes["onmouseover"] = this.renderCallback('domOnMouseOver'); this.attributes["onmouseout"] = this.renderCallback('domOnMouseOut'); }, domOnMouseOver: function(param, domElement) { if (!this.params.hideButtons) { $(domElement).addClass('jmlImageBox_hover'); } }, domOnMouseOut: function(param, domElement) { if (!this.params.hideButtons) $(domElement).removeClass('jmlImageBox_hover'); }, onEditClick: function() { this._popupIsOpened = true; this.popup(new oculos.epd.ImageEditorPopup({ image: this.value() })); this.domOnFocus(); }, onDeleteClick: function() { this.value(null); }, renderContents: function() { var out = []; var me = this; if (!this.params.height) this.params.height = '100px'; if (!this.params.width) this.params.width = '100px'; var style = "text-align:center;vertical-align:middle;"; if (this.params.height) style += "height:" + this.params.height + ";max-height:" + this.params.height + ";min-height:" + this.params.height + ";"; if (this.params.width) style += "width:" + this.params.width + ";max-width:" + this.params.width + ";min-width:" + this.params.width + ";"; var rememberStyle = style; out.push('
'); //
'); var value = this.value(); if (value) { style = ""; if (this.params.height) style = "height:" + this.params.height + ";"; if (this._loadedThumb) { if (this._thumb.width > this._thumb.height) style = "width:" + this.params.width + ";"; //alert(1); } if (this.params.height) style += "max-height:100%;"; // + this.params.height + ";"; if (this.params.width) style += "max-width:100%;"; // + this.params.width + ";"; //out.push('
'); if (this._loadedImage) out.push(''); else if (this._loadedThumb) out.push(''); else { out.push('
'); this._thumb = new Image(); this._thumb.onload = function() { me._loadedThumb = true; if (parseInt(me.params.width) > me._thumb.width && parseInt(me.params.height) > me._thumb.height) { me._image = new Image(); me._image.onload = function() { me._loadedImage = true; setTimeout(function() { me.invalidate(true); me.fireEvent('ImageLoaded'); }, 50); }; me._image.src = 'JS/GetFile.ashx?fileId=' + value; } setTimeout(function() { me.invalidate(true); me.fireEvent('ThumbLoaded'); }, 50); }; this._thumb.src = 'JS/GetThumb.ashx?fileId=' + value; } //out.push('
'); } else { out.push('
'); out.push(this.params.noImageText ? this.params.noImageText : T("gui_noimage")); out.push('
'); } out.push(' '); out.push('
'); if (!this.params.hideButtons) { out.push('
'); out.push(''); if (value) out.push(''); if (value) out.push(''); out.push('
'); } return out.join(''); }, onRendered: function() { if (this._hasFocus) this.focus(); }, domOnBlur: function(param, domElement) { if (this._popupIsOpened) return; var me = this; me._lostFocus = true; setTimeout(function() { if (me._lostFocus) { me._hasFocus = false; me.fireEvent('Blur'); } }, 100); }, domOnFocus: function(param, domElement) { var me = this; this._hasFocus = true; this._lostFocus = false; this.fireEvent('Focus'); }, focus: function() { $('#' + this.domId + ' a').focus(); }, value: function(value) { if (typeof (value) !== 'undefined') { if (this.params.value != value) { this.params.value = value; this._loadedThumb = false; this._loadedImage = false; this._thumb = null; this._image = null; this.invalidate(true); this.fireEvent('ValueChange'); } } else return this.params.value; }, display: function(value) { return jAppML.controls.ImageBox.display(value); } }); jAppML.controls.ImageBox.display = function(value, parent) { var ctrl = new jAppML.controls.ImageBox({value:value, hideButtons:true}); ctrl.setParent(parent); return ctrl.render(); };jAppML.utils.ensureNamespace("oculos.epd"); function doGetCaretPosition (ctrl) { var CaretPos = 0; // IE Support if (document.selection) { ctrl.focus (); var Sel = document.selection.createRange (); Sel.moveStart ('character', -ctrl.value.length); CaretPos = Sel.text.length; } // Firefox support else if (ctrl.selectionStart || ctrl.selectionStart == '0') CaretPos = ctrl.selectionStart; return (CaretPos); } function setCaretPosition(ctrl, pos) { if(ctrl.setSelectionRange) { ctrl.focus(); ctrl.setSelectionRange(pos,pos); } else if (ctrl.createTextRange) { var range = ctrl.createTextRange(); range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select(); } } oculos.epd.LocalizationStringsEditor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "localizationStringsEditor"; this._input = null; this._lastEditId = null; this._lastEditLocId = null; this._lastEditCatId = null; this._lastEditIsId = null; this.data = []; this.reload(); }, reload: function() { var me = this; $.ajax({ type: "GET", url: "JS/LocalizationStrings.ashx", data: {action:'list'}, success: function(msg){ try { me.data = eval("(" + msg + ")"); me.invalidate(true); me.fireEvent("DataChanged"); } catch(ex) { me.data = []; me.invalidate(true); me.fireEvent("DataChanged"); } }, failure: function() { me.data = []; me.invalidate(true); me.fireEvent("DataChanged"); } }); }, input: function() { if (this._input) return this._input; else this._input = $('#' + this.domId + ' input').get(0); return this._input; }, renderContents: function() { var out = []; this._input = null; if (this.data.localizationCodes) { out.push(''); out.push(''); var locCount = 0; for(var langCode in this.data.localizationCodes) { out.push(''); locCount ++; } out.push(''); for (var catId in this.data.resourceCategories) { out.push(''); var resourceStrings = this.data.resourceCategories[catId].resourceStrings; if (!resourceStrings[catId]) resourceStrings[catId] = {localization:[]}; for (var stringId in resourceStrings) { out.push(''); out.push(''); for(var langCode in this.data.localizationCodes) { out.push(''); } out.push(''); } } out.push('
Id'); out.push(this.data.localizationCodes[langCode]); out.push(' 
'); out.push(this.data.resourceCategories[catId].name); out.push('
'); if (this._lastEditId == stringId && this._lastEditCatId == catId && !this._lastEditLocId) { out.push(''); } else out.push(stringId != catId ? stringId : '*'); out.push(''); if (this._lastEditId == stringId && this._lastEditCatId == catId && this._lastEditLocId == langCode) { out.push(''); } else out.push(resourceStrings[stringId]["localization"][langCode] ? resourceStrings[stringId]["localization"][langCode] : ' '); out.push(''); if (stringId != catId) out.push('X'); else out.push(" "); out.push('
'); } else { out.push('
'); } return out.join(''); }, saveRow: function(param) { var me = this; var doRepaint = false; // save current cell in edit if (this._lastEditId) { if (this._lastEditIsId) { if(this._lastEditId == this._lastEditCatId) { var resourceString = this.data.resourceCategories[this._lastEditCatId].resourceStrings[this._lastEditId]; if (this.input().value != (this.data.resourceCategories[this._lastEditCatId].name.toLowerCase() + "_")) { resourceString._newid = this.input().value; this.input().parentNode.innerHTML = this.input().value ? this.input().value : ' '; this.invalidate(); } else { this.input().parentNode.innerHTML = "*"; } } else { var resourceString = this.data.resourceCategories[this._lastEditCatId].resourceStrings[this._lastEditId]; resourceString._newid = this.input().value; this.input().parentNode.innerHTML = this.input().value ? this.input().value : ' '; this.invalidate(); } } else { // save value var resourceString = this.data.resourceCategories[this._lastEditCatId].resourceStrings[this._lastEditId]; if (resourceString.localization[this._lastEditLocId] != this.input().value) { resourceString.localization[this._lastEditLocId] = this.input().value; resourceString._edited = true; this.input().parentNode.innerHTML = this.input().value ? this.input().value : ' '; this.invalidate(); } else { this.input().parentNode.innerHTML = this.input().value ? this.input().value : ' '; } } } // save last row to db if new row if (this._lastEditId) { if (this._lastEditId != param.id) { var resourceString = this.data.resourceCategories[this._lastEditCatId].resourceStrings[this._lastEditId]; // if modifying existing row if (this._lastEditId != this._lastEditCatId) { var oldId = this._lastEditId; var newId = resourceString._newid ? resourceString._newid : oldId; if (newId != oldId || resourceString._edited) { // try to save changes var data = {}; var result = {}; data.action = "update"; for(var key in resourceString.localization) { data[key] = resourceString.localization[key]; } data.id = oldId; data.catid = this._lastEditCatId; data.newid = newId; $.ajax({ type: "POST", async:false, url: "JS/LocalizationStrings.ashx", data: data, success: function(msg){ try { result = eval("(" + msg + ")"); } catch(ex) { alert('failed to update row\n\n' + ex); } }, failure: function() { alert('failed to update row'); } }); if (result.ok) { // if ok, fix id in array if (result.newid != oldId) { var oldArray = this.data.resourceCategories[this._lastEditCatId].resourceStrings; var newArray = []; for(var stringId in oldArray) { if (stringId != oldId && stringId != this._lastEditCatId) newArray[stringId] = oldArray[stringId]; else if (stringId == oldId) { resourceString._newid = result.newid; newArray[result.newid] = resourceString; this.data.resourceCategories[this._lastEditCatId].resourceStrings = newArray; } } doRepaint = true; } } else { me.reload(); return; } } resourceString._edited = false; } else { // try to create new row var contOk = false; for(var lid in resourceString.localization) { if (resourceString.localization[lid]) { if (resourceString.localization[lid] != "") contOk = true; } } if ((resourceString._edited && contOk) || (resourceString._newid && resourceString._newid != this.lastEditId)) { if (!resourceString._newid) resourceString._newid = this.data.resourceCategories[this._lastEditId].name.toLowerCase() + "_"; var data = {}; var result = {}; data.action = "store"; for(var key in resourceString.localization) { data[key] = resourceString.localization[key]; } data.id = resourceString._newid; data.catid = this._lastEditCatId; $.ajax({ type: "POST", async:false, url: "JS/LocalizationStrings.ashx", data: data, success: function(msg){ try { result = eval("(" + msg + ")"); } catch(ex) { alert('failed to store row\n\n' + ex); } }, failure: function() { alert('failed to store row'); } }); if (result.ok) { var oldArray = this.data.resourceCategories[this._lastEditCatId].resourceStrings; var newArray = []; for(var stringId in oldArray) { if (stringId != oldId && stringId != this._lastEditCatId) newArray[stringId] = oldArray[stringId]; } newArray[result.newid] = resourceString; resourceString._newid = result.newid; this.data.resourceCategories[this._lastEditCatId].resourceStrings = newArray; doRepaint = true; } else { me.reload(); return; } } resourceString._edited = false; } } } return doRepaint; }, domOnCellClick: function(param,elem) { var me = this; // ignore if already in edit if (this._lastEditId == param.id && this._lastEditLocId == param.locId) return false; var doRepaint = this.saveRow(param); //this._input = document.createElement('input'); this._lastEditId = param.id; this._lastEditLocId = param.locId; this._lastEditCatId = param.catId; this._lastEditIsId = true; if (param.locId) this._lastEditIsId = false; if (doRepaint) { this.invalidate(true); this.fireEvent('Repaint'); this.input().select(); return; } this._input = null; elem.innerHTML = ''; if (this._lastEditIsId) { if (this.data.resourceCategories[this._lastEditCatId].resourceStrings[this._lastEditId]._newid) this.input().value = this.data.resourceCategories[this._lastEditCatId].resourceStrings[this._lastEditId]._newid; else { if (param.id == param.catId) this.input().value = this.data.resourceCategories[param.catId].name.toLowerCase() + "_"; else this.input().value = param.id; } } else { this.input().value = this.data.resourceCategories[param.catId].resourceStrings[param.id].localization[param.locId]; if (this.input().value === 'undefined') this.input().value = ''; } //elem.innerHTML = ''; //elem.appendChild(this.input()); //$(this.input()).attr('onkeyup', this.renderCallback('domOnKeyUp', '')); this.input().select(); this.invalidate(); //alert(param.id + ' ' + param.locId); }, domOnCellMouseOver: function(param,elem) { elem.style.backgroundColor = "#ffe0e0"; }, domOnCellMouseOut: function(param,elem) { elem.style.backgroundColor = ""; }, domOnDeleteClick: function(param, elem) { this.saveRow({id:this._lastEditId, catId:this._lastEditCatId, locId:this._lastEditLocId}); $.ajax({ type: "POST", async:false, url: "JS/LocalizationStrings.ashx", data: {action:'delete',id:param.id}, success: function(msg){ try { result = eval("(" + msg + ")"); } catch(ex) { alert(ex); } }, failure: function() { } }); if (result.ok) { var oldArray = this.data.resourceCategories[param.catId].resourceStrings; var newArray = []; for(var stringId in oldArray) { if (stringId != param.id) newArray[stringId] = oldArray[stringId]; } this.data.resourceCategories[param.catId].resourceStrings = newArray; if (this._lastEditId == param.id) { this._lastEditId = null; this._lastEditCatId = null; this._lastEditLocId = null; } this.invalidate(); this.redraw(); } else { alert('failed to delete row'); me.reload(); return; } }, domOnKeyDown: function(param, elem, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shift = evt.shiftKey; var me = this; if (keyCode == 9) { evt.cancelBubble = true; var nextSibling; if (shift) nextSibling = elem.parentNode.previousSibling; else nextSibling = elem.parentNode.nextSibling; if (nextSibling) { nextSibling.onclick(); setTimeout(function() { me.input().focus(); me.input().select(); },50); } } else if ((keyCode == 37 || keyCode == 39) && !shift) { var sel = false; if (document.selection) { if (document.selection.createRange().duplicate().text != '') sel = true; } else { if (elem.selectionStart != elem.selectionEnd) sel = true; } if (sel) { if (elem.selectionEnd) { var newpos = 0; if (keyCode == 37) newpos = elem.selectionStart+1; if (keyCode == 39) newpos = elem.selectionEnd-1; if (newpos < 0) newpos = 0; if (newpos > elem.value.length) newpos = elem.value.length; setCaretPosition(elem,newpos); } return; } var pos = doGetCaretPosition(elem); if (keyCode == 37 && pos == 0) { var evt2 = {keyCode:9,shiftKey:true}; this.domOnKeyDown(param, elem, evt2); return; } else if (keyCode == 39 && pos == elem.value.length) { var evt2 = {keyCode:9,shiftKey:false}; this.domOnKeyDown(param, elem, evt2); return; } } else if (keyCode == 40 || keyCode == 38) { evt.cancelBubble = true; var extraUp = false; if (this._lastEditCatId == this._lastEditId) { if (this.saveRow(param)) { this.redraw(); this.input().select(); if (keyCode == 40) return; else extraUp = true; } else this.redraw(); } this._input = null; var cell = this.input().parentNode; var row = cell.parentNode; var table = row.parentNode; var cellindex = 0; for(var i in row.childNodes) { if (row.childNodes[i] == cell) cellindex = i; } var down = (keyCode == 40); var cont = true; var nextCell = null; nextRow = row; if (extraUp) nextRow = nextRow.previousSibling; while(cont) { nextRow = down ? nextRow.nextSibling : nextRow.previousSibling; if (nextRow) { if (nextRow.className.indexOf('data') >= 0) { if (nextRow.childNodes[cellindex]) { if (nextRow.childNodes[cellindex].className == cell.className) { cont = false; nextCell = nextRow.childNodes[cellindex]; } } } } else cont = false; } if (nextCell) { nextCell.onclick(); setTimeout(function() { me.input().focus(); me.input().select(); },50); } else{ setTimeout(function() { me.input().focus(); me.input().select(); },50); } } } });var objectEditorSetups = []; // JatoEquipment objectEditorSetups['e9de6089-c75b-4133-ab86-36da6b3dad98'] = [ {cssClass:'ed_jato_namecol', type:'composite', sortKey:'', headerKey:'784712c2-3744-4b18-ad45-92afeca4cee7', items:[{type:'prop', id:'784712c2-3744-4b18-ad45-92afeca4cee7'},{cssClass:'italics',type:'prop',id:'9c8b1da4-0d87-438e-b65f-d2dd1b0393f7'}]}, // Utstyrsbeskrivelse + Egenbeskrivelse, header=Utstyrsbeskrivelse {cssClass:'ed_jato_catcol', type:'composite', sortKey:'', headerKey:'9a81d7fd-2415-4c9e-ac47-517362b171d4', items:[{type:'prop', id:'9a81d7fd-2415-4c9e-ac47-517362b171d4', extclass:'f15c4ca1-5729-4b51-9b6b-b82a16cb8516', extprop:'f03b33c3-3f71-46a4-8461-d0cb8a117f79'}]}, // Category {cssClass:'ed_jato_typecol', type:'composite', sortKey:'', headerKey:'71f51b8a-0019-49a1-9ee3-6139176b4895', items:[{type:'prop', id:'71f51b8a-0019-49a1-9ee3-6139176b4895'}]}, // type {cssClass:'ed_jato_anbcol', type:'composite', sortKey:'', headerKey:'48d1db2b-e969-4afa-ad2f-11f0f6d5ad5d', items:[{type:'prop', id:'48d1db2b-e969-4afa-ad2f-11f0f6d5ad5d'}]}, // anbefalt {cssClass:'ed_jato_utcol', cssSubClass:'ed_jato_utcol_sub', type:'availgrouplink', sortKey:'', classId:'8b438735-0a31-44b6-9315-01fa28be59be', textExpr:'Properties[\'b98d692c-54b6-48d5-a559-0bf6ea86f575\']', linkProp:'4fba8f7d-d03f-4eb1-8757-09e37f0787a0'}, // trimlevel {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'4fba8f7d-d03f-4eb1-8757-09e37f0787a0', items:[{type:'prop', id:'4fba8f7d-d03f-4eb1-8757-09e37f0787a0'}]}, // pris {cssClass:'ed_jato_listcol', cssSubClass:'ed_jato_listcol_sub', type:'lists', headerText:T('gui_lists')} // lister ]; // DealerEquipment objectEditorSetups['25bf2a7a-ef7e-4956-99e9-506c9e411818'] = [ {cssClass:'ed_jato_catcol', cssClass:'ed_dealer_namecol', type:'composite', sortKey:'', headerKey:'acc1b3e9-7fc5-4ba6-8d6a-f283a41f9c0b', items:[{type:'prop', id:'acc1b3e9-7fc5-4ba6-8d6a-f283a41f9c0b'},{cssClass:'italics',type:'prop',id:'7817a5a5-cb18-48c5-9337-07e17b56793f'}]}, // Utstyrsbeskrivelse + Egenbeskrivelse, header=Utstyrsbeskrivelse {type:'composite', sortKey:'', headerKey:'9a81d7fd-2415-4c9e-ac47-517362b171d4', items:[{type:'prop', id:'9a81d7fd-2415-4c9e-ac47-517362b171d4', extclass:'f15c4ca1-5729-4b51-9b6b-b82a16cb8516', extprop:'f03b33c3-3f71-46a4-8461-d0cb8a117f79'}]}, // Category {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'aac776eb-922d-442a-86d2-4e82d80933df', items:[{type:'prop', id:'aac776eb-922d-442a-86d2-4e82d80933df'}]}, // innpris {cssClass:'ed_jato_utcol', cssSubClass:'ed_jato_utcol_sub', type:'availgrouplink', sortKey:'', classId:'8b438735-0a31-44b6-9315-01fa28be59be', textExpr:'Properties[\'b98d692c-54b6-48d5-a559-0bf6ea86f575\']', linkProp:'4fba8f7d-d03f-4eb1-8757-09e37f0787a0'}, // trimlevel {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'58654a35-d7bf-47d7-86ae-97da17574ede', items:[{type:'prop', id:'58654a35-d7bf-47d7-86ae-97da17574ede'}]}, // pricemod {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'d435b0e6-d853-4cc4-a8b8-6b156c77bcd7', items:[{type:'prop', id:'d435b0e6-d853-4cc4-a8b8-6b156c77bcd7'}]}, // priceround {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'7246f0e7-b845-43c4-86b6-67dbacec2004', items:[{type:'prop', id:'7246f0e7-b845-43c4-86b6-67dbacec2004'}]}, // utpris {cssClass:'ed_jato_listcol', cssSubClass:'ed_jato_listcol_sub', type:'lists', headerText:T('gui_lists')} // lister ]; // DealerLocalEquipment objectEditorSetups['df658419-c05b-4183-a4e2-49076e4956d8'] = [ {cssClass:'ed_jato_catcol', cssClass:'ed_dealer_namecol', type:'composite', sortKey:'', headerKey:'acc1b3e9-7fc5-4ba6-8d6a-f283a41f9c0b', items:[{type:'prop', id:'acc1b3e9-7fc5-4ba6-8d6a-f283a41f9c0b'},{cssClass:'italics',type:'prop',id:'7817a5a5-cb18-48c5-9337-07e17b56793f'}]}, // Utstyrsbeskrivelse + Egenbeskrivelse, header=Utstyrsbeskrivelse {type:'composite', sortKey:'', headerKey:'9a81d7fd-2415-4c9e-ac47-517362b171d4', items:[{type:'prop', id:'9a81d7fd-2415-4c9e-ac47-517362b171d4', extclass:'f15c4ca1-5729-4b51-9b6b-b82a16cb8516', extprop:'f03b33c3-3f71-46a4-8461-d0cb8a117f79'}]}, // Category {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'1a5ae1d3-e380-433e-b970-7fdd28d3f5d5', items:[{type:'prop', id:'1a5ae1d3-e380-433e-b970-7fdd28d3f5d5'}]}, // delepris {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'405a9b15-9ee2-446a-9b87-52dbea7e7a73', items:[{type:'prop', id:'405a9b15-9ee2-446a-9b87-52dbea7e7a73'}]}, // timer {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'389a89ba-df8e-4320-95f1-de31aa065ae3', items:[{type:'prop', id:'389a89ba-df8e-4320-95f1-de31aa065ae3'}]}, // timepris {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'d435b0e6-d853-4cc4-a8b8-6b156c77bcd7', items:[{type:'prop', id:'d435b0e6-d853-4cc4-a8b8-6b156c77bcd7'}]}, // priceround {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'7b687628-8579-4e1d-98ea-300bdbb74242', items:[{type:'prop', id:'7b687628-8579-4e1d-98ea-300bdbb74242'}]}, // utpris {cssClass:'ed_jato_listcol', cssSubClass:'ed_jato_listcol_sub', type:'lists', headerText:T('gui_lists')} // lister ]; // TrimLevel objectEditorSetups['8b438735-0a31-44b6-9315-01fa28be59be'] = [ {type:'composite', sortKey:'', headerKey:'a55ccc1f-8df3-4f3e-a91a-f33aa17e94e1', items:[{type:'prop', id:'a55ccc1f-8df3-4f3e-a91a-f33aa17e94e1'}]}, // Name {type:'composite', sortKey:'', headerKey:'b98d692c-54b6-48d5-a559-0bf6ea86f575', items:[{type:'prop', id:'b98d692c-54b6-48d5-a559-0bf6ea86f575'}]}, // ShortName {type:'composite', sortKey:'', headerKey:'0080dc6f-080a-4d20-bfa7-5b51e559cd35', items:[{type:'prop', id:'0080dc6f-080a-4d20-bfa7-5b51e559cd35'}]}, // Desc {type:'composite', sortKey:'', headerKey:'330ba45f-91c0-45af-9b65-381f444115f4', items:[{type:'prop', id:'330ba45f-91c0-45af-9b65-381f444115f4'}]} // Sort ]; // CarCategory objectEditorSetups['ea1c41c6-22f4-4992-807d-928e04e15e51'] = [ {type:'composite', sortKey:'', headerKey:'f03b33c3-3f71-46a4-8461-d0cb8a117f79', items:[{type:'prop', id:'f03b33c3-3f71-46a4-8461-d0cb8a117f79'}]}, // Name {type:'composite', sortKey:'', headerKey:'367c6e91-8cf2-45a3-99d3-a85dca11c736', items:[{type:'prop', id:'367c6e91-8cf2-45a3-99d3-a85dca11c736'}]}, // Desc {type:'composite', sortKey:'', headerKey:'4e407527-0a88-4a0a-b701-c0acdb7ecd22', items:[{type:'prop', id:'4e407527-0a88-4a0a-b701-c0acdb7ecd22'}]} // Sort ]; // EqCategory objectEditorSetups['f15c4ca1-5729-4b51-9b6b-b82a16cb8516'] = [ {type:'composite', sortKey:'', headerKey:'f03b33c3-3f71-46a4-8461-d0cb8a117f79', items:[{type:'prop', id:'f03b33c3-3f71-46a4-8461-d0cb8a117f79'}]}, // Name {type:'composite', sortKey:'', headerKey:'367c6e91-8cf2-45a3-99d3-a85dca11c736', items:[{type:'prop', id:'367c6e91-8cf2-45a3-99d3-a85dca11c736'}]}, // Desc {type:'composite', sortKey:'', headerKey:'4e407527-0a88-4a0a-b701-c0acdb7ecd22', items:[{type:'prop', id:'4e407527-0a88-4a0a-b701-c0acdb7ecd22'}]} // Sort ]; // JatoCars objectEditorSetups['7e74cbcc-bcf2-4f97-9ab4-cd2d4ce1349c'] = [ {type:'composite', sortKey:'', headerKey:'eb56561f-3161-49ab-824d-4fc7cba5be66', items:[{type:'prop', id:'eb56561f-3161-49ab-824d-4fc7cba5be66'}]}, // Jato#id {type:'composite', sortKey:'', headerKey:'45dc2638-e2c1-4214-b8fb-80e55c28896e', items:[{type:'prop', id:'45dc2638-e2c1-4214-b8fb-80e55c28896e'}]}, // Merke {type:'composite', sortKey:'', headerKey:'e9fe2a80-0f38-4d6d-bdf0-11d9c0840677', items:[{type:'prop', id:'e9fe2a80-0f38-4d6d-bdf0-11d9c0840677'}]}, // Modell {type:'composite', sortKey:'', headerKey:'fd219500-c88c-483d-89ff-970d5cf24c9b', items:[{type:'prop', id:'fd219500-c88c-483d-89ff-970d5cf24c9b'}]}, // Modellår {type:'composite', sortKey:'', headerKey:'773c9731-6751-4455-9356-f1c82beda1a2', items:[{type:'prop', id:'773c9731-6751-4455-9356-f1c82beda1a2'}]}, // Versjon {type:'composite', sortKey:'', headerKey:'8b88e4da-d991-4d71-a1ee-ff7e0416138f', items:[{type:'prop', id:'8b88e4da-d991-4d71-a1ee-ff7e0416138f'}]}, // Liter {type:'composite', sortKey:'', headerKey:'4440c20f-7a57-47ff-acaf-10d6a6af2920', items:[{type:'prop', id:'4440c20f-7a57-47ff-acaf-10d6a6af2920'}]}, // HK {cssClass:'ed_jato_catcol',type:'composite', sortKey:'', headerKey:'6230a7c3-3c7c-48d4-89e0-122be66188b4', items:[{type:'prop', id:'6230a7c3-3c7c-48d4-89e0-122be66188b4', extclass:'8b438735-0a31-44b6-9315-01fa28be59be', extprop:'a55ccc1f-8df3-4f3e-a91a-f33aa17e94e1'}]}, // Type {cssClass:'ed_jato_catcol',type:'composite', sortKey:'', headerKey:'59c80cdf-78b7-4e78-9ddc-03506a5b4144', items:[{type:'prop', id:'59c80cdf-78b7-4e78-9ddc-03506a5b4144', extclass:'ea1c41c6-22f4-4992-807d-928e04e15e51', extprop:'f03b33c3-3f71-46a4-8461-d0cb8a117f79'}]}, // Category {type:'composite', sortKey:'', headerKey:'b08576ba-44c4-47bd-8e47-29fff9985c59', items:[{type:'prop', id:'b08576ba-44c4-47bd-8e47-29fff9985c59'}]}, // Antall dører {type:'composite', sortKey:'', headerKey:'fe24a25e-b30b-428c-89e2-4b1b15c8cb65', items:[{type:'prop', id:'fe24a25e-b30b-428c-89e2-4b1b15c8cb65'}]}, // Biltype {type:'composite', sortKey:'', headerKey:'8693bea9-54b1-45da-bb86-5258b2b83cd7', items:[{type:'prop', id:'8693bea9-54b1-45da-bb86-5258b2b83cd7'}]}, // Isofix {type:'composite', sortKey:'', headerKey:'fa17c154-21bc-421b-acb7-6c9a0a4283e4', items:[{type:'prop', id:'fa17c154-21bc-421b-acb7-6c9a0a4283e4'}]}, // Antall seter {type:'composite', sortKey:'', headerKey:'cf01e943-8d3f-40c9-8430-79961f308720', items:[{type:'prop', id:'cf01e943-8d3f-40c9-8430-79961f308720'}]}, // Antall gir {type:'composite', sortKey:'', headerKey:'cdd710e7-dd47-4879-b457-7bb9a3dcc828', items:[{type:'prop', id:'cdd710e7-dd47-4879-b457-7bb9a3dcc828'}]}, // Taktype {type:'composite', sortKey:'', headerKey:'57c4d9c1-d878-4481-9e88-8af609baebe2', items:[{type:'prop', id:'57c4d9c1-d878-4481-9e88-8af609baebe2'}]}, // Drift {type:'composite', sortKey:'', headerKey:'ec2caf57-0d2a-4fd1-8526-9b073cea3467', items:[{type:'prop', id:'ec2caf57-0d2a-4fd1-8526-9b073cea3467'}]}, // Cabtype {type:'composite', sortKey:'', headerKey:'17fe1d4d-6632-4759-8bc7-a4f8d529418a', items:[{type:'prop', id:'17fe1d4d-6632-4759-8bc7-a4f8d529418a'}]}, // Karosseritype {type:'composite', sortKey:'', headerKey:'c71132e3-3098-4540-9d68-ce14d1f48950', items:[{type:'prop', id:'c71132e3-3098-4540-9d68-ce14d1f48950'}]}, // Karosseribeskrivelse {type:'composite', sortKey:'', headerKey:'cd6506f6-0f7b-47ae-a854-e10b765a1903', items:[{type:'prop', id:'cd6506f6-0f7b-47ae-a854-e10b765a1903'}]}, // Girtype {type:'composite', sortKey:'', headerKey:'bdb8debc-f689-4812-aa79-e9aa334515b1', items:[{type:'prop', id:'bdb8debc-f689-4812-aa79-e9aa334515b1'}]}, // Beskrivelse {type:'composite', sortKey:'', headerKey:'b999aefe-e75f-4369-bc9b-ef2b24380eb8', items:[{type:'prop', id:'b999aefe-e75f-4369-bc9b-ef2b24380eb8'}]}, // Drivstoff {type:'composite', sortKey:'', headerKey:'a291ef0d-a5af-45bc-9147-82172ce1d595', items:[{type:'prop', id:'a291ef0d-a5af-45bc-9147-82172ce1d595'}]}, // Bilpris {type:'composite', sortKey:'', headerKey:'2e51812e-ebbf-4d81-ba41-460649d17d88', items:[{type:'prop', id:'2e51812e-ebbf-4d81-ba41-460649d17d88'}]}, // Avgift {type:'composite', sortKey:'', headerKey:'57c11b8c-e793-4c4f-b615-71f9cb05c5e6', items:[{type:'prop', id:'57c11b8c-e793-4c4f-b615-71f9cb05c5e6'}]}, // EvalTest {type:'composite', sortKey:'', headerKey:'cdc4dc6d-21c2-488a-8e72-60a4cec26d46', items:[{type:'prop', id:'cdc4dc6d-21c2-488a-8e72-60a4cec26d46'}]} // Pris ]; // DealerCars objectEditorSetups['e43432e7-f81f-43fa-a772-55c644aacd9b'] = [ {type:'composite', sortKey:'', headerKey:'d79401be-320d-4863-ab89-fdc99e643a21', items:[{type:'prop', id:'d79401be-320d-4863-ab89-fdc99e643a21'}]}, // Merke {type:'composite', sortKey:'', headerKey:'354ddaf0-0ae0-49fa-b030-0278011ee093', items:[{type:'prop', id:'354ddaf0-0ae0-49fa-b030-0278011ee093'}]}, // Modell {type:'composite', sortKey:'', headerKey:'33adcfd6-b2cd-4e5b-bf60-33c6935e2f24', items:[{type:'prop', id:'33adcfd6-b2cd-4e5b-bf60-33c6935e2f24'}]}, // Modellår {type:'composite', sortKey:'', headerKey:'acc1b3e9-7fc5-4ba6-8d6a-f283a41f9c0b', items:[{type:'prop', id:'acc1b3e9-7fc5-4ba6-8d6a-f283a41f9c0b'}]}, // Name {cssClass:'ed_jato_catcol',type:'composite', sortKey:'', headerKey:'59c80cdf-78b7-4e78-9ddc-03506a5b4144', items:[{type:'prop', id:'59c80cdf-78b7-4e78-9ddc-03506a5b4144', extclass:'ea1c41c6-22f4-4992-807d-928e04e15e51', extprop:'f03b33c3-3f71-46a4-8461-d0cb8a117f79'}]}, // Category {type:'composite', sortKey:'', headerKey:'38eebb36-e49c-46b1-96cf-8f1a59f7a0ef', items:[{type:'prop', id:'38eebb36-e49c-46b1-96cf-8f1a59f7a0ef'}]}, // Antall dører {type:'composite', sortKey:'', headerKey:'bebcb7f2-c05d-4c3e-8b80-372291e35e88', items:[{type:'prop', id:'bebcb7f2-c05d-4c3e-8b80-372291e35e88'}]}, // Antall seter {type:'composite', sortKey:'', headerKey:'1313e6f1-f085-46bd-87f1-20d60a600bf0', items:[{type:'prop', id:'1313e6f1-f085-46bd-87f1-20d60a600bf0'}]}, // Antall gir {type:'composite', sortKey:'', headerKey:'b39d2210-f4fc-4c2c-b343-691a172acb67', items:[{type:'prop', id:'b39d2210-f4fc-4c2c-b343-691a172acb67'}]}, // Drift {type:'composite', sortKey:'', headerKey:'4df40d99-d8c8-4ef8-b60c-0b5a1be5499c', items:[{type:'prop', id:'4df40d99-d8c8-4ef8-b60c-0b5a1be5499c'}]}, // Karosseritype {type:'composite', sortKey:'', headerKey:'e623eba4-e82e-4d80-a8c2-b39d9b40e042', items:[{type:'prop', id:'e623eba4-e82e-4d80-a8c2-b39d9b40e042'}]}, // Karosseribeskrivelse {type:'composite', sortKey:'', headerKey:'ea5486e5-63b2-4ec4-9cdf-867fbe4b19fe', items:[{type:'prop', id:'ea5486e5-63b2-4ec4-9cdf-867fbe4b19fe'}]}, // Girtype {type:'composite', sortKey:'', headerKey:'4a81ca09-6aac-4f9c-a269-27d833b8b6b3', items:[{type:'prop', id:'4a81ca09-6aac-4f9c-a269-27d833b8b6b3'}]}, // Drivstoff {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'0aae0236-3726-432a-b000-a4689b620376', items:[{type:'prop', id:'0aae0236-3726-432a-b000-a4689b620376'}]}, // Innpris {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'96f3885d-e61d-4a62-a883-0245c4749938', items:[{type:'prop', id:'96f3885d-e61d-4a62-a883-0245c4749938'}]}, // Avgift {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'0d2ada75-8e6a-48c0-b155-355cceb57d69', items:[{type:'prop', id:'0d2ada75-8e6a-48c0-b155-355cceb57d69'}]}, // Årsavgift {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'c11d098e-f369-4419-8ba3-efd51d8f63ee', items:[{type:'prop', id:'c11d098e-f369-4419-8ba3-efd51d8f63ee'}]}, // Fast margin {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'355d8a45-dca1-4912-bb15-0eea2be87278', items:[{type:'prop', id:'355d8a45-dca1-4912-bb15-0eea2be87278'}]}, // Var margin {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'ec4b5bb4-a2c6-4653-8cce-56399830c88d', items:[{type:'prop', id:'ec4b5bb4-a2c6-4653-8cce-56399830c88d'}]}, // Frakt {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'58654a35-d7bf-47d7-86ae-97da17574ede', items:[{type:'prop', id:'58654a35-d7bf-47d7-86ae-97da17574ede'}]}, // Pris mod {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'be6f8847-9530-4cdc-a86e-71c11f3379ed', items:[{type:'prop', id:'be6f8847-9530-4cdc-a86e-71c11f3379ed'}]}, // Margin {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'d435b0e6-d853-4cc4-a8b8-6b156c77bcd7', items:[{type:'prop', id:'d435b0e6-d853-4cc4-a8b8-6b156c77bcd7'}]}, // Avrunding {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'52daa81d-5b62-4d1c-afed-c43052be1ee2', items:[{type:'prop', id:'52daa81d-5b62-4d1c-afed-c43052be1ee2'}]}, // Ut bilpris {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'71c763ec-0ccd-4e78-9265-25359b9a6b93', items:[{type:'prop', id:'71c763ec-0ccd-4e78-9265-25359b9a6b93'}]}, // Ut avgift {cssClass:'ed_jato_pricecol', type:'composite', sortKey:'', headerKey:'a0649fad-39fc-4a8e-bdc7-e681e66a1fe9', items:[{type:'prop', id:'a0649fad-39fc-4a8e-bdc7-e681e66a1fe9'}]}, // Veil pris {cssClass:'ed_jato_listcol', cssSubClass:'ed_jato_listcol_sub', type:'lists', headerText:T('gui_lists')} // lister ]; //JatoCar // {type:'composite', sortKey:'', headerKey:'4f49fb82-2420-494a-b6b9-4d1e77186a01', items:[{type:'prop', id:'4f49fb82-2420-494a-b6b9-4d1e77186a01'}]}, // Drivstoffsforbuk // {type:'composite', sortKey:'', headerKey:'b36a9575-c09e-41df-b183-22cd62296127', items:[{type:'prop', id:'b36a9575-c09e-41df-b183-22cd62296127'}]}, // Utslipp // {type:'composite', sortKey:'', headerKey:'f0191628-85f5-4b1b-9dfa-576b0bcb289d', items:[{type:'prop', id:'f0191628-85f5-4b1b-9dfa-576b0bcb289d'}]}, // Wheelbase // DealerCar // {type:'composite', sortKey:'', headerKey:'b9a3118d-cecf-4982-b56d-f1a3849b9aea', items:[{type:'prop', id:'b9a3118d-cecf-4982-b56d-f1a3849b9aea'}]}, // Wheelbase // {type:'composite', sortKey:'', headerKey:'b7284bab-2d09-4a46-9a46-facbd9b2fb6e', items:[{type:'prop', id:'b7284bab-2d09-4a46-9a46-facbd9b2fb6e'}]}, // Utslipp // {type:'composite', sortKey:'', headerKey:'db5cc82f-ffbe-4b88-b445-119b7f10dd03', items:[{type:'prop', id:'db5cc82f-ffbe-4b88-b445-119b7f10dd03'}]}, // Drivstoffsforbuk // {type:'composite', sortKey:'', headerKey:'7817a5a5-cb18-48c5-9337-07e17b56793f', items:[{type:'prop', id:'7817a5a5-cb18-48c5-9337-07e17b56793f'}]}, // Desc // {type:'composite', sortKey:'', headerKey:'7525d068-fdbb-422c-82b1-3931af35c7a5', items:[{type:'prop', id:'7525d068-fdbb-422c-82b1-3931af35c7a5'}]}, // Liter // {type:'composite', sortKey:'', headerKey:'d8615f78-327c-44aa-90b1-f257244ed054', items:[{type:'prop', id:'d8615f78-327c-44aa-90b1-f257244ed054'}]}, // HK // {cssClass:'ed_jato_catcol',type:'composite', sortKey:'', headerKey:'6230a7c3-3c7c-48d4-89e0-122be66188b4', items:[{type:'prop', id:'6230a7c3-3c7c-48d4-89e0-122be66188b4', extclass:'8b438735-0a31-44b6-9315-01fa28be59be', extprop:'a55ccc1f-8df3-4f3e-a91a-f33aa17e94e1'}]}, // Type // {type:'composite', sortKey:'', headerKey:'f8cd478b-3728-42ca-b0bb-d2f689fc515c', items:[{type:'prop', id:'f8cd478b-3728-42ca-b0bb-d2f689fc515c'}]}, // Biltype // {type:'composite', sortKey:'', headerKey:'0fa84c66-f4b2-4a82-98ae-9de5c276f285', items:[{type:'prop', id:'0fa84c66-f4b2-4a82-98ae-9de5c276f285'}]}, // Isofix // {type:'composite', sortKey:'', headerKey:'280161cf-9712-4712-b677-7d763c94e939', items:[{type:'prop', id:'280161cf-9712-4712-b677-7d763c94e939'}]}, // Taktype // {type:'composite', sortKey:'', headerKey:'d1af2b9e-7033-4966-a880-a0a3533808a6', items:[{type:'prop', id:'d1af2b9e-7033-4966-a880-a0a3533808a6'}]}, // Cabtype var getObjectEditorSetup = function(id) { if (objectEditorSetups[id]) return jAppML.utils.cloneObject(objectEditorSetups[id]); // generate default objectEditorSetup; return {}; //objectEditorSetups[0]; };jAppML.controls.ObjectLinkCheckBoxList = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlObjectLinkCheckBoxList"; if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); var me = this; this._dataSource.getAll(this.params.sort, null, function(sort, search, data) { me.data(data); }); this._dataSource.registerEventHandler("DataChange", this, this.onDataChange); }, checkIfInList: function(id) { var result = false; var value = this.value(); for(var i in value) { if (value[i].Id == id) { result = true; break; } } return result; }, addToList: function(id) { if (!this.checkIfInList(id)) { var oldList = this.value(); var newList = []; for (var i in oldList) { newList.push(oldList[i]); } newList.push({Id:id}); this.params.value = newList; this.invalidate(false); this.fireEvent('ValueChange'); } }, removeFromList: function(id) { if (!this.checkIfInList(id)) return; var oldList = this.value(); var newList = []; for (var i in oldList) { if (oldList[i].Id != id) newList.push(oldList[i]); } this.params.value = newList; this.invalidate(false); this.fireEvent('ValueChange'); }, onDomCheckChange: function(param, domElement) { var data = this.data(); var value = this.value(); var id = data[param].Id; var add = domElement.checked; if (add) this.addToList(id); else this.removeFromList(id); }, renderContents: function() { var out = []; var data = this.data(); if (data) { out.push(''); for (var i in data) { out.push(''); out.push(''); out.push(''); out.push(''); } out.push('
'); with(data[i]) { out.push(eval(this.params.nameTemplate)); } // out.push(data[i].Name); // out.push(''); out.push(''); out.push('
'); } else { out.push('progress...'); } return out.join(''); }, onDataChange: function() { var me = this; this._dataSource.getAll(null, null, function(sort, search, data) { me.data(data); }); }, value: function(value) { if (typeof(value) !== 'undefined') { if (this.params.value != value) { this.params.value = value; this.invalidate(true); this.fireEvent('ValueChange'); } } else { if (typeof(this.params.value) === 'undefined') this.params.value = []; return this.params.value; } }, data: function(value) { if (typeof(value) !== 'undefined') { if (this._data != value) { this._data = value; if (this._hasRendered) { this.invalidate(true); this.fireEvent('Redraw'); } } } else return this._data; } }); jAppML.controls.ObjectListEditor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlObjectListEditor"; this.propEditor = null; this.inEditParam = null; var oldpts = this.params.pts; var newpts = []; this.params.pts = []; for (var i in oldpts) { var oldpt = oldpts[i]; newpts[oldpt.Id] = oldpt; } this.params.pts = newpts; this.params.columns = getObjectEditorSetup(this.params.classtype.Id); this.params.noColumns = true; // find if header row is double this.params.doubleHeader = false; this.regenFakeObjects(); }, setController:function(controller) { this.params.controller = controller; for(var i in this.params.columns) { this.params.noColumns = false; var column = this.params.columns[i]; if (column.type == 'availgrouplink') { this.params.doubleHeader = true; // resolve objectids for group class var linkedClass = this.params.controller.getClassById(column.classId); column.headerText = T(linkedClass.Name); column.rowspan = "1"; } else if (column.type == 'composite') { var propType = this.params.pts[column.headerKey]; column.headerText = T(propType.Name); column.rowspan = "2"; } else if (column.type == 'lists') { column.rowspan = "1"; } } this.recalcAll(); }, onDomDropOver: function(param, elem) { elem.style.backgroundColor = "#fff0f0"; }, onPropEditorFocus: function(param, elem) { //elem.style.backgroundColor = "#fff0f0"; var o = this.params.data[param.index]; var p = null; for(var i in o.Properties) { var prop = o.Properties[i]; if (prop.Id == param.prop) { p = prop; break; } } if (!p) return; //alert(JSON.stringify(p)); var toolTipText = []; toolTipText.push(''); toolTipText.push(''); var lstvalue = ''; var hist = {}; for(var histIndex in p.History) { var lastRowCss = ""; hist = p.History[histIndex]; if (histIndex == p.History.length - 1) { if (p.Value == hist.Value) { lastRowCss="lastRow"; } } toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); } if (p.Value != hist.Value) { toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); } toolTipText.push('
' + T('date') + ' ' + T('revision') + ' ' + T('revisiontype') + ' ' + T('value') + ' 
'); toolTipText.push(hist.RevisionDate.toString("dd.MM.yyyy")); toolTipText.push(' '); toolTipText.push(hist.Revision); toolTipText.push(' '); toolTipText.push(T('revisiontype_' + hist.RevisionType)); toolTipText.push(' '); toolTipText.push(hist.Value); lastvalue = hist.Value; toolTipText.push(' 
'); toolTipText.push("-"); toolTipText.push(' '); toolTipText.push("-"); toolTipText.push(' '); toolTipText.push(T('revisiontype_0')); toolTipText.push(' '); toolTipText.push(p.Value); toolTipText.push(' 
'); //tt_PosFix(); var offset = $(elem).offset(); Tip(toolTipText.join(''), FIX,[offset.left,offset.top], ABOVE, true); }, onDomDropOut: function(param, elem) { elem.style.backgroundColor = ""; }, onPropEditorBlur: function(param, elem) { //elem.style.backgroundColor = ""; UnTip(); }, onDomRowClick: function(y) { alert(JSON.stringify(this.params.data[y])); }, addNewObject: function() { if (this._newObject != null) { this.params.data.push(this._newObject); this._newObject = null; } }, onDomPropClick: function(param, elem) { var object = this.params.data[param.index]; var me = this; if (object == this._newObject) { if (me.validateNewObjectNotEmpty()) { //me.addNewObject(); me._newObject = null; me.createNewObject(); me.invalidate(true); me.params.controller.invalidateOthers(me); me.fireEvent('NewRow'); setTimeout(function() { me.onDomPropClick(param, elem); },100); return; } } if (param.listindex) { var lists = this.params.controller.getLists(); var list = lists[param.listindex]; var found_list = false; for(var i in object.Lists) { if (object.Lists[i].Id == list.Id) { found_list = true; break; } } var oldList = object.Lists; object.Lists = []; if (found_list) { for(var i in oldList) { if (oldList[i].Id != list.Id) object.Lists.push(oldList[i]); } } else { for(var i in oldList) { object.Lists.push(oldList[i]); } object.Lists.push({Id:list.Id}); } elem.innerHTML = jAppML.controls.CheckBox.display(!found_list); this.invalidate(false); return; } if (me.propEditor) { setTimeout(function() { me.onDomPropClick(param); }, 100); return; } var pt = this.params.pts[param.prop]; if (pt.FormulaId || pt.DefaultFormula) return; var columnSettings = this.params.columns[param.column]; var itemSettings = columnSettings.items[param.item]; var ctrlClass2 = pt.JSEditor; if (ctrlClass2 == 'jAppML.controls.NewTextBox') ctrlClass2 = 'jAppML.controls.TextBoxMultiline'; if (ctrlClass2 == 'jAppML.controls.NewTextBoxMultiline') ctrlClass2 = 'jAppML.controls.TextBoxMultiline'; var ctrlClass = eval(ctrlClass2); if (itemSettings.extclass) { ctrlClass = jAppML.controls.DropDown; } // if (this.propEditor) { // // var object = this.params.data[this.inEditParam.index]; // // for(var fi in object.Properties) { // if (object.Properties[fi].Id == this.inEditParam.prop) { // object.Properties[fi].Value = this.propEditor.value(); // // var cell = document.getElementById(this.domId + '_propEditor'); // // var pt2 = this.params.pts[this.inEditParam.prop]; // var ptCtrl = eval(pt2.JSEditor); // // cell.innerHTML = ptCtrl.display(object.Properties[fi].Value); // cell.setAttribute("id", ""); // cell.setAttribute("onclick", this.renderCallback("onDomPropClick", this.inEditParam)); // // // } // } // this.inEditParam = null; // this.propEditor = null; // this.invalidate(false); // } elem = document.getElementById(this.domId + '_data' + param.index + '_row' + param.row + '_col' + param.column + '_item' + param.item); if (!elem) alert(JSON.stringify(param)); var upParam = null; var downParam = null; var leftParam = null; var rightParam = null; var isLastRow = (param.index == this.params.data.length -1); if (param.item > 0 || param.index > 0) { upParam = {move:true, column:param.column, row:param.row}; if (param.item > 0) { upParam.item = parseInt(param.item) -1; upParam.index = param.index; } else if (param.index > 0) { upParam.item = this.params.columns[param.column].items.length - 1; upParam.index = parseInt(param.index) - 1; } upParam.prop = this.params.columns[upParam.column].items[upParam.item].id; } if (true) { downParam = {move:true, column:param.column, row:param.row}; if (param.item < this.params.columns[param.column].items.length-1) { downParam.item = parseInt(param.item) +1; downParam.index = param.index; } else if (param.index < this.params.data.length -1) { downParam.item = 0; downParam.index = parseInt(param.index) + 1; } else { downParam.item = 0; downParam.index = parseInt(param.index) + 1; downParam.anotherNewRow = true; } //alert(downParam.column + " " + downParam.item); downParam.prop = this.params.columns[downParam.column].items[downParam.item].id; } if (param.column > 0) { var currentColumnIndex = parseInt(param.column) -1; var foundColumn = false; while(!foundColumn && currentColumnIndex >= 0) { var column = this.params.columns[currentColumnIndex]; if (column.type == 'composite') { var currentItemIndex = -1; for(var i in column.items) { var item = column.items[i]; var pt2 = this.params.pts[item.id]; if (pt2.FormulaId || pt2.DefaultFormula) { } else { currentItemIndex = parseInt(i); break; } } if (currentItemIndex != -1) { foundColumn = true; leftParam = {move:true, column:currentColumnIndex, row:param.row, item:currentItemIndex, index:param.index}; leftParam.prop = this.params.columns[leftParam.column].items[leftParam.item].id; //alert(JSON.stringify(leftParam)); break; } } currentColumnIndex--; } } if (param.column < this.params.columns.length-1) { var currentColumnIndex = parseInt(param.column) +1; var foundColumn = false; while(!foundColumn && currentColumnIndex <= this.params.columns.length-1) { var column = this.params.columns[currentColumnIndex]; if (column.type == 'composite') { var currentItemIndex = -1; for(var i in column.items) { var item = column.items[i]; var pt2 = this.params.pts[item.id]; if (pt2.FormulaId || pt2.DefaultFormula) { } else { currentItemIndex = parseInt(i); break; } } if (currentItemIndex != -1) { foundColumn = true; rightParam = {move:true, column:currentColumnIndex, row:param.row, item:currentItemIndex, index:param.index}; rightParam.prop = this.params.columns[rightParam.column].items[rightParam.item].id; //alert(JSON.stringify(rightParam)); break; } } currentColumnIndex++; } } this.inEditParam = param; //this.propEditor = new ctrlClass({onValueChange:}); var object = this.params.data[param.index]; var possibleValues; if (itemSettings.extclass) { possibleValues = []; var extObjects = this.params.controller.getAllObjectsByClassId(itemSettings.extclass); for(var i in extObjects) { var extObject = extObjects[i]; for(var p in extObject.Properties) { var prop = extObject.Properties[p]; if (prop.Id == itemSettings.extprop) { possibleValues.push({text:prop.Value,value:extObject.PublicId.Value}); break; } } } } this.propEditor = new ctrlClass({style:("height:" + $(elem).height() + "px;width:" + $(elem).width() + "px;"), possibleValues:possibleValues}); //this.propEditor = new ctrlClass({style:("height:" + $(elem).height() + "px;width:" + $(elem).width() + "px;overflow:hidden;"), possibleValues:possibleValues}); var prop = null; for(var fi in object.Properties) { if (object.Properties[fi].Id == param.prop) { prop = object.Properties[fi]; } } this.propEditor.value(prop.Value); if (!param.move) { if (pt.JSEditor == "jAppML.controls.CheckBox") this.propEditor.value(!this.propEditor.value()); } this.propEditor.registerEventHandler("ValueChange", this , function() { var ed = me.propEditor; if (ed) { prop.Value = ed.value(); me.updateCalcRow(param.index); if (isLastRow) { } me.invalidate(false); } }); this.propEditor.registerEventHandler("Blur", this, function() { me.onPropEditorBlur(param, elem); if (me.propEditor) { prop.Value = me.propEditor.value(); me.updateCalcRow(param.index); var cell = document.getElementById(me.domId + '_propEditor'); if (cell) { cell.innerHTML = me.propEditor.display(me.propEditor.value()); cell.setAttribute("id", me.domId + '_data' + param.index + '_row' + param.row + '_col' + param.column + '_item' + param.item); cell.setAttribute("onclick", me.renderCallback("onDomPropClick", me.inEditParam)); } me.inEditParam = null; me.propEditor = null; me.invalidate(false); } }); this.propEditor.registerEventHandler("Focus", this, function() { me.onPropEditorFocus(param, elem); }); if (upParam) { this.propEditor.registerEventHandler("MoveUp", this, function() { me.propEditor.fireEvent('Blur'); me.onDomPropClick(upParam); }); } if (downParam) { this.propEditor.registerEventHandler("MoveDown", this, function() { var go = true; if (isLastRow && downParam.anotherNewRow) { go = false; if (me.validateNewObjectNotEmpty()) { me._newObject = null; me.createNewObject(); $("#" + me.domId + " .jmlObjectListEditorTable tr:last").after(me.renderRow(me._newObject, me.params.data.length -1, true)); go = true; } } if (go) { me.propEditor.fireEvent('Blur'); me.onDomPropClick(downParam); } }); } if (leftParam) { this.propEditor.registerEventHandler("MoveLeft", this, function() { me.propEditor.fireEvent('Blur'); me.onDomPropClick(leftParam); }); } if (rightParam) { this.propEditor.registerEventHandler("MoveRight", this, function() { me.propEditor.fireEvent('Blur'); me.onDomPropClick(rightParam); }); } //this.propEditor.value(); elem.innerHTML = this.propEditor.render(); elem.setAttribute("id", this.domId + '_propEditor'); elem.setAttribute("onclick", ""); if (this.propEditor.select) setTimeout( function() {me.propEditor.select(); },50); else if (this.propEditor.focus) setTimeout( function() {me.propEditor.focus(); },50); ensureElementIsVisible(document.getElementById(this.domId).parentNode, elem.parentNode); //alert(JSON.stringify(param)); }, updateCalcRow: function(index) { var object = this.params.data[index]; var pts = this.params.pts; this.recalcRow(object); var fakeObject = {}; fakeObject.Properties = []; for(var fi in object.Properties) { var fio = object.Properties[fi]; fakeObject.Properties[fio.Id] = fio; } for(var x in this.params.columns) { var column = this.params.columns[x]; if (column.type == 'composite') { for(var z in column.items) { var item = column.items[z]; if (item.type == 'prop') { var pt = pts[item.id]; if (pt.FormulaId || pt.DefaultFormula) { var domElement = document.getElementById( this.domId + '_data' + index + '_row' + 0 + '_col' + x + '_item' + z); if (domElement) { var ptCtrl = eval(pt.JSEditor); domElement.innerHTML = ptCtrl.display(fakeObject.Properties[item.id].Value); } //else alert('cant_find'); } } } } } }, recalcAndRedraw: function() { this.recalcAll(); this.invalidate(true); this.fireEvent('RecalcAndRedraw'); }, recalcAll: function() { var data = this.params.data; for (var y in data) { var object = data[y]; this.recalcRow(object); } }, recalcRow: function(object) { var me = this; var fakeObject = {}; fakeObject.Properties = []; for(var fi in object.Properties) { var fio = object.Properties[fi]; fakeObject.Properties[fio.Id] = fio; } var pts = this.params.pts; var P = function(id) { var stringVal = fakeObject.Properties[id].Value; var realVal = stringVal; var pt = pts[id]; if (pt.DataTypeId == 'Currency') { realVal = 0; realVal = parseFloat(stringVal); if (isNaN(realVal)) realVal = 0; } else if (pt.DataTypeId == 'Decimal') { realVal = 0; realVal = parseFloat(stringVal); if (isNaN(realVal)) realVal = 0; } else if (pt.DataTypeId == 'Integer') { realVal = 0; realVal = parseInt(stringVal); if (isNaN(realVal)) realVal = 0; } return realVal; }; var CalcDealerEq = calculations.CalcDealerEq; var CalcDealerLocalEq = calculations.CalcDealerLocalEq; var CalcDealerCarMargin = calculations.CalcDealerCarMargin; var CalcDealerCarTax = calculations.CalcDealerCarTax; var CalcDealerCarPrice = calculations.CalcDealerCarPrice; var CalcDealerCarTotalPrice = calculations.CalcDealerCarTotalPrice; var Name = function() { return me.params.controller.getDocumentName(); }; var Pricemod = function(price,mod) { if (!mod) return price; try { if (mod.substr(mod.length -1, 1) == "%") { mod = mod.substr(0, mod.length-1); if (mod.substr(0,1) == "+") { mod = mod.substr(1, mod.length-1); return price*(1+(parseFloat(mod)/100)); } else if (mod.substr(0,1) == "-") { mod = mod.substr(1, mod.length-1); return price*(1-(parseFloat(mod)/100)); } else { return price*((parseFloat(mod)/100)); } } else { if (mod.substr(0,1) == "+") { mod = mod.substr(1, mod.length-1); return price+parseFloat(mod); } else if (mod.substr(0,1) == "-") { mod = mod.substr(1, mod.length-1); return price-parseFloat(mod); } else { return parseFloat(mod); } } } catch (e) { if (price) alert(e); return 0; } }; for(var i in fakeObject.Properties) { var prop = fakeObject.Properties[i]; var pt = pts[i]; if (pt.FormulaId || pt.DefaultFormula) { var formula = null; if (pt.FormulaId) { // find formula } if (!formula) { formula = pt.DefaultFormula; } prop.Value = '' + eval('(' + formula + ')'); } } }, regenFakeObjects: function() { this._fakeObjects = []; var data = this.params.data; for(var i in data) { var oldob = data[i]; var newob = {Properties:[]}; for(var p in oldob.Properties) { var prop = oldob.Properties[p]; newob.Properties[prop.Id] = prop.Value; } this._fakeObjects[oldob.PublicId.Value] = newob; } }, getFakeObject: function(id) { return this._fakeObjects[id]; }, getAllObjects: function() { var result = []; for (var i in this.params.data) { var ob = this.params.data[i]; if (ob == this._newObject) { if (this.validateNewObjectNotEmpty()) { result.push(ob); } } else { result.push(ob); } } return result; }, validateNewObjectNotEmpty: function() { if (!this._newObject) return false; var result = false; var pts = this.params.pts; var cl = this.params.classtype; for(var i in this._newObject.Properties) { var prop = this._newObject.Properties[i]; var pt = pts[prop.Id]; if (pt.DefaultFormula || pt.FormulaId) { } else { if (prop.Value) { result = true; break; } } } return result; }, createNewObject: function() { if (this._newObject) return; var data = this.params.data; var result = {}; var pts = this.params.pts; var cl = this.params.classtype; result.Properties = []; result.Id = jAppML.controls.ObjectListEditor.getTempId(); result.Class = {Value:cl.Id}; result.PublicId = {Value:result.Id}; result.AccessoryFor = {Value:''}; result.IncludedIn = {Value:''}; //result.IncludedIn = {Value:''}; for(var i in cl.PropertyTypeIds) { var pt_id = cl.PropertyTypeIds[i]; var pt = pts[pt_id]; var prop = {}; prop.Id = pt_id; prop.Value = ""; result.Properties.push(prop); } data.push(result); this._newObject = result; return result; }, renderContents: function() { if (this.params.noColumns) return ""; var out = []; var classtype = this.params.classtype; var pts = this.params.pts; var data = this.params.data; var listtypes = this.params.controller.getListTypes(); var lists = this.params.controller.getLists(); out.push(''); out.push(''); this.params.doubleHeader = false; var drawthis = true; for(var y in this.params.columns) { drawthis = true; var column = this.params.columns[y]; var colspan = null; if (column.type == 'availgrouplink') { column.objects = this.params.controller.getAllObjectsByClassId(column.classId); colspan = 0; for(var z in column.objects) colspan++; if (colspan > 0) { this.params.doubleHeader = true; } else { drawthis = false; colspan = null; } } else if (column.type == 'lists') { column.objects = lists; colspan = 0; for(var z in column.objects) colspan++; if (colspan > 0) { this.params.doubleHeader = true; } else { drawthis = false; colspan = null; } } if (drawthis) { out.push(''); out.push(column.headerText); out.push(''); } } out.push(''); if (this.params.doubleHeader) { out.push(''); for(var y in this.params.columns) { var column = this.params.columns[y]; if (column.type == 'availgrouplink') { for(var yy in column.objects) { var object = column.objects[yy]; var fakeobject = {}; fakeobject.Properties = []; for(var fi in object.Properties) { var fio = object.Properties[fi]; fakeobject.Properties[fio.Id] = fio.Value; } with(fakeobject) { //alert("" + eval(column.textExpr)); out.push('' + eval(column.textExpr) + ''); } } } else if (column.type == 'lists') { for(var yy in column.objects) { var object = column.objects[yy]; var lt = listtypes[object.Id]; out.push('' + T(lt.Name) + ''); } } } out.push(''); } out.push(''); out.push(''); var even = false; this.createNewObject(); for (var y in data) { even = !even; out.push(this.renderRow(data[y], y, even)); } out.push(''); out.push('
'); return out.join(''); }, renderRow: function(object, y, even) { var out = []; var fakeObject = {}; fakeObject.Properties = []; for(var fi in object.Properties) { var fio = object.Properties[fi]; fakeObject.Properties[fio.Id] = fio; } var overriddenProps = []; var numRows = []; var maxRows = 1; //var linkPropColumns = []; for(var x in this.params.columns) { numRows[x] = 1; var column = this.params.columns[x]; if (column.type == 'composite') { for(var z in column.items) { var item = column.items[z]; if (item.type == 'prop') { var overrides = fakeObject.Properties[item.id].Overrides; if (overrides) { var o_length = 0; for(var ooo in overrides) { o_length++; } if (o_length > 0) { var override_array = []; overriddenProps[item.id] = override_array; for(var override_index in overrides) { var override = overrides[override_index]; if (!override_array[override.Value]) { //linkPropColumns[item.id] = x; numRows[x]++; if (numRows[x] > maxRows) maxRows = numRows[x]; override_array[override.Value] = []; } override_array[override.Value].push(override.Link); } } } } } } } for(var n = 0; n < maxRows; n++) { out.push(''); for(var x in this.params.columns) { var column = this.params.columns[x]; var rowspan = 1; if (numRows[x] == 1) rowspan = maxRows; if (column.type == 'composite') { if (numRows[x] > n) { out.push(''); for(var z in column.items) { var item = column.items[z]; var isInEdit = false; if (this.inEditParam) { if (this.inEditParam.prop == item.id && this.inEditParam.index == y && this.inEditParam.row == n) { isInEdit = true; } } if (!isInEdit) { out.push('
'); var pt = this.params.pts[item.id]; var ptCtrl = eval(pt.JSEditor); if (item.type == 'prop') { var writeStandard = true; if (overriddenProps[item.id]) { var override_array = overriddenProps[item.id]; var ooo_i = 0; for(var ooo in override_array) { ooo_i++; if (ooo_i == n) { out.push(ptCtrl.display(ooo)); writeStandard = false; } } } if (pt.DataTypeId == 'ContainmentLink' || pt.DataTypeId == 'ForeignKey') { var extId = fakeObject.Properties[item.id].Value; var extObj = this.params.controller.getFakeObject(item.extclass, extId); if (extObj) { if (writeStandard) { var zzz = ptCtrl.display(extObj.Properties[item.extprop]); out.push(zzz ? zzz : " "); } } else if (writeStandard) out.push(" "); } else { if (writeStandard) out.push(ptCtrl.display(fakeObject.Properties[item.id].Value)); } } } else { out.push('
'); out.push(this.propEditor.render()); } out.push('
'); } out.push(''); } } else if (column.type == 'lists') { if (n == 0) { for(var z in column.objects) { out.push(''); out.push('
'); var list_found = false; for(var zz in object.Lists) { if (object.Lists[zz].Id == column.objects[z].Id) { list_found = true; break; } } out.push(jAppML.controls.CheckBox.display(list_found)); out.push('
'); } } } else if (column.type == 'availgrouplink') { for(var z in column.objects) { out.push(''); //out.push(''); var expr = object.AccessoryFor.Value; var addTest = []; var allTest = []; if (overriddenProps[column.linkProp]) { var override_array = overriddenProps[column.linkProp]; var ooo_i = 0; for(var ooo in override_array) { ooo_i++; allTest.push(override_array[ooo]); if (ooo_i == n) { addTest = override_array[ooo]; } } } var O = function(id) { //if (y == 1) alert(id + " " + column.objects[z].PublicId.Value); return (id == column.objects[z].PublicId.Value); }; var allMatch = false; // check if match on override if (allTest.length > 0) { for(var al in allTest) { var tempTest = allTest[al]; if (tempTest) { if (tempTest.length > 0) { var expr2 = tempTest.join("||"); if (expr) expr2 = "(" + expr + ")&&(" + expr2 + ")"; if (eval("(" + expr2 + ")")) allMatch = true; } } } } if (addTest.length > 0) { if (expr != "") expr = "(" + expr + ")&&(" + addTest.join("||") + ")"; } var match = false; if (expr != "") match = eval('(' + expr + ')'); var isIncluded = false; if (object.IncludedIn != null) { if (object.IncludedIn.Value != null) { if (object.IncludedIn.Value != "") { isIncluded = eval('(' + object.IncludedIn.Value + ')'); } } } if (n == 0 && allMatch) match = false; if (match) out.push((isIncluded ? 'S' : 'O')); else out.push('-'); out.push(''); } } } out.push(''); } return out.join(''); }, onRendered: function() { freezeTableHeader(document.getElementById(this.domId).parentNode, "#" + this.domId + " .jmlObjectListEditorTable", 1); } }); jAppML.controls.ObjectListEditor.tempIdCounter = 0; jAppML.controls.ObjectListEditor.getTempId = function() { return ":tempid:" + jAppML.controls.ObjectListEditor.tempIdCounter++; };var dataSourceService = 'Oculos.Epd.Web.WcfService'; jAppML.controls.PathDataSource = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = ""; // find functions var s = this.source().split('.'); var className = s[s.length-1]; this._service = eval(dataSourceService); var me = this; this._data = null; if (this._service[className + 'GetAll']) { this._getAll = function(onSuccess) { AjaxQueue(function(failed) { me._service[className + 'GetAll'](window.impersonation, function(result) { me._data = result; onSuccess(); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Save']) { this._save = function(obj, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Save'](window.impersonation, obj, function(result) { onSuccess(); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Rename']) { this._rename = function(obj, newname, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Rename'](window.impersonation, obj.Id, newname, function(result) { obj.Name = result; onSuccess(obj); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Move']) { this._move = function(id, newparent, onSuccess) { AjaxQueue(function(failed) { if (newparent == "") newparent = null; me._service[className + 'Move'](window.impersonation, id, newparent, function(result) { onSuccess(result); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Delete']) { this._delete = function(obj, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Delete'](window.impersonation, obj.Id, null, function(result) { onSuccess(obj); }, function(failure) { failed(failure); }); }); }; } if (this._service[className + 'Create']) { this._create = function(obj, newname, onSuccess) { AjaxQueue(function(failed) { me._service[className + 'Create'](window.impersonation, obj.Id, newname, function(result) { onSuccess(result); }, function(failure) { failed(failure); }); }); }; } }, findNode: function(path, id) { if (path.Id == id) return path; else { for (var i in path.Paths) { var p = this.findNode(path.Paths[i], id); if (p) return p; } } return null; }, findParentNode: function(path, id) { for (var i in path.Paths) { if (path.Paths[i].Id == id) return path; else { var p = this.findParentNode(path.Paths[i], id); if (p) return p; } } return null; }, renameNode: function(obj, newName, callback) { var me = this; me._rename(obj, newName, function(newob) { // findNode var node = me.findNode(me._data, newob.Id); node.Name = newob.Name; var oldData = me._data; me._data = {}; me._data.Name = oldData.Name; me._data.Paths = oldData.Paths; me._data.Id = oldData.Id; if (callback) callback(); me.fireEvent('DataChange'); }); }, moveNode: function(id, newparent, callback) { var me = this; me._move(id, newparent, function(result) { me._data = result; if (callback) callback(); me.fireEvent('DataChange'); }); }, newNode: function(obj, newName, callback) { var me = this; me._create(obj, newName, function(newob) { // findNode var node = me.findNode(me._data, obj.Id); node.Paths.push(newob); var oldData = me._data; me._data = {}; me._data.Name = oldData.Name; me._data.Paths = oldData.Paths; me._data.Id = oldData.Id; if (callback) callback(newob); me.fireEvent('DataChange'); }); }, deleteNode: function(obj, callback) { var me = this; me._delete(obj, function(newob) { // findNode var parent = me.findParentNode(me._data, newob.Id); var oldPaths = parent.Paths; parent.Paths = []; for (var i in oldPaths) { if (oldPaths[i].Id != newob.Id) parent.Paths.push(oldPaths[i]); } var oldData = me._data; me._data = {}; me._data.Name = oldData.Name; me._data.Paths = oldData.Paths; me._data.Id = oldData.Id; if (callback) callback(); me.fireEvent('DataChange'); }); }, getByParent: function(parentPath,callback) { var me = this; if (!this._data) { this._getAll(function() {me.getByParent(parentPath, callback); }); } }, getAll: function(callback) { var me = this; if (!this._data) { this._getAll(function() {me.getAll(callback); }); } callback(this._data); }, refresh: function(sort, search) { }, source: function(value) { if (typeof(value) !== 'undefined') { if (this.params.source != value) { this.params.source = value; this.invalidate(true); this.fireEvent('SourceChanged'); } } else return this.params.source; } });jAppML.controls.PropertyEditor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'table'); this.fixedClass = "jmlPropertyEditor"; if (this.params.hideHeader == "true" || this.params.hideHeader == true) { this.params.hideHeader = true; } //this.ctrl = new jAppML.controls.TextBox(); this.data = null; // find editor this._editor = null; }, value: function(value) { if (typeof(value) !== 'undefined') { this.ctrl.value(value); this.invalidate(true); this.fireEvent('ValueChange'); } else return this.ctrl.value(); }, onCtrlChange: function(param,src) { var s = this.source().split('.'); var c = this.data; for(var i = 0; i < s.length - 1; i++) { c = c[s[i]]; } //alert(c[s[i]]); c[s[i]] = this.ctrl.value(); this.fireEvent("ValueChange"); this.invalidate(false); }, prepareAttributes: function() { this._super(); this.attributes['cellspacing'] = "0"; this.attributes['cellpadding'] = "0"; }, renderContents: function() { if (!this.ctrl) { var c = this; while (!(c instanceof jAppML.controls.Editor)) { c = c.parent; } this._editor = c; var ctrlParams = {}; if (this.params.controlParams) ctrlParams = this.params.controlParams; this.ctrl = this._editor.getEditorForProperty(this.source(), ctrlParams, this.namingContainer); this.ctrl.parent = this; this.ctrl.registerEventHandler("ValueChange", this , this.onCtrlChange); this.data = c.data(); var me = this; with(this.data) { me.ctrl.value(eval(me.source())); } } var out = []; out.push(''); if (!this.params.hideHeader) { out.push(''); var headerKey = this.header(); if (!headerKey) headerKey = this._editor._dataSource.getHeaderForProperty(this.source()); out.push(T(headerKey)); out.push(''); } out.push(''); out.push(this.ctrl.render()); out.push(''); return out.join(''); }, source: function(value) { if (typeof(value) !== 'undefined') { if (this.params.source != value) { this.params.source = value; this.invalidate(true); this.fireEvent('SourceChanged'); } } else return this.params.source; }, header: function(value) { if (typeof(value) !== 'undefined') { if (this.params.header != value) { this.params.header = value; this.invalidate(true); this.fireEvent('HeaderChanged'); } } else return this.params.header; } }); jAppML.controls.SingleObjectEditor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlObjectListEditor"; var oldpts = this.params.pts; var newpts = []; this.params.pts = []; for (var i in oldpts) { var oldpt = oldpts[i]; newpts[oldpt.Id] = oldpt; } this.params.pts = newpts; var data = this.params.data; if (data.length == 0) { this.createDefaultObject(); } this.editCtrl = null; this.editProp = null; }, createDefaultObject: function() { var data = this.params.data; var result = {}; var pts = this.params.pts; var cl = this.params.classtype; result.Properties = []; result.Id = jAppML.controls.ObjectListEditor.getTempId(); result.Class = {Value:cl.Id}; result.PublicId = {Value:result.Id}; result.AccessoryFor = {Value:''}; result.IncludedIn = {Value:''}; //result.IncludedIn = {Value:''}; for(var i in cl.PropertyTypeIds) { var pt_id = cl.PropertyTypeIds[i]; var pt = pts[pt_id]; var prop = {}; prop.Id = pt_id; prop.Value = ""; result.Properties.push(prop); } data.push(result); return result; }, setController:function(controller) { this.params.controller = controller; }, onRendered: function() { if (this.editCtrl) { if (this.editCtrl.focus) this.editCtrl.focus(); if (this.editCtrl.select) this.editCtrl.select(); } }, onPropEditorBlur: function(param, elem) { //elem.style.backgroundColor = ""; //UnTip(); }, onCellClick: function(param, elem) { var me = this; // if (me.editCtrl) { // setTimeout(function() { me.onCellClick(param); }, 100); // return; // } if (me.editCtrl) { me.oldProp.Value = me.editCtrl.value(); var cell = document.getElementById(me.domId + '_' + me.editProp); if (cell) { cell.innerHTML = me.editCtrl.display(me.editCtrl.value()); cell.setAttribute("onclick", me.renderCallback("onCellClick", me.editProp)); } me.editProp = null; me.editCtrl = null; me.oldProp = null; me.invalidate(false); } elem.setAttribute("onclick", ""); var domCell = elem; var pt = this.params.pts[param]; var ctrlClass2 = pt.JSEditor; if (ctrlClass2 == 'jAppML.controls.NewTextBox') ctrlClass2 = 'jAppML.controls.TextBoxMultiline'; if (ctrlClass2 == 'jAppML.controls.NewTextBoxMultiline') ctrlClass2 = 'jAppML.controls.TextBoxMultiline'; var ctrlClass = eval(ctrlClass2); //var ctrlClass = eval(pt.JSEditor); this.editCtrl = new ctrlClass(); this.editCtrl.setParent(this); this.editProp = param; this.editCtrl.value(); var object = this.params.data[0]; var prop = null; for (var i in object.Properties) { var testprop = object.Properties[i]; if (testprop.Id == param) { prop = testprop; break; } } this.oldProp = prop; var me = this; this.editCtrl.value(prop.Value); // this.editCtrl.registerEventHandler("Blur", this, function() { // me.onPropEditorBlur(param, elem); // if (me.editCtrl) { // prop.Value = me.editCtrl.value(); // // var cell = document.getElementById(me.domId + '_' + me.editProp); // if (cell) { // cell.innerHTML = me.editCtrl.display(me.editCtrl.value()); // cell.setAttribute("onclick", me.renderCallback("onCellClick", me.editProp)); // } // // me.editProp = null; // me.editCtrl = null; // me.invalidate(false); // } // // }); this.editCtrl.registerEventHandler("ValueChange", this, function() { me.onPropEditorBlur(param, elem); if (me.editCtrl) { prop.Value = me.editCtrl.value(); // var cell = document.getElementById(me.domId + '_' + me.editProp); // if (cell) { // cell.innerHTML = me.editCtrl.display(me.editCtrl.value()); // cell.setAttribute("onclick", me.renderCallback("onCellClick", me.editProp)); // } // // me.editProp = null; // me.editCtrl = null; me.invalidate(false); } }); //domCell.innerHTML = this.editCtrl.render(); this.invalidate(true); this.fireEvent('redraw'); }, onCellOver: function(param, elem) { elem.style.backgroundColor = "#fff0f0"; }, onCellOut:function(param, elem) { elem.style.backgroundColor = ""; }, getFakeObject: function() { var object = this.params.data[0]; var fakeObject = {}; fakeObject.Properties = []; for (var i in object.Properties) { var prop = object.Properties[i]; fakeObject.Properties[prop.Id] = prop.Value; } return fakeObject; }, getAllObjects: function() { return this.params.data; }, renderContents: function() { //if (this.params.noColumns) return ""; var out = []; var fakeObject = this.getFakeObject(); var pts = this.params.pts; var cl = this.params.classtype; out.push(''); for (var i in cl.PropertyTypeIds) { var pt_id = cl.PropertyTypeIds[i]; var pt = pts[pt_id]; out.push(''); out.push(''); if (pt_id == this.editProp && this.editCtrl != null) { out.push(''); out.push(''); } out.push('
'); out.push(T(pt.Name)); out.push('
'); out.push(this.editCtrl.render()); } else { out.push('
'); var ctrlClass = eval(pt.JSEditor); out.push(ctrlClass.display(fakeObject.Properties[pt_id], this)); } out.push('
'); return out.join(''); }, onRendered: function() { if (this.editCtrl) this.editCtrl.focus(); } }); jAppML.controls.TextBox = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'input'); this._text = this.params.text ? this.params.text : ''; this.attributes['type'] = 'text'; this.fixedClass = "jmlInput jmlTextBox"; this._hasFocus = false; }, prepareAttributes: function() { this._super(); this.attributes['value'] = (this._text ? this._text : "").replace('"','"', 'g'); this.attributes['onchange'] = this.renderCallback('domOnChange', null); this.attributes['onkeyup'] = this.renderCallback('domOnKeyUp', null); this.attributes['onkeydown'] = this.renderCallback('domOnKeyDown', null); this.attributes['onfocus'] = this.renderCallback('domOnFocus', null); this.attributes['onblur'] = this.renderCallback('domOnBlur', null); this.attributes['onmouseover'] = this.renderCallback('domOnMouseOver', null); this.attributes['onmouseout'] = this.renderCallback('domOnMouseOut', null); }, text: function(value) { if (typeof(value) !== 'undefined') { if (this._text != value) { this._text = value; try{document.getElementById(this.domId).value = value;}catch(ex){} this.invalidate(); this.fireEvent('TextChange'); this.fireEvent('ValueChange'); } } else return this._text; }, value: function(value) { return this.text(value); }, clear: function() { this.text(""); }, focus: function(value) { document.getElementById(this.domId).focus(); }, select: function(value) { document.getElementById(this.domId).select(); }, domOnFocus: function(param, domElement) { $(domElement).removeClass('jmlTextBox_hover'); $(domElement).addClass('jmlTextBox_focus'); this._hasFocus = true; this.fireEvent("Focus"); }, domOnBlur: function(param, domElement) { $(domElement).removeClass('jmlTextBox_hover'); $(domElement).removeClass('jmlTextBox_focus'); this._hasFocus = false; this.fireEvent('Blur'); }, domOnMouseOver: function(param, domElement) { if (!this._hasFocus) $(domElement).addClass('jmlTextBox_hover'); }, domOnMouseOut: function(param, domElement) { $(domElement).removeClass('jmlTextBox_hover'); }, domOnChange: function(param, domElement) { this.text(domElement.value); }, domOnKeyUp: function(param, domElement, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; if (this._text != domElement.value) { this._text = domElement.value; this.fireEvent('TextChange'); this.fireEvent('ValueChange'); this.invalidate(false); } this.fireEvent('KeyUp', {keyCode:keyCode, shiftKey:shiftKey}); }, domOnKeyDown: function(param, elem, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; var me = this; if (keyCode == 9) { evt.cancelBubble = true; if (shiftKey) this.fireEvent('MoveLeft'); else this.fireEvent('MoveRight'); } else if ((keyCode == 37 || keyCode == 39) && !shiftKey) { var sel = false; if (document.selection) { if (document.selection.createRange().duplicate().text != '') sel = true; } else { if (elem.selectionStart != elem.selectionEnd) sel = true; } if (sel) { if (elem.selectionEnd) { var newpos = 0; if (keyCode == 37) newpos = elem.selectionStart+1; if (keyCode == 39) newpos = elem.selectionEnd-1; if (newpos < 0) newpos = 0; if (newpos > elem.value.length) newpos = elem.value.length; setCaretPosition(elem,newpos); } return; } var pos = doGetCaretPosition(elem); if (keyCode == 37 && pos == 0) { var evt2 = {keyCode:9,shiftKey:true}; this.domOnKeyDown(param, elem, evt2); return; } else if (keyCode == 39 && pos == elem.value.length) { var evt2 = {keyCode:9,shiftKey:false}; this.domOnKeyDown(param, elem, evt2); return; } } else if (keyCode == 40 && !shiftKey) { this.fireEvent('MoveDown'); } else if (keyCode == 38 && !shiftKey) { this.fireEvent('MoveUp'); } }, display: function(value) { return jAppML.controls.TextBox.display(value); } }); jAppML.controls.TextBox.display = function(value) { if (value) return value; else return " "; }; jAppML.controls.PasswordBox = jAppML.controls.TextBox.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.attributes['type'] = 'password'; this.fixedClass = "jmlInput jmlTextBox jmlPasswordBox"; } }); jAppML.controls.TextBoxMultiline = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'textarea'); this._text = this.params.text ? this.params.text : ''; //this.attributes['type'] = 'text'; this.fixedClass = "jmlInput jmlTextBox jmlTextBoxMultiline"; this._hasFocus = false; this._calcHeight = null; }, prepareAttributes: function() { this._super(); //this.attributes['value'] = this._text; this.attributes['onchange'] = this.renderCallback('domOnChange', null); this.attributes['onkeyup'] = this.renderCallback('domOnKeyUp', null); this.attributes['onkeydown'] = this.renderCallback('domOnKeyDown', null); this.attributes['onfocus'] = this.renderCallback('domOnFocus', null); this.attributes['onblur'] = this.renderCallback('domOnBlur', null); this.attributes['onmouseover'] = this.renderCallback('domOnMouseOver', null); this.attributes['onmouseout'] = this.renderCallback('domOnMouseOut', null); if (this._calcHeight) this.attributes['style'] = 'height:' + this._calcHeight + ';'; }, text: function(value) { if (typeof(value) !== 'undefined') { if (this._text != value) { this._text = value; try{document.getElementById(this.domId).innerHTML = value;}catch(ex){} this._calcHeight = null; this.invalidate(); this.fireEvent('TextChange'); this.fireEvent('ValueChange'); } } else return this._text; }, renderScriptDelayContents: function() { return this.renderEventlessCallback("domResize", {}); }, renderContents: function() { return this._text ? this._text : ""; }, value: function(value) { return this.text(value); }, clear: function() { this.text(""); }, focus: function(value) { document.getElementById(this.domId).focus(); }, select: function(value) { document.getElementById(this.domId).select(); }, domOnFocus: function(param, domElement) { $(domElement).removeClass('jmlTextBox_hover'); $(domElement).addClass('jmlTextBox_focus'); this._hasFocus = true; this.fireEvent("Focus"); }, domOnBlur: function(param, domElement) { $(domElement).removeClass('jmlTextBox_hover'); $(domElement).removeClass('jmlTextBox_focus'); this._hasFocus = false; this.fireEvent('Blur'); }, domOnMouseOver: function(param, domElement) { if (!this._hasFocus) $(domElement).addClass('jmlTextBox_hover'); }, domOnMouseOut: function(param, domElement) { $(domElement).removeClass('jmlTextBox_hover'); }, domOnChange: function(param, domElement) { this.text(domElement.value); }, domResize: function() { if (this._calcHeight) return; var el = document.getElementById(this.domId); if (el) { this._calcHeight = el.scrollHeight+"px"; el.style.height = this._calcHeight; } }, domOnKeyUp: function(param, domElement, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; this._calcHeight = null; this.domResize(); if (this._text != domElement.value) { this._text = domElement.value; this.fireEvent('TextChange'); this.fireEvent('ValueChange'); this.invalidate(false); } this.fireEvent('KeyUp', {keyCode:keyCode, shiftKey:shiftKey}); }, domOnKeyDown: function(param, elem, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; var me = this; if (keyCode == 9) { evt.cancelBubble = true; if (shiftKey) this.fireEvent('MoveLeft'); else this.fireEvent('MoveRight'); } else if ((keyCode == 37 || keyCode == 39) && !shiftKey) { var sel = false; if (document.selection) { if (document.selection.createRange().duplicate().text != '') sel = true; } else { if (elem.selectionStart != elem.selectionEnd) sel = true; } if (sel) { if (elem.selectionEnd) { var newpos = 0; if (keyCode == 37) newpos = elem.selectionStart+1; if (keyCode == 39) newpos = elem.selectionEnd-1; if (newpos < 0) newpos = 0; if (newpos > elem.value.length) newpos = elem.value.length; setCaretPosition(elem,newpos); } return; } var pos = doGetCaretPosition(elem); if (keyCode == 37 && pos == 0) { var evt2 = {keyCode:9,shiftKey:true}; this.domOnKeyDown(param, elem, evt2); return; } else if (keyCode == 39 && pos == elem.value.length) { var evt2 = {keyCode:9,shiftKey:false}; this.domOnKeyDown(param, elem, evt2); return; } } else if ((keyCode == 40 || keyCode == 38)&& !shiftKey) { var sel = false; if (document.selection) { if (document.selection.createRange().duplicate().text != '') sel = true; } else { if (elem.selectionStart != elem.selectionEnd) sel = true; } if (sel) { if (elem.selectionEnd) { var newpos = 0; if (keyCode == 38) { //newpos = elem.selectionStart+1; this.fireEvent("MoveUp"); return; } if (keyCode == 40) { //newpos = elem.selectionEnd-1 this.fireEvent("MoveDown"); return; } if (newpos < 0) newpos = 0; if (newpos > elem.value.length) newpos = elem.value.length; setCaretPosition(elem,newpos); } return; } var pos = doGetCaretPosition(elem); if (keyCode == 38 && pos == 0) { this.fireEvent("MoveUp"); return; } else if (keyCode == 40 && pos == elem.value.length) { this.fireEvent("MoveDown"); return; } } }, display: function(value) { return jAppML.controls.TextBoxMultiline.display(value); } }); jAppML.controls.TextBoxMultiline.display = function(value) { if (value) return value.replace("\n", "
", "g"); else return " "; };jAppML.controls.ToolBarButtonGroup = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'table'); this.fixedClass = "jmlTBBG"; }, prepareAttributes: function() { this._super(); this.attributes['cellspacing'] = "0"; this.attributes['cellpadding'] = "0"; }, renderContents: function() { var out = []; out.push(''); out.push(''); out.push(this.namedChildren['content'] ? this.namedChildren['content'].renderChildren() : (this.params.content ? this.params.content : this.renderChildren())); out.push(''); out.push(this.namedChildren['caption'] ? this.namedChildren['caption'].renderChildren() : (this.params.caption ? this.params.caption : '')); out.push(''); return out.join(''); }, content: function(value) { if (typeof(value) !== 'undefined') { if (this.params.content != value) { this.params.content = value; this.invalidate(true); this.fireEvent('ContentChanged'); } } else return this.params.content; }, caption: function(value) { if (typeof(value) !== 'undefined') { if (this.params.caption != value) { this.params.caption = value; this.invalidate(true); this.fireEvent('CaptionChanged'); } } else return this.params.caption; } });jAppML.controls.TreeView = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlTreeView"; if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); var me = this; this._expandedNodes = []; this._dataSource.getAll(function(data) { me.data(data); }); this._dataSource.registerEventHandler("DataChange", this, this.onDataChange); }, deleteNode: function(obj, callback) { this._dataSource.deleteNode(obj, callback); }, renameNode: function(obj, newname, callback) { this._dataSource.renameNode(obj, newname, callback); }, moveNode: function(id, newparent, callback) { this._dataSource.moveNode(id, newparent, callback); }, newNode: function(obj, newname, callback) { var me = this; this._dataSource.newNode(obj, newname, function(newob) { me._expandedNodes[obj.Id] = true; if (callback) callback(newob); }); }, onDataChange: function() { var me = this; this._dataSource.getAll(function(data) { me.data(data); }); }, prepareAttributes: function() { this._super(); }, domOnRowOver: function(param, domElement) { //$(domElement).addClass('_rowhover'); }, domOnRowOut: function(param, domElement) { //$(domElement).removeClass('_rowhover'); }, domOnNodeCollapse: function(param) { this._expandedNodes[param] = false; this.invalidate(true); this.fireEvent('NodeCollapse'); }, domOnNodeExpand: function(param) { this._expandedNodes[param] = true; this.invalidate(true); this.fireEvent('NodeExpand'); }, domOnNodeSelect: function(param) { this.selectedNode(param); }, findNode: function(path, id) { if (path.Id == id) return path; else { for (var i in path.Paths) { var p = this.findNode(path.Paths[i], id); if (p) return p; } } return null; }, onDomDrop: function(param) { var me = this; // find data var topPath = this.data(); var data = this.findNode(topPath,param); this.fireEvent('Drop', {drag:jAppML.utils.dragObject(), drop:data}); }, onDomMouseDown: function(param, elem, evt) { var me = this; // find data var topPath = this.data(); var data = this.findNode(topPath,param); jAppML.utils.dragObject(data); //this.fireEvent('Click', this.data()[param]); }, onDomNodeContext: function(param, elem, evt) { var me = this; // find data var topPath = this.data(); var data = this.findNode(topPath,param); me.fireEvent('ItemContext', {data:data, evt:evt}); //jAppML.utils.context(evt, [{cssClass:'icon_rename', text:T('gui_rename')},{cssClass:'icon_delete', text:T('gui_delete')}]); return false; }, renderPath: function(path, level) { var out = []; var expanded = this._expandedNodes[path.Id]; if (typeof expanded == 'undefined' && level == 0) expanded = true; var selected = this.params.selectedNode == path.Id; if (!level) level = 0; out.push(''); for(var i = 0; i < level; i++) { out.push(''); } if (path.Paths.length > 0) { if (expanded) { out.push(''); } else { out.push(''); } } else { out.push(''); } if (selected) out.push(''); out.push('
    '); else out.push(''); out.push(path.Name); out.push('
'); if (expanded) { if (path.Paths) { for(var i in path.Paths) { out.push(this.renderPath(path.Paths[i], level +1)); } } } return out.join(''); }, renderContents: function() { var out = []; if (this.params.data) { out.push(this.renderPath(this.params.data, 0)); out.push('
'); out.push(''); out.push(''); } else { out.push('...loading'); } return out.join(''); }, data: function(value) { if (typeof(value) !== 'undefined') { if (this.params.data != value) { this.params.data = value; this.invalidate(true); this.fireEvent('DataChanged'); } } else return this.params.data; }, selectedNode: function(value) { if (typeof(value) !== 'undefined') { if (this.params.selectedNode != value) { this.params.selectedNode = value; this.invalidate(true); this.fireEvent('SelectedNodeChanged', value); } } else return this.params.selectedNode; } });jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.BigButton = jAppML.controls.LinkButton.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.fixedClass = "jmlInput jmlCssButton epdBigButton"; }, renderContents: function() { var out = []; out.push('
'); out.push(''); out.push('
'); out.push('
'); out.push('
' + this._super() + '
'); out.push('
'); out.push('
' + this.params.description + '
'); out.push('
'); return out.join(''); }, description: function(value) { if (typeof(value) !== 'undefined') { if (this.params.description != value) { this.params.description = value; this.invalidate(true); this.fireEvent('DescriptionChanged'); } } else return this.params.description; } }); oculos.epd2.BigButton2 = jAppML.controls.LinkButton.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.fixedClass = "jmlInput jmlCssButton epdBigButton"; }, renderContents: function() { var out = []; out.push('
'); out.push('
' + this._super() + '
'); out.push('
'); return out.join(''); } }); jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.BreadCrumbs = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, "div"); this.fixedClass = "epdBreadCrumbs"; }, renderContents: function() { var out = []; //alert(JSON.stringify(this.namingContainer)); if (!this.pageHandler) { this.pageHandler = window.pageHandler; this.pageHandler.registerEventHandler("IndexChange", this, this.onIndexChange); } var index = this.pageHandler.index(); out.push('' + this.params.caption + ''); for(var i = 0; i < this.pageHandler.children.length; i++) { if (i <= index) { var page = this.pageHandler.children[i]; var cssClass = ""; if (i == index) cssClass = "active"; out.push(''); out.push(page.title()); out.push(''); if (i != index) out.push(' > '); } else { break; } } return out.join(''); }, onItemClick: function(i) { this.pageHandler.index(i); }, onIndexChange: function() { this.invalidate(true); this.fireEvent("IndexChange"); } }); oculos.epd2.Browser = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlBrowser"; if (typeof(this.params.mode) == 'undefined') this.params.mode = "details"; if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); this.itemClass = eval(this.params.itemClass); var me = this; if (this.params.maxCount) this.params.maxCount = parseInt('' + this.params.maxCount); this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); this._dataSource.registerEventHandler("DataChange", this, this.onDataChange); }, onDataChange: function() { var me = this; this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); }, prepareAttributes: function() { this._super(); }, onDomHeaderClick: function(param, elem) { var me = this; var oldSort = this.sort(); var newSort = []; var tempSort = this.params.columnSettings[param].sort; for(var i in tempSort) { newSort.push(tempSort[i]); } var isSameSort = me._dataSource.compareSortKeys(oldSort, newSort); if (isSameSort) { for(var i in newSort) { if (newSort[i].direction == 'asc') newSort[i].direction = 'desc'; else newSort[i].direction = 'asc'; } } this.params.data = null; this.sort(newSort); this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); }, onDomHeaderMouseOver: function(param, elem) { elem.className = 'hover'; }, onDomHeaderMouseOut: function(param, elem) { elem.className = ''; }, onDomCellMouseOver: function(param, elem) { elem.parentNode.className = 'hover'; }, onDomCellMouseOut: function(param, elem) { elem.parentNode.className = ''; }, onDomThumbMouseOver: function(param, elem) { elem.className = 'thumbdiv thumbdiv_hover'; }, onDomThumbMouseOut: function(param, elem) { elem.className = 'thumbdiv'; }, onDomCellClick: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { me.fireEvent('Click', data); }); //this.fireEvent('Click', this.data()[param]); }, onDomMouseDown: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { jAppML.utils.dragObject(data); }); //this.fireEvent('Click', this.data()[param]); }, onDomCellContext: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { me.fireEvent('ItemContext', {data:data, evt:evt, index:parseInt(param, 10)}); }); //jAppML.utils.context(evt, [{cssClass:'icon_rename', text:T('gui_rename')},{cssClass:'icon_delete', text:T('gui_delete')}]); return false; }, renderContents: function() { var out = []; var me = this; var mode = this.mode(); var oldSort = this.sort(); if (mode == "details") { out.push(''); for(var i in this.params.columnSettings) { out.push(''); } out.push(''); } else if (mode == "thumbs") { } if (this.data()) { var data = this.data(); for(var y in data) { if (this.params.maxCount) { if (y>= this.params.maxCount) break; } if (mode == "details") { out.push(''); for(var x in this.params.columnSettings) { out.push(''); } out.push(''); } else if (mode == "thumbs") { // out.push('
'); // // if (data[y].HasUpdates) { // out.push('
'); // } // // out.push('
'); if (oldSort) { if (this._dataSource.compareSortKeys(this.params.columnSettings[i].sort, oldSort)) { out.push('
'); } } var headerKey = this.params.columnSettings[i].header; if (!headerKey) headerKey = this._dataSource.getHeaderForProperty(this.params.columnSettings[i].property); if (!headerKey) headerKey = this._dataSource.getHeaderForProperty(this.params.columnSettings[i].eval); out.push(T(headerKey)); out.push('
'); var expr = this.params.columnSettings[x].eval; if (!expr) expr = this.params.columnSettings[x].property; with(data[y]) { out.push(eval(expr)); } out.push('
'); // // var thumbField = this.params.thumbField; // var thumbId = (data[y])[thumbField]; // if (thumbId) { // // out.push(''); // } // else out.push('
' + (this.params.thumbMissingText ? this.params.thumbMissingText : '') + '
'); // // out.push('
'); // // var expr = this.params.textField; // if (!expr) expr = "Id"; // with(data[y]) { // out.push(eval(expr)); // } // // out.push('
'); // // // out.push('
'); var text = ''; var expr = this.params.textField; if (!expr) expr = "Id"; with(data[y]) { text = eval(expr); } var desc = ''; if (this.params.descFunction) { desc = this.namingContainer[this.params.descFunction].call(this.namingContainer,data[y]); } else { expr = this.params.descField; if (!expr) expr = "Id"; with(data[y]) { desc = eval(expr); } } var thumb = ''; expr = this.params.thumbField; if (!expr) expr = "Thumb"; with(data[y]) { thumb = eval(expr); } //var realData = data[y]; var itemCtrl = new this.itemClass({commandParams:y,text:text,description:desc,thumb:thumb,navType:this.params.navType,selType:this.params.selType}); var func = function(param) { me.onDomCellClick('' + param); }; itemCtrl.registerEventHandler("Click", this, func); out.push(itemCtrl.render()); } } if (data.length == 0) { if (mode == "details") out.push('
' + this.params.noItemsText + '
'); else out.push('
' + this.params.noItemsText + '
'); } } else { if (mode == "details") out.push('
'); else out.push('
'); } if (mode == "details") { out.push(''); } else if (mode == "thumbs") { if (data) { if (data.length > 0) { out.push(''); out.push('
'); } } } return out.join(''); }, mode: function(value) { if (typeof(value) !== 'undefined') { if (this.params.mode != value) { this.params.mode = value; this.invalidate(true); this.fireEvent('ModeChanged'); } } else return this.params.mode; }, data: function(value) { if (typeof(value) !== 'undefined') { if (this.params.data != value) { this.params.data = value; this.invalidate(true); this.fireEvent('DataChanged'); } } else return this.params.data; }, sort: function(value) { if (typeof(value) !== 'undefined') { if (this.params.sort != value) { this.params.sort = value; this.invalidate(true); this.fireEvent('SortChanged'); } } else return this.params.sort; }, refreshDatasource: function() { this._dataSource.refresh(); }, search: function(value) { if (typeof(value) !== 'undefined') { if (this.params.search != value) { this.params.search = value; this.invalidate(true); var me = this; this._dataSource.getAll(this.sort(), value, function(sort, search2, data) { me.sort(sort); me.data(data); }); //this.fireEvent('SearchChanged'); } } else return this.params.search; }, saveObject: function(obj, callback) { this._dataSource.saveObject(obj, callback); }, deleteObject: function(obj, callback) { this._dataSource.deleteObject(obj, callback); }, addSavedObject: function(obj, callback) { this._dataSource.addSavedObject(obj, callback); }, removeDeletedObject: function(obj, callback) { this._dataSource.removeDeletedObject(obj, callback); }, renameObject: function(obj, newName, callback) { this._dataSource.renameObject(obj, newName, callback); }, moveObject: function(obj, newpath, callback) { this._dataSource.moveObject(obj, newpath, callback); }, getObjectTemplate: function(callback) { this._dataSource.getObjectTemplate(callback); } });oculos.epd2.Browser2 = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "jmlBrowser"; if (typeof (this.params.mode) == 'undefined') this.params.mode = "details"; if (typeof (this.params.displayPanel) == 'undefined') this.params.displayPanel = true; else { this.params.displayPanel = (('' + this.params.displayPanel).toLowerCase() == 'true'); } if (typeof (this.params.displaySearch) == 'undefined') this.params.displaySearch = false; else { this.params.displaySearch = (('' + this.params.displaySearch).toLowerCase() == 'true'); } if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); this.itemClass = eval(this.params.itemClass); this._selection = []; var me = this; if (this.params.maxCount) this.params.maxCount = parseInt('' + this.params.maxCount); this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); this._dataSource.registerEventHandler("DataChange", this, this.onDataChange); this.searchTextControl = new jAppML.controls.NewTextBox({ displaySearchIcon: true, onTextChange: function() { me.search([{ key: me.params.searchKey, op: me.params.searchOp, param1: me.searchTextControl.text()}]); } }, {}, this); }, // onRendered: function() { // if (this.searchTextControl) this.searchTextControl.restoreCaret(); // }, onDataChange: function() { var me = this; this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); }, prepareAttributes: function() { this._super(); }, onDomHeaderClick: function(param, elem) { var me = this; var oldSort = this.sort(); var newSort = []; var tempSort = this.params.columnSettings[param].sort; for (var i in tempSort) { newSort.push(tempSort[i]); } var isSameSort = me._dataSource.compareSortKeys(oldSort, newSort); if (isSameSort) { for (var i in newSort) { if (newSort[i].direction == 'asc') newSort[i].direction = 'desc'; else newSort[i].direction = 'asc'; } } this.params.data = null; this.sort(newSort); this._selectedControls = []; this._dataSource.getAll(this.sort(), this.search(), function(sort, search, data) { me.sort(sort); me.data(data); }); }, onDomHeaderMouseOver: function(param, elem) { elem.className = 'hover'; }, onDomHeaderMouseOut: function(param, elem) { elem.className = ''; }, onDomCellMouseOver: function(param, elem) { elem.parentNode.className = 'hover'; }, onDomCellMouseOut: function(param, elem) { elem.parentNode.className = ''; }, onDomThumbMouseOver: function(param, elem) { elem.className = 'thumbdiv thumbdiv_hover'; }, onDomThumbMouseOut: function(param, elem) { elem.className = 'thumbdiv'; }, onDomCellClick: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { me.fireEvent('Click', data); }); //this.fireEvent('Click', this.data()[param]); }, onDomMouseDown: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { jAppML.utils.dragObject(data); }); //this.fireEvent('Click', this.data()[param]); }, onDomCellContext: function(param, elem, evt) { var me = this; this._dataSource.getByIndex(this.sort(), this.search(), parseInt(param, 10), function(sort, search, data) { me.fireEvent('ItemContext', { data: data, evt: evt, index: parseInt(param, 10) }); }); //jAppML.utils.context(evt, [{cssClass:'icon_rename', text:T('gui_rename')},{cssClass:'icon_delete', text:T('gui_delete')}]); return false; }, renderInside: function() { var out = []; var me = this; var mode = this.mode(); var oldSort = this.sort(); if (mode == "details") { out.push(''); for (var i in this.params.columnSettings) { out.push(''); } out.push(''); } if (this.data()) { var data = this.data(); if (mode == "thumbs") { if (data) { if (data.length > 0) { if (this.params.maxHeight) { var fixHeight = parseInt(this.params.maxHeight); out.push('
'); } } } } for (var y in data) { if (this.params.maxCount) { if (y >= this.params.maxCount) break; } if (mode == "details") { out.push('
'); for (var x in this.params.columnSettings) { out.push(''); } out.push(''); } else if (mode == "thumbs") { // out.push('
'); // // if (data[y].HasUpdates) { // out.push('
'); // } // // out.push('
'); if (oldSort) { if (this._dataSource.compareSortKeys(this.params.columnSettings[i].sort, oldSort)) { out.push('
'); } } var headerKey = this.params.columnSettings[i].header; if (!headerKey) headerKey = this._dataSource.getHeaderForProperty(this.params.columnSettings[i].property); if (!headerKey) headerKey = this._dataSource.getHeaderForProperty(this.params.columnSettings[i].eval); out.push(T(headerKey)); out.push('
'); var expr = this.params.columnSettings[x].eval; if (!expr) expr = this.params.columnSettings[x].property; with (data[y]) { out.push(eval(expr)); } out.push('
'); // // var thumbField = this.params.thumbField; // var thumbId = (data[y])[thumbField]; // if (thumbId) { // // out.push(''); // } // else out.push('
' + (this.params.thumbMissingText ? this.params.thumbMissingText : '') + '
'); // // out.push('
'); // // var expr = this.params.textField; // if (!expr) expr = "Id"; // with(data[y]) { // out.push(eval(expr)); // } // // out.push('
'); // // // out.push(''); //var realData = data[y]; var itemCtrl = new this.itemClass({ commandParams: y, data: data[y], navType: this.params.navType, selType: this.params.selType }); //this._selectedControls[data[y].Id] = itemCtrl; var func = function(param) { me.onDomCellClick('' + param); if (me.params.allowSelection) { this.selected(!this.selected()); me._selection[this.params.data.Id] = this.selected(); } }; itemCtrl.registerEventHandler("Click", itemCtrl, func); out.push(itemCtrl.render()); } } if (data.length == 0) { if (mode == "details") out.push('
' + this.params.noItemsText + '
'); else out.push('
' + this.params.noItemsText + '
'); } } else { if (mode == "details") out.push('
'); else out.push('
'); } if (mode == "details") { out.push(''); } else if (mode == "thumbs") { if (data) { if (data.length > 0) { if (this.params.maxHeight) { out.push(''); } out.push(''); out.push('
'); } } } return out.join(''); }, selectionIds: function() { var result = []; for (var i in this._selection) { if (this._selection[i]) result.push({ Id: i }); } return result; }, selection: function() { var result = []; var hash = []; var data = this.data(); for (var i in data) { hash[data[i].Id] = data[i]; } for (var i in this._selection) { if (this._selection[i] && hash[i]) result.push(hash[i]); } return result; }, renderContents: function() { var out = []; if (this.displayPanel()) { out.push('
'); out.push('
'); out.push('
'); out.push(this.panelHeader()); out.push('
'); if (this.displaySearch()) out.push(this.searchTextControl.render()); out.push('
'); out.push('
'); } out.push(this.renderInside()); if (this.displayPanel()) { out.push('
'); out.push('
'); } return out.join(''); }, mode: function(value) { if (typeof (value) !== 'undefined') { if (this.params.mode != value) { this.params.mode = value; this.invalidate(true); this.fireEvent('ModeChanged'); } } else return this.params.mode; }, displayPanel: function(value) { if (typeof (value) !== 'undefined') { if (this.params.displayPanel != value) { this.params.displayPanel = value; this.invalidate(true); this.fireEvent('DisplayPanelChanged'); } } else return this.params.displayPanel; }, displaySearch: function(value) { if (typeof (value) !== 'undefined') { if (this.params.displaySearch != value) { this.params.displaySearch = value; this.invalidate(true); this.fireEvent('DisplaySearchChanged'); } } else return this.params.displaySearch; }, panelClass: function(value) { if (typeof (value) !== 'undefined') { if (this.params.panelClass != value) { this.params.panelClass = value; this.invalidate(true); this.fireEvent('PanelClassChanged'); } } else return this.params.panelClass; }, panelHeader: function(value) { if (typeof (value) !== 'undefined') { if (this.params.panelHeader != value) { this.params.panelHeader = value; this.invalidate(true); this.fireEvent('PanelHeaderChanged'); } } else return this.params.panelHeader; }, data: function(value) { if (typeof (value) !== 'undefined') { if (this.params.data != value) { this.params.data = value; try { var inside = document.getElementById(this.domId + '_dp'); inside.innerHTML = this.renderInside(); this.invalidate(false); } catch (ex) { this.invalidate(true); } this.fireEvent('DataChanged'); } } else return this.params.data; }, sort: function(value) { if (typeof (value) !== 'undefined') { if (this.params.sort != value) { this.params.sort = value; try { var inside = document.getElementById(this.domId + '_dp'); inside.innerHTML = this.renderInside(); this.invalidate(false); } catch (ex) { this.invalidate(true); } this.fireEvent('SortChanged'); } } else return this.params.sort; }, refreshDatasource: function() { this._dataSource.refresh(); }, search: function(value) { if (typeof (value) !== 'undefined') { if (this.params.search != value) { this.params.search = value; var me = this; me.data([]); try { var inside = document.getElementById(this.domId + '_dp'); inside.innerHTML = this.renderInside(); this.invalidate(false); } catch (ex) { this.invalidate(true); } this.fireEvent('SearchChanged'); this._dataSource.getAll(this.sort(), value, function(sort, search2, data) { me.sort(sort); me.data(data); }); // } } else return this.params.search; }, saveObject: function(obj, callback) { this._dataSource.saveObject(obj, callback); }, deleteObject: function(obj, callback) { this._dataSource.deleteObject(obj, callback); }, addSavedObject: function(obj, callback) { this._dataSource.addSavedObject(obj, callback); }, removeDeletedObject: function(obj, callback) { this._dataSource.removeDeletedObject(obj, callback); }, renameObject: function(obj, newName, callback) { this._dataSource.renameObject(obj, newName, callback); }, moveObject: function(obj, newpath, callback) { this._dataSource.moveObject(obj, newpath, callback); }, getObjectTemplate: function(callback) { this._dataSource.getObjectTemplate(callback); }, onRendered: function(once) { var me = this; if (this.params.maxHeight) { var dom = document.getElementById(this.domId + "_fixheight"); //alert('check'); if (dom) { var fixHeight = parseInt(this.params.maxHeight); //alert(fixHeight); var realHeight = $(dom).height(); //alert(realHeight); if (realHeight > fixHeight) dom.style.height = fixHeight + 'px'; } else { if (once != 1) { if (!once) once = 50; setTimeout(function() { me.onRendered(once); }, 200); } } } } });jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.BrowserItem = jAppML.controls.LinkButton.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.fixedClass = "epdItem epdItemSmall"; this.params.selected = (this.params.selected == "true" || this.params.selected == "True" || this.params.selected == "TRUE" || this.params.selected === true); this.params.allowSelect = (this.params.allowSelect == "true" || this.params.allowSelect == "True" || this.params.allowSelect == "TRUE" || this.params.allowSelect === true); this.params.allowMultiSelect = (this.params.allowMultiSelect == "true" || this.params.allowMultiSelect == "True" || this.params.allowMultiSelect == "TRUE" || this.params.allowMultiSelect === true); if (!this.params.selType) this.params.selType = 'Pos'; }, renderBeginTag: function() { var out = []; out.push(this._super()); out.push('
'); out.push('
'); return out.join(''); }, renderEndTag: function() { var out = []; out.push('
'); out.push('
'); out.push(this._super()); return out.join(''); }, renderContents: function() { return this.renderChildren(); }, selected: function(value) { if (typeof(value) !== 'undefined') { if (this.params.selected != value) { this.params.selected = value; try { if (value) { $('#' + this.domId + '_table').addClass("sel" + this.params.selType); } else { $('#' + this.domId + '_table').removeClass("sel" + this.params.selType); } } catch (ex) {} this.invalidate(); this.fireEvent('SelectedChange'); } } else { if (typeof(this.params.selected) === 'undefined') this.params.selected = false; return this.params.selected; } }, domOnClick: function(param, domElement) { this.fireEvent('Click',this.params.commandParams); if (this.params.allowSelect || this.params.allowMultiSelect) this.selected(!this.selected()); }, data: function(value) { if (typeof(value) !== 'undefined') { if (this.params.data != value) { this.params.data = value; this.invalidate(true); this.fireEvent('DataChanged'); } } else return this.params.data; } }); jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.Button = jAppML.controls.CssButton.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.fixedClass = "jmlInput jmlCssButton epdButton"; } }); jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.ChangeLanguageSelector = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, "div"); this.fixedClass = "epdChangeLanguageSelector"; }, onLangClick: function(code) { setCookie("epdlang", code); document.location.href = "LogOn.aspx"; }, activeLanguage: function() { return language; }, renderContents: function() { var out = []; var activeLanguge = this.activeLanguage(); for(var i in languages) { var lang = languages[i]; var actClass = " lang_" + (activeLanguge == lang.Code ? "act" : "inact"); out.push(''); } return out.join(''); } });jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.CurrentPageTitle = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, "span"); }, renderContents: function() { var out = []; //alert(JSON.stringify(this.namingContainer)); if (!this.pageHandler) { this.pageHandler = window.pageHandler; this.pageHandler.registerEventHandler("IndexChange", this, this.onIndexChange); } var index = this.pageHandler.index(); out.push(this.pageHandler.children[index].title()); return out.join(''); }, onIndexChange: function() { this.invalidate(true); this.fireEvent("IndexChange"); } }); jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.SmallItem = jAppML.controls.LinkButton.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.fixedClass = "epdItem epdItemSmall"; this.params.selected = (this.params.selected == "true" || this.params.selected == "True" || this.params.selected == "TRUE" || this.params.selected === true); this.params.allowSelect = (this.params.allowSelect == "true" || this.params.allowSelect == "True" || this.params.allowSelect == "TRUE" || this.params.allowSelect === true); this.params.allowMultiSelect = (this.params.allowMultiSelect == "true" || this.params.allowMultiSelect == "True" || this.params.allowMultiSelect == "TRUE" || this.params.allowMultiSelect === true); if (!this.params.selType) this.params.selType = 'Pos'; }, renderContents: function() { var out = []; out.push('
'); out.push('
'); if (this.thumb()) out.push(''); out.push('
' + this.text() + '
' + this.description() + '
'); out.push('
'); return out.join(''); }, selected: function(value) { if (typeof(value) !== 'undefined') { if (this.params.selected != value) { this.params.selected = value; try { if (value) { $('#' + this.domId + '_table').addClass("sel" + this.params.selType); } else { $('#' + this.domId + '_table').removeClass("sel" + this.params.selType); } } catch (ex) {} this.invalidate(); this.fireEvent('SelectedChange'); } } else { if (typeof(this.params.selected) === 'undefined') this.params.selected = false; return this.params.selected; } }, domOnClick: function(param, domElement) { this.fireEvent('Click',this.params.commandParams); if (this.params.allowSelect || this.params.allowMultiSelect) this.selected(!this.selected()); }, description: function(value) { if (typeof(value) !== 'undefined') { if (this.params.description != value) { this.params.description = value; this.invalidate(true); this.fireEvent('DescriptionChange'); } } else return this.params.description; }, thumb: function(value) { if (typeof(value) !== 'undefined') { if (this.params.thumb != value) { this.params.thumb = value; this.invalidate(true); this.fireEvent('ThumbChange'); } } else return this.params.thumb; } }); oculos.epd2.NewsItem = oculos.epd2.SmallItem.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.fixedClass = "epdItem newsItem"; } }); oculos.epd2.DocChangeItem = oculos.epd2.SmallItem.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.fixedClass = "epdItem docChangeItem"; } }); jAppML.controls.NewTextBox = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this._text = this.params.text ? this.params.text : ''; //this.attributes['type'] = 'text'; this.fixedClass = "jmlInput jmlNewTextBox"; this._hasFocus = false; this.delayedActive = false; this._calcHeight = null; if (!this.params.ghost) this.params.ghost = ''; if (!this.params.innerClass) this.params.innerClass = ''; if (typeof (this.params.multiLine) == 'undefined') this.params.multiLine = false; else { this.params.multiLine = (('' + this.params.multiLine).toLowerCase() == 'true'); } if (typeof (this.params.displaySearchIcon) == 'undefined') this.params.displaySearchIcon = false; else { this.params.displaySearchIcon = (('' + this.params.displaySearchIcon).toLowerCase() == 'true'); } }, innerClass: function(value) { if (typeof (value) !== 'undefined') { if (this.params.innerClass != value) { this.params.innerClass = value; try { document.getElementById(this.domId + '_ta').className = value; this.invalidate(false); } catch (ex) { this.invalidate(true); } this.fireEvent('ThumbChange'); } } else return this.params.innerClass; }, prepareAttributes: function() { this.validate(true); if (this.state() == "error") { this.fixedClass = "jmlInput jmlNewTextBox jmlNewTextBox_error"; } else this.fixedClass = "jmlInput jmlNewTextBox"; this._super(); }, state: function(value, init) { if (typeof (value) !== 'undefined') { if (this.params.state != value) { this.params.state = value; this.invalidate(); if (!init) { if (value == 'error') { $('#' + this.domId).addClass('jmlNewTextBox_error'); if (this._hasFocus) $('#' + this.domId).addClass('jmlNewTextBox_error_focus'); } else { $('#' + this.domId).removeClass('jmlNewTextBox_error'); $('#' + this.domId).removeClass('jmlNewTextBox_error_focus'); } this.fireEvent('StateChange'); } } } else return this.params.state; }, validate: function(init) { var text = this.text(); if (!text) text = ''; if (text.indexOf("rune dahl") >= 0) { this.state('error', init); } else this.state(''); }, delayedCount: function() { this.delayedCounter -= 1; if (this.delayedCounter <= 0) { clearInterval(this.delayedId); this.delayedActive = false; if (this.text() != this.delayedValue) { this.fireEvent('TextDelayedChange'); this.fireEvent('ValueDelayedChange'); } } }, text: function(value) { if (typeof (value) !== 'undefined') { if (value == null) value = ''; value = '' + value; var me = this; if (this._text != value) { this.delayedCounter = 1; if (!this.delayedActive) { this.delayedActive = true; this.delayedValue = this._text; this.delayedId = setInterval(function() { me.delayedCount(); }, 200); } else { } this._text = value; try { document.getElementById(this.domId + '_ta').value = value; } catch (ex) { } try { document.getElementById(this.domId + '_ghost').innerHTML = (value ? '' : this.ghost()); } catch (ex) { } this._calcHeight = null; this.invalidate(); this.fireEvent('TextChange'); this.fireEvent('ValueChange'); this.validate(); } } else return this._text ? this._text : ''; }, multiLine: function(value) { if (typeof (value) !== 'undefined') { if (this.params.multiLine != value) { this.params.multiLine = value; this.invalidate(); this.fireEvent('MultiLineChange'); } } else return this.params.multiLine; }, displaySearchIcon: function(value) { if (typeof (value) !== 'undefined') { if (this.params.displaySearchIcon != value) { this.params.displaySearchIcon = value; this.invalidate(); this.fireEvent('DisplaySearchIconChange'); } } else return this.params.displaySearchIcon; }, ghost: function(value) { if (typeof (value) !== 'undefined') { if (value == null) value = ''; if (this.params.ghost != value) { this.params.ghost = value; try { document.getElementById(this.domId + '_ghost').innerHTML = (this._text ? '' : this.params.ghost); } catch (ex) { } this.invalidate(); this.fireEvent('GhostChange'); } } else { if (this.params.ghost == 'undefined') return ''; return this.params.ghost ? this.params.ghost : ''; } }, renderScriptDelayContents: function() { return this.renderEventlessCallback("domResize", {}); }, renderContents: function() { var out = []; out.push('
'); out.push('
'); var ctrlType = 'input'; var multiLine = this.multiLine(); if (multiLine) ctrlType = 'textarea'; out.push('
' + (this.displaySearchIcon() ? '
' : '') + '
'); out.push('
' + (this._text ? '' : this.ghost()) + '
'); out.push('<' + ctrlType + ' type="' + (this.params.password ? 'password' : 'text') + '" class="' + this.innerClass() + '" id="' + this.domId + '_ta" onchange="' + this.renderCallback('domOnChange', null) + '" onkeyup="' + this.renderCallback('domOnKeyUp', null) + '" onkeydown="' + (multiLine ? '' : 'if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) return false;') + this.renderCallback('domOnKeyDown', null) + '" onfocus="' + this.renderCallback('domOnFocus', null) + '" onblur="' + this.renderCallback('domOnBlur', null) + '" onmouseover="' + this.renderCallback('domOnMouseOver', null) + '" onmouseout="' + this.renderCallback('domOnMouseOut', null) + (multiLine ? '' : ('" value="' + (this._text ? this._text : ""))) + // fiks koding '" style="' + (this._calcHeight ? 'height:' + (this._calcHeight + ';') : '') + (this.params.textAlign ? ('text-align:' + this.params.textAlign + ';') : '') + '" ' + (multiLine ? '' : '/') + '>'); if (multiLine) out.push(this._text ? this._text : ""); if (multiLine) out.push(''); out.push('
'); out.push('
'); return out.join(''); }, value: function(value) { return this.text(value); }, clear: function() { this.text(""); }, focus: function(value) { document.getElementById(this.domId + '_ta').focus(); }, select: function(value) { document.getElementById(this.domId + '_ta').select(); }, domOnFocus: function(param, domElement) { $('#' + this.domId).removeClass('jmlNexTextBox_hover'); $('#' + this.domId).removeClass('jmlNexTextBox_error_hover'); $('#' + this.domId).addClass('jmlNewTextBox_focus'); if (this.state() == "error") $('#' + this.domId).addClass('jmlNewTextBox_error_focus'); this._hasFocus = true; this.fireEvent("Focus"); }, domOnBlur: function(param, domElement) { $('#' + this.domId).removeClass('jmlNewTextBox_hover'); $('#' + this.domId).removeClass('jmlNewTextBox_error_hover'); $('#' + this.domId).removeClass('jmlNewTextBox_focus'); $('#' + this.domId).removeClass('jmlNewTextBox_error_focus'); this._hasFocus = false; this.fireEvent('Blur'); }, domOnMouseOver: function(param, domElement) { if (!this._hasFocus) { $('#' + this.domId).addClass('jmlNewTextBox_hover'); if (this.state() == "error") $('#' + this.domId).addClass('jmlNewTextBox_error_hover'); } }, domOnMouseOut: function(param, domElement) { $('#' + this.domId).removeClass('jmlNewTextBox_hover'); $('#' + this.domId).removeClass('jmlNewTextBox_error_hover'); }, domOnChange: function(param, domElement) { this.text(domElement.value); }, domResize: function() { if (this._calcHeight) return; if (this.params.NoAutoHeight) return; var el = document.getElementById(this.domId + '_ta'); if (el) { if (!jQuery.browser.msie) el.style.height = 0; this._calcHeight = el.scrollHeight + "px"; el.style.height = this._calcHeight; } }, domOnKeyUp: function(param, domElement, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; var ctrlKey = evt.ctrlKey; var me = this; this._calcHeight = null; if (this.multiLine()) this.domResize(); var pos = doGetCaretPosition(domElement); this._caretPos = pos; if (this._text != domElement.value) { this.delayedCounter = 3; if (!this.delayedActive) { this.delayedActive = true; this.delayedValue = this._text; this.delayedId = setInterval(function() { me.delayedCount(); }, 200); } else { } this._text = domElement.value; try { document.getElementById(this.domId + '_ghost').innerHTML = (this._text ? '' : this.ghost()); } catch (ex) { } this.fireEvent('TextChange'); this.fireEvent('ValueChange'); this.invalidate(false); this.validate(); } this.fireEvent('KeyUp', { keyCode: keyCode, shiftKey: shiftKey, ctrlKey:ctrlKey }); }, restoreCaret: function() { var me = this; // setTimeout(function() { var el = document.getElementById(me.domId + '_ta'); if (el) try { setCaretPosition(el, (me._caretPos ? me._caretPos : 0)); } catch (ex) { }; // },100); }, domOnKeyDown: function(param, elem, evt) { var keyCode = evt.keyCode ? evt.keyCode : evt.which; var shiftKey = evt.shiftKey; var me = this; if (keyCode == 9) { evt.cancelBubble = true; if (shiftKey) this.fireEvent('MoveLeft'); else this.fireEvent('MoveRight'); } // else if (keyCode == 13) { // evt.cancelbubble = true; // evt.returnvalue = false; // return false; // // } else if ((keyCode == 37 || keyCode == 39) && !shiftKey) { var sel = false; if (document.selection) { if (document.selection.createRange().duplicate().text != '') sel = true; } else { if (elem.selectionStart != elem.selectionEnd) sel = true; } if (sel) { if (elem.selectionEnd) { var newpos = 0; if (keyCode == 37) newpos = elem.selectionStart + 1; if (keyCode == 39) newpos = elem.selectionEnd - 1; if (newpos < 0) newpos = 0; if (newpos > elem.value.length) newpos = elem.value.length; setCaretPosition(elem, newpos); } return; } var pos = doGetCaretPosition(elem); if (keyCode == 37 && pos == 0) { var evt2 = { keyCode: 9, shiftKey: true }; this.domOnKeyDown(param, elem, evt2); return; } else if (keyCode == 39 && pos == elem.value.length) { var evt2 = { keyCode: 9, shiftKey: false }; this.domOnKeyDown(param, elem, evt2); return; } } else if ((keyCode == 40 || keyCode == 38) && !shiftKey) { var sel = false; if (document.selection) { if (document.selection.createRange().duplicate().text != '') sel = true; } else { if (elem.selectionStart != elem.selectionEnd) sel = true; } if (sel) { if (elem.selectionEnd) { var newpos = 0; if (keyCode == 38) { //newpos = elem.selectionStart+1; this.fireEvent("MoveUp"); return; } if (keyCode == 40) { //newpos = elem.selectionEnd-1 this.fireEvent("MoveDown"); return; } if (newpos < 0) newpos = 0; if (newpos > elem.value.length) newpos = elem.value.length; setCaretPosition(elem, newpos); } return; } var pos = doGetCaretPosition(elem); if (keyCode == 38 && pos == 0) { this.fireEvent("MoveUp"); return; } else if (keyCode == 40 && pos == elem.value.length) { this.fireEvent("MoveDown"); return; } } }, display: function(value) { return jAppML.controls.NewTextBox.display(value); } }); jAppML.controls.NewPasswordBox = jAppML.controls.NewTextBox.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.params.password= true; } }); jAppML.controls.NewTextBox.display = function(value) { if (value) return value.replace("\n", "
", "g"); else return " "; }; jAppML.controls.NewPasswordBox.display = function(value) { if (value) return value.replace("\n", "
", "g"); else return " "; }; jAppML.controls.NewTextBoxMultiline = jAppML.controls.NewTextBox.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent); this.params.multiLine= true; } }); jAppML.controls.NewTextBoxMultiline.display = function(value) { if (value) return value.replace("\n", "
", "g"); else return " "; }; jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.ObjectBar = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdObjectBar"; }, renderContents: function() { var out = []; if (this.displaySave()) out.push(this.renderButton(T('gui_save'), 'smallicon_save', 'SaveClick')); if (this.displayDelete()) out.push(this.renderButton(T('gui_delete'), 'smallicon_delete', 'DeleteClick')); return out.join(''); }, renderButton: function(text, icon, event) { var out = []; out.push('
' + text + '
'); return out.join(''); }, domMouseDown: function(param) { this.startHold = new Date(); }, domClick: function(param) { var now = new Date(); var ms = (now.getTime() - this.startHold.getTime()); var hold = (ms > 400); this.fireEvent(param, hold); }, displaySave: function(value) { if (typeof (value) !== 'undefined') { if (this.params.displaySave != value) { this.params.displaySave = value; this.invalidate(true); this.fireEvent('DisplaySaveChange'); } } else return this.params.displaySave; }, displayDelete: function(value) { if (typeof (value) !== 'undefined') { if (this.params.displayDelete != value) { this.params.displayDelete = value; this.invalidate(true); this.fireEvent('DisplayDeleteChange'); } } else return this.params.displayDelete; } }); jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.ObjectBrowserGetIconClass = function(id) { var iconclass = ''; if (id == 'e43432e7-f81f-43fa-a772-55c644aacd9b') iconclass = 'car'; else if (id == '25bf2a7a-ef7e-4956-99e9-506c9e411818') iconclass = 'eq'; else if (id == 'df658419-c05b-4183-a4e2-49076e4956d8') iconclass = 'eq'; else if (id == '9291a5a1-b82a-4c3a-b3f3-db280aa60e15') iconclass = 'car'; else if (id == 'd7a4db4d-2013-47e3-81fb-378ae0edc25a') iconclass = 'eq'; else if (id == 'ea1c41c6-22f4-4992-807d-928e04e15e51') iconclass = 'cat'; else if (id == 'f15c4ca1-5729-4b51-9b6b-b82a16cb8516') iconclass = 'cat'; else if (id == '8b438735-0a31-44b6-9315-01fa28be59be') iconclass = 'trimlevel'; else if (id == '31b2d775-fe5a-4d51-bcd0-99629d874e6b') iconclass = 'info'; else if (id == 'f1e24006-4395-4948-a50b-cbb4ec5c596c') iconclass = 'camp'; return iconclass; }; oculos.epd2.ObjectBrowser = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdObjectBrowser"; this.ctrlById = {}; this.selectionIds = {}; this.sorted = false; if (!this.params.classFilter) this.params.classFilter = []; this._baseFilter = false; this._selection = false; }, selection: function() { if (!this._selection) this._getSelection(); return this.params.selection; }, _getSelection: function() { this.params.selection = []; var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; for (var g in this.textFiltered) { var group = this.textFiltered[g]; var drawnGroup = false; for (var i in group) { var index = group[i]; var item = data[index]; if (item) { var ctrl = this.ctrlById[item.Id]; if (ctrl) { if (ctrl.selected()) { this.params.selection.push(ctrl.item); } } } } } this._selection = true; }, onObjectsRemoved: function() { this._baseFilter = false; this.invalidateChildrenNext = true; this.invalidate(true); this.fireEvent('Redraw'); }, onObjectAdd: function(p) { if (this.domId != p.domId) { var classes = this.classFilter(); var refresh = false; if (classes.length == 0) { refresh = true; } else { for (var i in classes) { if (classes[i] == p.classId) { refresh = true; break; } } } if (refresh) { this._baseFilter = false; this.invalidate(true); this.fireEvent('Redraw'); } } }, selectChange: function() { this._selection = false; this.fireEvent('SelectChange'); }, doBaseFilter: function() { var out = []; var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; var classFilter = this.classFilter(); for (var i in data) { var ob = data[i]; var ok = true; if (classFilter.length > 0) { ok = false; for (var z in classFilter) { if (ob.Class.Value == classFilter[z]) { ok = true; } } } if (ok) out.push(i); } this._baseFilter = out; this.grouped = false; var me = this; setTimeout(function() { me.invalidate(true); me.fireEvent('Redraw'); }, 10); }, groupByField: function(source, field) { var out = []; var me = this; var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; var oldKey = '327y423y4'; var currentGroup = []; out.push(currentGroup); for (var i in source) { var ob = data[source[i]]; me.documenteditor.setObject(ob); var valA = me.documenteditor.oFunc.Calc(field); if (!valA) valA = ''; if (typeof (valA) == 'string') valA = valA.toUpperCase(); if (valA != oldKey) { oldKey = valA; currentGroup = []; out.push(currentGroup); } currentGroup.push(source[i]); } return out; }, sortByField: function(source, field, desc) { var out = []; var me = this; var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; for (var i in source) { out.push(source[i]); } out.sort(function(a, b) { var result = 0; var objA = data[a]; var objB = data[b]; me.documenteditor.setObject(objA); var valA = me.documenteditor.oFunc.Calc(field); me.documenteditor.setObject(objB); var valB = me.documenteditor.oFunc.Calc(field); if (!valA) valA = ''; if (!valB) valB = ''; if (typeof (valA) == 'string') valA = valA.toUpperCase(); if (typeof (valB) == 'string') valB = valB.toUpperCase(); if (valA == valB) result = 0; else if (valA > valB) result = 1; else if (valB > valA) result = -1; if (desc) result = result * (-1); return result; }); return out; }, doOuterGroup: function() { if (this.outerGroupField()) { var sorted = this.sortByField(this._baseFilter, this.outerGroupField(), this.outerGroupDesc()); this.grouped = this.groupByField(sorted, this.outerGroupField()); this.grouped.push([]); } else { this.grouped = []; this.grouped[0] = []; this.grouped[1] = []; for (var i in this._baseFilter) { this.grouped[0].push(this._baseFilter[i]); } } this.sorted = false; var me = this; setTimeout(function() { me.invalidate(true); me.fireEvent('Redraw'); }, 10); }, doSort: function() { if (this.sortField()) { var out = []; for (var i in this.grouped) { out.push(this.sortByField(this.grouped[i], this.sortField(), this.sortDesc())); } this.sorted = out; } else this.sorted = this.grouped; this.textFiltered = false; if (this.invalidateChildrenNext) { this.invalidateChildrenNext = false; this.invalidateAllChildren(true); } var me = this; setTimeout(function() { me.invalidate(true); me.fireEvent('Redraw'); }, 10); }, doTextFilter: function() { var filterText = this.textFilter(); if (filterText) { var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; var out = []; for (var i in this.sorted) { var group = this.sorted[i]; var lastGroup = []; for (var ii in group) { var objA = data[group[ii]]; this.documenteditor.setObject(objA); var valA = this.documenteditor.oFunc.textFilter(filterText); if (valA) lastGroup.push(group[ii]); } if (lastGroup.length > 0) out.push(lastGroup); } this.textFiltered = out; } else this.textFiltered = this.sorted; var me = this; setTimeout(function() { me.invalidate(true); me.fireEvent('Redraw'); }, 10); }, renderContents: function() { var out = []; var me = this; if (!this.iehack) { setTimeout(function() { if (!me.iehack) { me.invalidate(true); me.fireEvent('Redraw'); } }, 1000); } if (!this._baseFilter) { setTimeout(function() { me.doBaseFilter(); }, 10); return '
'; } if (!this.grouped) { setTimeout(function() { me.doOuterGroup(); }, 10); return '
'; } if (!this.sorted) { setTimeout(function() { me.doSort(); }, 10); return '
'; } if (!this.textFiltered) { setTimeout(function() { me.doTextFilter(); }, 10); return '
'; } this.iehack = true; var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; for (var g in this.textFiltered) { var group = this.textFiltered[g]; var drawnGroup = false; for (var i in group) { var index = group[i]; var item = data[index]; var ctrl = this.ctrlById[item.Id]; if (!drawnGroup) { drawnGroup = true; if (this.outerGroupText() || this.outerGroupField()) { this.documenteditor.setObject(item); var groupText = this.documenteditor.oFunc.Calc(this.outerGroupText() ? this.outerGroupText() : this.outerGroupField()); out.push('
' + groupText + '
'); } } if (!ctrl) { ctrlclass = this.getCtrlClass(item.Class.Value); ctrl = new ctrlclass({ expanded: this.expandNew || oculos.epd2.DefaultParamsForClass[item.Class.Value].initExpanded }, {}, this.namingContainer); ctrl.setParent(this); this.ctrlById[item.Id] = ctrl; ctrl.item = item; //ctrl.itemIndex = index; ctrl.documenteditor = this.documenteditor; } out.push(ctrl.render()); } } this.expandNew = false; return out.join(''); }, sort: function(value) { if (typeof (value) !== 'undefined') { if (this.params.sort != value) { this.params.sort = value; this.invalidate(true); this.fireEvent('SortChanged'); } } else return this.params.sort; }, sortField: function(value) { if (typeof (value) !== 'undefined') { if (this.params.sortField != value) { this.params.sortField = value; this.invalidate(true); this.fireEvent('SortFieldChanged'); } } else return this.params.sortField; }, sortDesc: function(value) { if (typeof (value) !== 'undefined') { if (this.params.sortDesc != value) { this.params.sortDesc = value; this.invalidate(true); this.fireEvent('SortDescChanged'); } } else return this.params.sortDesc; }, list: function(value) { if (typeof (value) !== 'undefined') { if (this.params.list != value) { this.params.list = value; this.invalidate(true); this.fireEvent('ListChanged'); } } else return this.params.list; }, classFilter: function(value) { if (typeof (value) !== 'undefined') { if (this.params.classFilter != value) { this.params.classFilter = value; this.invalidate(true); this.fireEvent('ClassFilterChanged'); } } else return this.params.classFilter; }, textFilter: function(value) { if (typeof (value) !== 'undefined') { if (this.params.textFilter != value) { this.params.textFilter = value; this.textFiltered = false; this.invalidate(true); this.fireEvent('TextFilterChanged'); } } else return this.params.textFilter; }, outerGroupText: function(value) { if (typeof (value) !== 'undefined') { if (this.params.outerGroupText != value) { this.params.outerGroupText = value; this.invalidate(true); this.fireEvent('OuterGroupTextChanged'); } } else return this.params.outerGroupText; }, outerGroupField: function(value) { if (typeof (value) !== 'undefined') { if (this.params.outerGroupField != value) { this.params.outerGroupField = value; this.invalidate(true); this.fireEvent('OuterGroupFieldChanged'); } } else return this.params.outerGroupField; }, outerGroupDesc: function(value) { if (typeof (value) !== 'undefined') { if (this.params.outerGroupDesc != value) { this.params.outerGroupDesc = value; this.invalidate(true); this.fireEvent('OuterGroupDescChanged'); } } else return this.params.outerGroupDesc; }, getCtrlClass: function(c) { var r = oculos.epd2.DefaultObject; var cc = oculos.epd2.ObjectEditorLookup[c]; if (cc) r = eval(cc); return r; }, onListUpdate: function(p) { if (this.domId != p.domId) { var ctrl = this.ctrlById[p.Id]; if (ctrl) { ctrl.updateHeader(); } } }, onRecalcEnd: function(p) { if (this.params.redrawOnUpdate) { // her må vi oppdatere all kampanjer for sikkerhets skyld this.invalidateAllChildren(true); } }, onRecalc: function(p) { if (p.domId != this.domId) { if (this.params.redrawOnUpdate) { // her må vi oppdatere all kampanjer for sikkerhets skyld this.invalidateAllChildren(); } } if (this.domId != p.domId) { var ctrl = this.ctrlById[p.Id]; if (ctrl) { ctrl.updateHeader(); ctrl.fireEvent('Recalc'); } } }, invalidateAllChildren: function(recalc) { var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; for (var g in this.sorted) { var group = this.sorted[g]; var drawnGroup = false; for (var i in group) { var index = group[i]; var item = data[index]; var ctrl = this.ctrlById[item.Id]; if (ctrl) { //ctrl.updateHeader(); //ctrl.invalidate(true); if (recalc) ctrl.invalidate(true); else ctrl.invalidate(); // if (recalc) ctrl.fireEvent('Recalc'); // //else ctrl.fireEvent('CalcUpdate'); } } } }, selectClear: function() { var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; for (var g in this.ctrlById) { var ctrl = this.ctrlById[g]; if (ctrl.selected) { ctrl.selected(false); } } this.selectionIds = {}; }, selectAll: function() { var data = this.params.trash ? this.documenteditor.document.DeletedObjects : this.documenteditor.document.Objects; for (var g in this.sorted) { var group = this.sorted[g]; var drawnGroup = false; for (var i in group) { var index = group[i]; var item = data[index]; var ctrl = this.ctrlById[item.Id]; if (ctrl) { ctrl.selected(true); } } } }, onObjectUpdate: function(p) { var ctrl = this.ctrlById[p.Id]; if (p.domId != this.domId) { if (this.params.redrawOnUpdate) { // her må vi oppdatere all kampanjer for sikkerhets skyld this.invalidateAllChildren(); } } if (ctrl) { //if (p.domId != this.domId) ctrl.fireEvent('ObjectUpdate'); //if (p.domId == this.domId) ctrl.fireEvent('CalcUpdate'); if (p.domId != this.domId) { ctrl.fireEvent('ObjectUpdate'); } ctrl.fireEvent('CalcUpdate'); ctrl.updateHeader(); } } }); oculos.epd2.ObjectEditorLookup = {}; oculos.epd2.ObjectEditorLookup['e43432e7-f81f-43fa-a772-55c644aacd9b'] = 'oculos.epd2.CarObject'; oculos.epd2.ObjectEditorLookup['9291a5a1-b82a-4c3a-b3f3-db280aa60e15'] = 'oculos.epd2.PPCarObject'; oculos.epd2.ObjectEditorLookup['25bf2a7a-ef7e-4956-99e9-506c9e411818'] = 'oculos.epd2.EqObject'; oculos.epd2.ObjectEditorLookup['d7a4db4d-2013-47e3-81fb-378ae0edc25a'] = 'oculos.epd2.PPEqObject'; oculos.epd2.ObjectEditorLookup['df658419-c05b-4183-a4e2-49076e4956d8'] = 'oculos.epd2.LocalEqObject'; oculos.epd2.ObjectEditorLookup['8b438735-0a31-44b6-9315-01fa28be59be'] = 'oculos.epd2.TrimLevelObject'; oculos.epd2.ObjectEditorLookup['ea1c41c6-22f4-4992-807d-928e04e15e51'] = 'oculos.epd2.CarCatObject'; oculos.epd2.ObjectEditorLookup['f15c4ca1-5729-4b51-9b6b-b82a16cb8516'] = 'oculos.epd2.EqCatObject'; oculos.epd2.ObjectEditorLookup['31b2d775-fe5a-4d51-bcd0-99629d874e6b'] = 'oculos.epd2.InfoObject'; oculos.epd2.ObjectEditorLookup['f1e24006-4395-4948-a50b-cbb4ec5c596c'] = 'oculos.epd2.CampainObject'; oculos.epd2.ObjectEditorLookup['31b2d775-fe5a-4d51-bcd0-99629d874e6b'] = 'oculos.epd2.DocInfoObject'; oculos.epd2.ObjectEditorLookup[''] = ''; oculos.epd2.DefaultParamsForClass = {}; oculos.epd2.DefaultParamsForClass['e43432e7-f81f-43fa-a772-55c644aacd9b'] = {filter: "'#' + P('ManCode') + ' ' + P('GenBrand') + ' ' + P('GenModel') + ' ' + P('GenDoors') + 'D ' + P('GenLitres') + 'L ' + P('GenHP') + 'HK ' + P('GenFuelType') + ' ' + P('GenNumGears') + '' + P('GenGearType') + ' ' + P('Type.TrimLevelName')", price: "P('DealerCarPriceTotal')", text: "P('GenBrand') + ' ' + P('GenModel') + ' ' + P('GenDoors') + 'D ' + P('GenLitres') + 'L ' + P('GenHP') + 'HK ' + P('GenFuelType') + ' ' + P('GenNumGears') + '' + P('GenGearType') + ' ' + P('Type.TrimLevelName')", outerGroupField: 'P("Type.TrimLevelSort") + " " + P("Type.TrimLevelName")', outerGroupText: 'P("Type.TrimLevelName")', sortField: 'P("GenHP")', sortDesc: true }; // DealerCar oculos.epd2.DefaultParamsForClass['25bf2a7a-ef7e-4956-99e9-506c9e411818'] = {filter:"'#' + P('ManCode') + ' ' + P('GenName') + ' ' + P('EquipmentCategory.CategoryName')", price:"P('DealerTotalPriceEq')", text:'P("GenName")', outerGroupField:'P("EquipmentCategory.CategorySort") + " " + P("EquipmentCategory.CategoryName")', outerGroupText:'P("EquipmentCategory.CategoryName")', sortField:'P("GenName")'}; // DealerEq oculos.epd2.DefaultParamsForClass['9291a5a1-b82a-4c3a-b3f3-db280aa60e15'] = {price: "P('DealerCarPriceTotal')", text: "P('GenBrand') + ' ' + P('GenModel') + ' ' + P('GenDoors') + 'D ' + P('GenLitres') + 'L ' + P('GenHP') + 'HK ' + P('GenFuelType') + ' ' + P('GenNumGears') + '' + P('GenGearType') + ' ' + P('Type.TrimLevelName')", outerGroupField: 'P("Type.TrimLevelSort") + " " + P("Type.TrimLevelName")', outerGroupText: 'P("Type.TrimLevelName")', sortField: 'P("GenHP")', sortDesc: true }; // ProPrimaCar oculos.epd2.DefaultParamsForClass['d7a4db4d-2013-47e3-81fb-378ae0edc25a'] = {filter:"P('GenName') + ' ' + P('EquipmentCategory.CategoryName')", price: "P('DealerTotalPriceEq')", text: 'P("GenName")', outerGroupField: 'P("EquipmentCategory.CategorySort") + " " + P("EquipmentCategory.CategoryName")', outerGroupText: 'P("EquipmentCategory.CategoryName")', sortField: 'P("GenName")' }; // ProPrimaEq oculos.epd2.DefaultParamsForClass['df658419-c05b-4183-a4e2-49076e4956d8'] = {filter: "'#' + P('ManCode') + ' ' + P('GenName')", price: "P('Price')", text: 'P("GenName")', allowNew: true, sortField: 'P("GenName")' }; oculos.epd2.DefaultParamsForClass['8b438735-0a31-44b6-9315-01fa28be59be'] = {filter:'P("TrimLevelName")', sortField: 'P("TrimLevelSort") + " " + P("TrimLevelName")' }; // TrimLevel oculos.epd2.DefaultParamsForClass['ea1c41c6-22f4-4992-807d-928e04e15e51'] = {filter:'P("CategoryName")', sortField: 'P("CategorySort") + " " + P("CategoryName")' }; // CarCat oculos.epd2.DefaultParamsForClass['f15c4ca1-5729-4b51-9b6b-b82a16cb8516'] = {filter:'P("CategoryName")', sortField:'P("CategorySort") + " " + P("CategoryName")'}; // EqCat oculos.epd2.DefaultParamsForClass['31b2d775-fe5a-4d51-bcd0-99629d874e6b'] = {text:'T("classes_docinfo")', initExpanded:true, disableRec:true}; oculos.epd2.DefaultParamsForClass['f1e24006-4395-4948-a50b-cbb4ec5c596c'] = {filter:'P("GenName")', redrawOnUpdate:true, allowNew:true, sortField:'P("GenName")'}; // Campaign oculos.epd2.DefaultObject = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdDefaultObject epdItem"; this.params.selType = 'Pos'; if (!this.params.expanded) this.params.expanded = false; }, selected: function(value) { if (typeof (value) !== 'undefined') { var oldValue = false; if (this.parent.selectionIds[this.item.Id]) oldValue = true; if (oldValue != value) { if (value) this.parent.selectionIds[this.item.Id] = true; else delete this.parent.selectionIds[this.item.Id]; try { if (value) { $('#' + this.domId + '_table').addClass("sel" + this.params.selType); } else { $('#' + this.domId + '_table').removeClass("sel" + this.params.selType); } } catch (ex) { } this.invalidate(); this.parent.selectChange(); this.fireEvent('SelectedChange'); } } else { if (this.parent.selectionIds[this.item.Id]) return true; return false; } }, domSelect: function() { this.selected(!this.selected()); }, domToggleExpand: function() { this.expanded(!this.expanded()); }, domToggleList: function() { this.toggleList(); }, updateHeader: function() { try { document.getElementById(this.domId + '_short').innerHTML = this.renderHeader(); this.invalidate(false); } catch (ex) { this.invalidate(true); } }, isInList: function() { var listId = this.parent.list(); for (var i in this.item.Lists) { if (this.item.Lists[i].Id == listId) return true; } return false; }, toggleList: function() { var oldLists = this.item.Lists; var newList = []; var listId = this.parent.list(); var found = false; for (var i in this.item.Lists) { if (this.item.Lists[i].Id != listId) { newList.push(this.item.Lists[i]); } else found = true; } if (!found) { newList.push({ Id: listId }); } this.item.Lists = newList; this.updateHeader(); this.documenteditor.updateList(this.item.Id, this.parent.domId); }, renderHeader: function() { var out = []; var expanded = this.expanded(); var iconclass = oculos.epd2.ObjectBrowserGetIconClass(this.item.Class.Value); var cParam = oculos.epd2.DefaultParamsForClass[this.item.Class.Value]; out.push('
'); out.push('
'); if (!cParam.disableExpand) out.push('
'); if (!cParam.disableRec) out.push('
'); this.documenteditor.setObject(this.item); var toEval = this.getShortText(); for (var i in toEval) { var part = toEval[i]; var text = ''; var style = ''; with (this.documenteditor.oFunc) { text = eval('(' + part.text + ')'); style = eval('(' + part.style + ')'); } out.push('
'); out.push(text); out.push('
'); } out.push('
'); return out.join(''); }, renderContents: function() { var out = []; var expanded = this.expanded(); out.push('
'); out.push('
'); out.push(this.renderHeader()); out.push('
'); if (expanded) { out.push('
'); out.push(this.renderChildren()); out.push('
'); } out.push('
'); return out.join(''); }, expanded: function(value) { if (typeof (value) !== 'undefined') { if (this.params.expanded != value) { this.params.expanded = value; this.invalidate(true); this.fireEvent('ExpandedChanged'); } } else return this.params.expanded; }, getShortText: function() { var out = []; out.push({ text: "P('CategoryName')", style: "'left'" }); out.push({ text: "'Høyre'", style: "'right'" }); return out; } }); oculos.epd2.PropLink = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this._init = false; }, onCtrlBlur: function() { UnTip(); this.tipped = false; }, onCtrlFocus: function(param, elem, quick) { //elem.style.backgroundColor = "#fff0f0"; var p = this.prop; //alert(JSON.stringify(p)); var toolTipText = []; toolTipText.push(''); toolTipText.push(''); var lstvalue = ''; var hist = { Value: '' }; for (var histIndex in p.History) { var lastRowCss = ""; hist = p.History[histIndex]; if (histIndex == p.History.length - 1) { if (!this.qBegin) { if (p.Value == hist.Value) { lastRowCss = "lastRow"; } } else { if (this.qValue == hist.Value) { lastRowCss = "lastRow"; } } } if (this.qIndex == histIndex) lastRowCss = "qactive"; toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); } var lastRowCss = "lastRow"; if (this.qIndex == p.History.length) lastRowCss = "qactive"; if (!this.qBegin) { if (p.Value != hist.Value) { toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); } } else { if (this.qValue != hist.Value) { toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); toolTipText.push(''); } } toolTipText.push('
' + T('date') + ' ' + T('revision') + ' ' + T('revisiontype') + ' ' + T('value') + ' 
'); toolTipText.push(hist.RevisionDate.toString("dd.MM.yyyy")); toolTipText.push(' '); toolTipText.push(hist.Revision); toolTipText.push(' '); toolTipText.push(T('revisiontype_' + hist.RevisionType)); toolTipText.push(' '); toolTipText.push(hist.Value); lastvalue = hist.Value; toolTipText.push(' 
'); toolTipText.push("-"); toolTipText.push(' '); toolTipText.push("-"); toolTipText.push(' '); toolTipText.push(T('revisiontype_0')); toolTipText.push(' '); toolTipText.push(p.Value); toolTipText.push(' 
'); toolTipText.push("-"); toolTipText.push(' '); toolTipText.push("-"); toolTipText.push(' '); toolTipText.push(T('revisiontype_0')); toolTipText.push(' '); toolTipText.push(this.qValue); toolTipText.push(' 
'); //tt_PosFix(); var me = this; setTimeout(function() { var offset = $(document.getElementById(me.ctrl.domId + '_ta')).offset(); Tip(toolTipText.join(''), FIX, [offset.left, offset.top - 10], ABOVE, true); if (quick) Tip(toolTipText.join(''), FIX, [offset.left, offset.top - 10], ABOVE, true, FADEIN, 0, DELAY, 0); else Tip(toolTipText.join(''), FIX, [offset.left, offset.top - 10], ABOVE, true); me.tipped = true; }, (quick ? 10 : 100)); }, onCtrlKeyUpDelayed: function() { if (this.tipped) this.onCtrlFocus(null, null, true); }, onCtrlKeyUp: function(param, elem) { if (param.ctrlKey && (param.keyCode == 38 || param.keyCode == 40)) { var p = this.prop; var up = (param.keyCode == 38); var down = (param.keyCode == 40); if (!this.qBegin) { this.qBegin = true; this.qValue = this.ctrl.value(); if (up) this.qIndex = p.History.length - 1; else this.qIndex = 0; } else { if (up) { if (this.qIndex > 0) this.qIndex--; } else { if (this.qIndex < p.History.length) this.qIndex++; } } if (this.qIndex < 0) this.qIndex = 0; if (this.qIndex < p.History.length) this.ctrl.value(p.History[this.qIndex].Value); else this.ctrl.value(this.qValue); this.ctrl.select(); this.onCtrlFocus(null, null, true); } else { if (param.keyCode != 17 && param.keyCode != 38 && param.keyCode != 40 && !param.ctrlKey) { this.qValue = this.ctrl.value(); this.qIndex = this.prop.History.length; } } }, onValueChange: function() { if (this.prop.Value != this.ctrl.value()) { this.prop.Value = this.ctrl.value(); this.namingContainer.documenteditor.registerUpdate(this.namingContainer.item.Id, this.namingContainer.parent.domId); } this.namingContainer.updateHeader(); }, render: function() { if (!this._init) { this._init = true; this.ctrl = this.namingContainer[this.params.ctrl]; if (!this.ctrl) alert(this.params.ctrl); this.namingContainer.documenteditor.setObject(this.namingContainer.item); this.prop = this.namingContainer.documenteditor.oFunc.Prop(this.params.prop); if (!this.prop.History) this.prop.History = []; this.propType = this.namingContainer.documenteditor._controller.getPropertyTypeById(this.prop.Id); if (this.ctrl.innerClass) { try { this.ctrl.innerClass("status_" + this.prop.State); } catch (e) { } } var me = this; this.ctrl.registerEventHandler("ValueChange", this, this.onValueChange); this.namingContainer.registerEventHandler("ObjectUpdate", this, this.update2); this.ctrl.registerEventHandler("Blur", this, this.onCtrlBlur); this.ctrl.registerEventHandler("Focus", this, this.onCtrlFocus); this.ctrl.registerEventHandler("KeyUp", this, this.onCtrlKeyUp); this.ctrl.registerEventHandler("TextDelayedChange", this, this.onCtrlKeyUpDelayed); if (!this.propType) alert(this.params.prop); if (this.propType.FormulaId || this.propType.DefaultFormula) { this.namingContainer.registerEventHandler("CalcUpdate", this, this.calcUpdate); } this.namingContainer.registerEventHandler("Recalc", this, this.recalc); this.update(); this.updateGhost(); //this.calcUpdate(); } return ''; }, recalc: function() { this.update(); this.updateGhost(); }, updateGhost: function() { if (this.ctrl.ghost && this.params.ghost) { var value = null; this.namingContainer.documenteditor.setObject(this.namingContainer.item); value = '' + this.namingContainer.documenteditor.oFunc.Calc(this.params.ghost); this.ctrl.ghost(value); } }, calcUpdate: function() { var value = null; var formula = null; if (this.propType.FormulaId) { // find formula } if (!formula) { formula = this.propType.DefaultFormula; } this.namingContainer.documenteditor.setObject(this.namingContainer.item); value = '' + this.namingContainer.documenteditor.oFunc.Calc(formula); if (value == 'NaN') value = '0'; this.prop.Value = value; this.update2(); }, update2: function() { this.ctrl.value(this.prop.Value); }, update: function() { this.ctrl.value(this.prop.Value); } });jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.ObjectContentEditor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdObjectContentEditor"; }, value: function(value) { if (typeof (value) !== 'undefined') { if (this.item.Contents != value) { this._sorted = false; this.item.Contents = value; this.invalidate(true); this.fireEvent('ValueChange'); } } else return this.item.Contents; }, onDomAdd: function(value) { if (!this.documenteditor.addpopup) { this.documenteditor.addpopup = new oculos.epd2.ContentAddPopup(); this.documenteditor.addpopup.documenteditor = this.documenteditor; } this.documenteditor.addpopup.addHandler = { func: this.onPopupReturn, ctrl: this }; this.documenteditor.popup(this.documenteditor.addpopup); //this.documenteditor.addpopup.invalidate(true); //this.documenteditor.addpopup.fireEvent('redraw'); }, onPopupReturn: function() { var selection = this.documenteditor.addpopup.getSelection(); this.addItems(selection); }, addItems: function(items) { var oldValue = this.value(); var newValue = []; var oldKeys = {}; for (var i in oldValue) { oldKeys[oldValue[i].Id] = oldValue[i].Id; newValue.push(oldValue[i]); } for (var i in items) { if (!oldKeys[items[i].PublicId.Value]) { oldKeys[items[i].PublicId.Value] = items[i].PublicId.Value; newValue.push({ Id: items[i].PublicId.Value }); } } this.value(newValue); }, onDomClearAll: function() { this.value([]); }, onDomDelete: function(index) { var oldValue = this.value(); var newValue = []; for (var i in oldValue) { if (index != i) newValue.push(oldValue[i]); } this.value(newValue); }, sortByField: function(source, field, desc) { var out = []; var me = this; // TODO: hvis objekter mangler må de fjernes fra Contents som under, men dette på også gjøres på server og alle typer links for (var i in source) { var xx = this.documenteditor._controller.getObjectById(source[i].Id); if (xx) out.push(source[i]); } out.sort(function(a, b) { var result = 0; var objA = me.documenteditor._controller.getObjectById(a.Id); var objB = me.documenteditor._controller.getObjectById(b.Id); me.documenteditor.setObject(objA); var valA = me.documenteditor.oFunc.Calc(field); me.documenteditor.setObject(objB); var valB = me.documenteditor.oFunc.Calc(field); if (!valA) valA = ''; if (!valB) valB = ''; if (typeof (valA) == 'string') valA = valA.toUpperCase(); if (typeof (valB) == 'string') valB = valB.toUpperCase(); if (valA == valB) result = 0; else if (valA > valB) result = 1; else if (valB > valA) result = -1; if (desc) result = result * (-1); return result; }); return out; }, doSort: function() { var value = this.value(); var me = this; // quick sort TODO: bør gruppers og lagres slik at dette ikke skjer hver gang det tegnes this.item.Contents = this.sortByField(value, 'ClassSort() + " " + ClassName() + " " + P("GenName")', false); this._sorted = true; }, renderContents: function() { var out = []; var value = this.value(); var me = this; if (!this._sorted) { setTimeout(function() { me.doSort(); me.invalidate(true); me.fireEvent('redraw'); }, 50); } out.push(''); var lastGroup = 'adasd'; for (var i in value) { var ob = this.documenteditor._controller.getObjectById(value[i].Id); this.documenteditor.setObject(ob); var groupText = this.documenteditor.oFunc.Calc("ClassName()"); var dp = oculos.epd2.DefaultParamsForClass[ob.Class.Value]; var text = this.documenteditor.oFunc.Calc(dp.text); var price = this.documenteditor.oFunc.Calc(dp.price); if (groupText != lastGroup) { lastGroup = groupText; out.push(''); } out.push(''); out.push(''); out.push(''); out.push(''); out.push(''); out.push(''); } out.push('
' + groupText + '
'); out.push('
'); out.push('
'); if (ob._deleted) out.push('(' + T('gui_deleted') + ') '); out.push(text); out.push('
'); out.push(price); out.push(''); out.push('' + T("gui_delobject") + ''); out.push('
'); out.push('
'); out.push('' + T("gui_addobject") + ''); out.push('' + T("gui_clearobjects") + ''); out.push('
'); return out.join(''); } });oculos.epd2.ObjectLinkEditor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdObjectLinkEditor"; }, renderContents: function() { var out = []; var item = this.namingContainer.item; var includedInIds = oculos.epd2.ObjectLinkEditor.extractObjectIds(item.IncludedIn.Value); var accessoryForIds = oculos.epd2.ObjectLinkEditor.extractObjectIds(item.AccessoryFor.Value); var mustBeCombinedWithIds = oculos.epd2.ObjectLinkEditor.extractObjectIds(item.MustBeCombinedWith.Value); out.push('
'); var included = []; var usedKeys = {}; for (var i in includedInIds) { var obId = includedInIds[i]; var ob = this.namingContainer.documenteditor._controller.getObjectById(obId); if (ob) { this.namingContainer.documenteditor.setObject(ob); var trimlevel = this.namingContainer.documenteditor.oFunc.Calc('P("TrimLevelName")'); usedKeys[trimlevel] = true; included.push(trimlevel); } } if (included.length > 0) out.push('Standard on: ' + included.join(', ') + ''); var accessory = []; for (var i in accessoryForIds) { var obId = accessoryForIds[i]; var ob = this.namingContainer.documenteditor._controller.getObjectById(obId); if (ob) { this.namingContainer.documenteditor.setObject(ob); var trimlevel = this.namingContainer.documenteditor.oFunc.Calc('P("TrimLevelName")'); if (!usedKeys[trimlevel]) accessory.push(trimlevel); } } if (accessory.length > 0) { if (included.length > 0) out.push('   '); out.push('Optional on: ' + accessory.join(', ') + ''); } out.push('
'); return out.join(''); } }); oculos.epd2.ObjectLinkEditor.extractObjectIds = function(text) { var out = []; if (!text) return out; var matches = text.match(/"[^"]+"/gmi); if (matches) { for (var i in matches) { var match = matches[i]; if (!match.length) return out; var fixed = match.substr(1, match.length - 2); var found = false; //for (var z in out) { // if (out[z] == fixed) { // found = true; // break; // } //} if (!found) { out.push(fixed); } } } return out; }; jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.Page = jAppML.controls.UserControl.extend({ title: function() { return "TestSide"; } });jAppML.utils.ensureNamespace("oculos.epd2"); nav = function(page) { window.pageHandler.nav(parseInt(page)); }; oculos.epd2.PageHandler = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdPageHandler"; this.pagewidth = 950; this.pagemargin = 150; if (this.params.index) this.params.index = parseInt('' + this.params.index); else this.params.index = 0; this.jumpToIndex = -1; this.pageParams = []; this.pageConst = []; this.destIndex = 0; this.loadIndex = 0; window.pageHandler = this; }, prepareAttributes: function() { this._super(); this.attributes['style'] = 'width:' + this.pagewidth + 'px;overflow:hidden;white-space:nowrap;position:relative;'; }, renderContents: function() { var out = []; var pages = this.children; out.push(''); //out.push('
'); for(var i = 0; i < pages.length; i++) { out.push(this.renderTD(i)); } //out.push('
'); out.push('
'); return out.join(''); }, renderTD: function(i) { var out = []; out.push(''); var left = i * (this.pagewidth + this.pagemargin); out.push('
'); out.push(this.children[i].render()); out.push('
'); out.push(''); return out.join(''); }, testPos: function() { var container = document.getElementById(this.domId); alert(container.scrollLeft + ' ' + container.scrollTop); }, onRendered: function() { var container = document.getElementById(this.domId); var nextElement = document.getElementById(this.domId + '_' + this.index()); $(container).scrollTo(nextElement,0,{axis:'yx'}); // if (this.jumpToIndex >= 0) { // var me = this; // setTimeout(function() { // me.index(me.jumpToIndex); // // },5); // } }, checkUrl: function() { }, nav: function(index) { this.index2(index); }, loadTo: function(index) { window.frames['navframe'].location.href = 'JS/nav.ashx?page=' + index; }, back: function(steps) { if (!steps) steps = 1; this.index(this.index() - steps); }, index: function(value, loaded) { if (typeof(value) !== 'undefined') { if (value < 0) value = 0; this.jumpToIndex = -1; if (this.params.index != value) { this.destIndex = value; this.loadIndex = this.params.index; if (value > this.params.index) { if (loaded) { window.frames['navframe'].history.go(value - this.params.index); } else { this.loadTo(this.params.index+1); } } else { window.frames['navframe'].history.go(value - this.params.index); } } } else { return this.params.index; } }, index2: function(value, moveback) { if (typeof(value) !== 'undefined') { this.jumpToIndex = -1; if (this.params.index != value) { var pages = this.children; var container = document.getElementById(this.domId); var domId = this.domId; // make next page visible TOTO: all elements visible in range var nextElement = document.getElementById(this.domId + '_' + value); //nextElement.style.height = 'auto'; var currentHeight = $('#' + this.domId + '_' + this.params.index).height(); for(var i = 0; i < pages.length; i++) { if (i != this.params.index) { document.getElementById(domId + '_' + i).style.height = currentHeight + 'px'; } } // scroll to next page var relLength = Math.abs(value - this.params.index); $(container).scrollTo(nextElement,300 + (100 * relLength),{axis:'yx',onAfter:function() { for(var i = 0; i < pages.length; i++) { if (i != value) { document.getElementById(domId + '_' + i).style.height = '0px'; } else document.getElementById(domId + '_' + i).style.height = 'auto'; } }}); this.params.index = value; this.invalidate(false); this.fireEvent('IndexChange'); } } else { return this.params.index; } }, addPage: function(ctrlName, params) { var index = this.index(); var paramsHash = JSON.stringify(params); if (this.pageConst[index+1] == ctrlName) { if (this.pageParams[index+1] == paramsHash) { this.index(index+1, true); return; } } var construc = eval(ctrlName); // TODO: reuse controls var oldChildren = this.children; this.children = []; for(var i = 0; i <= index; i++) { this.children.push(oldChildren[i]); } var newPage = new construc(params); this.addControl(newPage); this.removeAfter(index); $('#' + this.domId + ' > table > tbody > tr > td:last').after(this.renderTD(index+1)); this.pageParams[index+1] = paramsHash; this.pageConst[index+1] = ctrlName; this.index(index+1); this.invalidate(); this.fireEvent("PageAdd"); }, removeAfter: function(i) { $('#' + this.domId + ' > table > tbody > tr > td:gt(' + i + ')').remove(); }, addControl: function(ctrl) { //if (ctrl instanceof oculos.epd2.Page) { this._super(ctrl); //} } }); jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.PolicyEditor = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdPolicyEditor"; this._useControls = []; this._controls = []; if (this.namingContainer[this.params.dataSource]) this._dataSource = this.namingContainer[this.params.dataSource]; else this._dataSource = this.getGlobalControl(this.params.dataSource); if (this.params.mode) this.mode = this.params.mode; else this.mode = 'ForSelf'; this.modeProp = 'ValueForSelf'; this.modeValue = 'Value'; if (this.mode == 'ForChildren') { this.modeProp = 'ValueForChildren'; this.modeValue = 'DefaultValue'; } else if (this.mode == 'FromParent') { this.modeProp = 'ValueFromParent'; this.modeValue = 'DefaultValue'; } var me = this; this._dataSource.getAll([{key:"T(Name)", direction:"asc"}], null, function(sort, search, data) { var orderedByGroup = []; for(var i in data) { var pol = data[i]; if (!orderedByGroup[pol.Group]) orderedByGroup[pol.Group] = []; orderedByGroup[pol.Group].push(pol); } me.source(orderedByGroup); }); this.getGlobalControl('policyGroupDataSource').getAll([{key:"T(Name)", direction:"asc"}], null, function(sort, search, data) { var indexed = []; for(var i in data) { var group = data[i]; indexed[group.Id] = group; } me.groups(indexed); }); if (this.params.getResolvedPolicies) { this.reloadPolicies(); } this.value(this.params.value); //alert(JSON.stringify(jAppML.user._dataTypes)); //this._dataSource.registerEventHandler("DataChange", this, this.onDataChange); }, reloadPolicies: function() { this.waitForPolicies = true; var func = this.namingContainer[this.params.getResolvedPolicies]; var me =this; me.resolvedPolicies = null; func.call(this.namingContainer, function(data) { var newdata = []; for (var i in data) { var pol = data[i]; newdata[pol.Id] = pol; } me.params.resolvedPolicies = newdata; me.invalidate(true); me.fireEvent('ResolvedPoliciesLoaded'); }); me.invalidate(true); me.fireEvent('ResolvedPoliciesReloading'); }, onRendered: function() { this.fireEvent('Rendered'); }, renderContents: function() { var out = []; var mode = this.mode; var data = this.value(); var source = this.source(); var groups = this.groups(); var me= this; if (!data || !source || !groups || (!this.params.resolvedPolicies && this.waitForPolicies)) { out.push('
'); return out.join(''); } out.push(''); for (var outer in groups) { var group = groups[outer]; var pols = source[outer]; var allow = false; if (pols) { for(var inner in pols) { var pol = pols[inner]; if (this.params.resolvedPoliciesForCompany) { var resolved = this.params.resolvedPoliciesForCompany[pol.Id]; if (resolved) { if (resolved.AllowSetValue && (mode != 'ForChildren' || resolved.AllowSetNewDefaultValue)) { // don't show calc policy if (pol.Id != 'ae9e100e-2aa3-4bce-9545-acc1d9316327') allow = true; break; } } } } } //alert(JSON.stringify(this.params.value)); if (pols && allow) { out.push(''); for (var inner in pols) { var pol = pols[inner]; allow = false; if (this.params.resolvedPoliciesForCompany) { var resolved = this.params.resolvedPoliciesForCompany[pol.Id]; if (resolved) { if (resolved.AllowSetValue && (mode != 'ForChildren' || resolved.AllowSetNewDefaultValue)) { allow = true; } } } // don't show calc policy if (pol.Id == 'ae9e100e-2aa3-4bce-9545-acc1d9316327') allow = false; if (allow) { out.push(''); out.push(''); out.push(''); out.push(''); out.push(''); } // javascript:alert(JSON.stringify(window.resolvedUserPoliciesForCompany['c777c70f-ae06-43bf-a036-632dea5b483c'])); } } } out.push('
' + T(group.Name) + '
'); if (!this._useControls[pol.Id]) { var zz = '' + pol.Id; this._useControls[pol.Id] = new jAppML.controls.CheckBox({},{onValueChange:function() { me.invalidate(true); me.fireEvent('Redraw'); }}, this); if (this.params.value[pol.Id]) { if (this.params.value[pol.Id][this.modeProp]) { if (this.params.value[pol.Id][this.modeProp][this.modeValue]) this._useControls[pol.Id].value(true); } }; } out.push(this._useControls[pol.Id].render()); var isUsed = this._useControls[pol.Id].value(); out.push('' + T(pol.Name) + '
'); //alert(pol.DataType); if (!this._controls[pol.Id]) { var ctrlClass = eval(jAppML.user._dataTypes[pol.DataType].editor); this._controls[pol.Id] = new ctrlClass({},{onValueChange:(function(polId) { return function() { me.params.value[polId] = {Id:polId}; me.params.value[polId][me.modeProp] = {}; me.params.value[polId][me.modeProp][me.modeValue] = me._controls[polId].value(); me.invalidate(); }})(pol.Id)},this); if (this.params.value[pol.Id]) { if (this.params.value[pol.Id][this.modeProp]) { this._controls[pol.Id].value(this.params.value[pol.Id][this.modeProp][this.modeValue]); } } me.params.value[pol.Id] = {Id:pol.Id}; me.params.value[pol.Id][this.modeProp] = {}; me.params.value[pol.Id][this.modeProp][this.modeValue] = me._controls[pol.Id].value(); } if (isUsed) { out.push(this._controls[pol.Id].render()); } else { var resolved = ''; var resolvedValue = ''; if (this.params.fix1) { resolved = this.params.resolvedPoliciesForCompany[pol.Id]; resolvedValue = resolved.Value; if (this.params.useInherited) resolvedValue = resolved.InheritedValue; } else if (this.params.resolvedPolicies) { resolved = this.params.resolvedPolicies[pol.Id]; resolvedValue = resolved.Value; if (this.params.useInherited) resolvedValue = resolved.InheritedValue; } var ren = ''; if (this._controls[pol.Id].display2) ren = this._controls[pol.Id].display2(resolvedValue); else ren = this._controls[pol.Id].display(resolvedValue); out.push('' + ren + ''); } out.push('
'); out.push('
'); //out.push(JSON.stringify(source)); return out.join(''); }, value: function(value) { if (typeof(value) !== 'undefined') { var newData = []; for(var i in value) { var v = value[i]; newData[v.Id] = v; } if (JSON.stringify(this.params.value) != JSON.stringify(newData)) { this.params.value = newData; this.invalidate(true); this.fireEvent('ValueChanged'); } } else { var newData = []; if (this.params.value) { for(var i in this.params.value) { if (this._useControls[this.params.value[i].Id]) { if (this._useControls[this.params.value[i].Id].value()) newData.push(this.params.value[i]); else { var nullValue = {Id:this.params.value[i].Id}; nullValue[this.modeProp] = {}; nullValue[this.modeProp][this.modeValue] = null; newData.push(nullValue); //newData.push({Id:this.params.value[i].Id, ValueForSelf:{Value:null}}); } } else newData.push(this.params.value[i]); } } return newData; } }, mergeValues: function(bs) { var hash = []; var as = this.value(); for (var i in as) { var a = as[i]; hash[a.Id] = a; } for (var i in bs) { var b = bs[i]; if (hash[b.Id]) { for(var x in b) { if (!hash[b.Id][x]) hash[b.Id][x] = b[x]; } } else hash[b.Id] = b; } var result = []; for (var i in hash) { result.push(hash[i]); } return result; }, source: function(value) { if (typeof(value) !== 'undefined') { if (this.params.source != value) { this.params.source = value; this.invalidate(true); this.fireEvent('SourceChanged'); } } else return this.params.source; }, groups: function(value) { if (typeof(value) !== 'undefined') { if (this.params.groups != value) { this.params.groups = value; this.invalidate(true); this.fireEvent('GroupsChanged'); } } else return this.params.groups; } });jAppML.controls.Scrollable = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this._scrollTop = 0; this._scrollLeft = 0; this._calcWidth = 0; }, prepareAttributes: function() { this._super(); var css = this.params.maxHeight ? ("max-height:" + this.params.maxHeight + ";") : ""; css += (this.params.minHeight ? ("min-height:" + this.params.minHeight + ";") : ""); if (this._calcWidth > 0) css += "max-width:" + this._calcWidth + 'px;'; this.attributes['style'] = "padding:0px;margin:0px;overflow:hidden;position:relative;overflow-y:scroll;" + css + (this.params.allowX ? 'overflow-x:scroll;' : ''); this.attributes['onscroll'] = this.renderCallback('domOnScroll', null); }, renderContents: function() { if (this._calcWidth == 0) return '
 
'; return this._super() + '
'; }, domOnScroll: function(param, domElement) { this._scrollTop = domElement.scrollTop; this._scrollLeft = domElement.scrollLeft; UnTip(); }, invalidate: function(x) { try { this._scrollTop = document.getElementById(this.domId).scrollTop; this._scrollLeft = document.getElementById(this.domId).scrollLeft; } catch (e) { } this._super(x); }, goToBottom: function() { try { var elm = document.getElementById(this.domId); var elm2 = document.getElementById(this.domId + '_bott'); $(elm).scrollTo(elm2, 200, { axis: 'y' }); } catch (ex) { } }, onRendered: function() { var dom = document.getElementById(this.domId); var me = this; if (this._calcWidth == 0) { this._calcWidth = $(dom).width(); // if (this._calcWidth == 0) { // setTimeout(function() { me.onRendered(); },100); // return; // } // setTimeout(function() { me.invalidate(true); me.fireEvent('CalcWidth'); }, 50); return; } try { dom.scrollTop = this._scrollTop; dom.scrollLeft = this._scrollLeft; } catch (e) { } } });jAppML.utils.ensureNamespace("oculos.epd2"); oculos.epd2.VersionBar = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, "div"); this.fixedClass = "epdVersionBar"; }, convertToHTML: function(v) { return '' + v.Name + ':'+ v.Major + '.' + v.Minor + '.' + v.Revision + (v.LocalModifications ? 'M' : '') + ''; }, renderContents: function() { var out = []; for(var i in serviceComponentVersions) { out.push(this.convertToHTML(serviceComponentVersions[i])); } out.push(this.convertToHTML(webVersion)); out.push(this.convertToHTML(proxyVersion)); out.push(this.convertToHTML(jAppMLVersion)); return out.join('-'); } });jAppML.utils.ensureNamespace("oculos.epd2"); var testWiz = [ {text:'Trinn A'}, {text:'Trinn B'}, {text:'Trinn C eller X'}, {text:'Trinn D'}, {text:'Trinn E'}, {text:'Trinn F'} ]; oculos.epd2.WizardBar = jAppML.controls.Control.extend({ init: function(params1, params2, parent) { this._super(params1, params2, parent, 'div'); this.fixedClass = "epdWizardBar"; if (this.params.index) this.params.index = parseInt('' + this.params.index); else this.params.index = 0; if (!this.params.wizData) this.params.wizData = testWiz; }, calcStates: function(i) { var wizData = this.params.wizData; var currentItem = wizData[i]; var nextItem = i < wizData.length - 1 ? wizData[i+1] : null; var prevItem = i > 0 ? wizData[i-1] : null; var currentState = "tocome"; if (currentItem.completed) currentState = "comp"; if (this.params.index > i) currentState = "comp"; if (i == this.params.index) { if (currentItem.completed) currentState = "finished"; else currentState = "active"; } var prevState = "tocome"; if (prevItem) { if (prevItem.completed) prevState = "comp"; if (this.params.index >= i) prevState = "comp"; if (i == (this.params.index +1)) { if (prevItem.completed) prevState = "finished"; else prevState = "active"; } } var nextState = "tocome"; if (nextItem) { if (nextItem.completed) nextState = "comp"; if (this.params.index > (i+1)) nextState = "comp"; if (i == (this.params.index -1)) { if (nextItem.completed) nextState = "finished"; else nextState = "active"; } } return {currentItem:currentItem, currentState:currentState, prevItem:prevItem, prevState:prevState, nextItem:nextItem, nextState:nextState}; }, domOnClick: function(i) { this.index(i); }, resetFromHere: function() { for(var i = this.params.index + 1; i < this.params.wizData.length; i++) { this.params.wizData[i].completed = false; } this.invalidate(true); this.fireEvent('StateChange'); }, completed: function(value) { var item = this.params.wizData[this.params.index]; if (typeof(value) !== 'undefined') { if (item.completed != value) { item.completed = value; this.invalidate(true); this.fireEvent('StateChange'); } } else { if (typeof(item.completed) === 'undefined') item.completed = false; return item.completed; } }, index: function(value) { if (typeof(value) !== 'undefined') { if (this.params.index != value) { this.params.index = value; this.invalidate(true); this.fireEvent('IndexChange'); } } else { return this.params.index; } }, next: function() { if (!this.completed()) return; var index = this.index() + 1; if (this.params.wizData.length > index) { this.index(index); } }, prev: function() { var index = this.index() - 1; if (index >= 0) { this.index(index); } }, domOnMouseOver: function(i) { var states = this.calcStates(i); if (!states.prevItem) { $('#' + this.domId + '_start').addClass('start_hover'); } else { $('#' + this.domId + '_link' + i).addClass('link_' + states.prevState + '_hover'); } if (!states.nextItem) { $('#' + this.domId + '_end').addClass('end_hover'); } else { $('#' + this.domId + '_link' + (i+1)).addClass('link_hover_' + states.nextState); //alert('link_hover_' + states.nextState); } $('#' + this.domId + '_item' + i).addClass('item_hover'); }, domOnMouseOut: function(i) { var states = this.calcStates(i); if (!states.prevItem) { $('#' + this.domId + '_start').removeClass('start_hover'); } else { $('#' + this.domId + '_link' + i).removeClass('link_' + states.prevState + '_hover'); } if (!states.nextItem) { $('#' + this.domId + '_end').removeClass('end_hover'); } else { $('#' + this.domId + '_link' + (i+1)).removeClass('link_hover_' + states.nextState); } $('#' + this.domId + '_item' + i).removeClass('item_hover'); }, renderContents: function() { var out = []; var wizData = this.params.wizData; out.push(''); var hasInCompletes = false; for(var i = 0; i < wizData.length; i++) { var states = this.calcStates(i); if (states.prevItem) { if (states.prevItem.completed == false ) hasInCompletes = true; } var cbString = ""; if (this.params.index != i && !hasInCompletes) cbString = 'onmouseover="' + this.renderCallback('domOnMouseOver', i) + '" onmouseout="' + this.renderCallback('domOnMouseOut', i) + '" onclick="' + this.renderCallback('domOnClick', i) + '"'; if (states.prevItem) { if (states.prevState != "comp" && states.prevState != "finished") cbString = ""; } if (!states.prevItem) { out.push(''); } out.push(''); if (!states.nextItem) { out.push(''); } else { out.push(''); } } out.push('
'); out.push('
' + (i+1) + '
'); out.push('
' + states.currentItem.text + '
'); ('
'); return out.join(''); } }); var customControlVersion = {"LocalModifications":false,"Major":0,"Minor":0,"Name":"Oculos.Epd.Web","Revision":670};