';
return html;
},
_getEditPageContent:function(app){
var html = '
';
html +='';
html+='
';
return html;
},
_getEditPageGroup: function(group){
var html = '
';
html += '
';
html += this.htmlEncode(this._getMessageFromObject(group.title));
html+='
';
if (group.propertyList){
for (var i = 0 ; i ';
return html;
},
_getEditPageProperty: function(property, group){
var html = '
';
if (property.control && this._getMessageFromObject(property.control.label)){
html +='
';
html += this.htmlEncode(this._getMessageFromObject(property.control.label));
html+='
'
}
html +='
';
html += this._getEditPagePropertyControl(property, group);
html+='
';
html+='
';
return html;
},
_getEditPagePropertyControl: function(property, group){
var type;
if (property.control){
type = property.control.type;
}
if (!type){
type = 'text'; // Default control type
}
var name = property.name;
var valueList = this._getPropertyValueList(property);
var size = this._getControlAttribute(property, 'size', 25);
var isDisabled = false;
if (property.control && property.control.dependsOnChoice){
var p = this._getPropertyByName(property.control.dependsOnChoice.name, group);
if (p){
var v = this._getPropertyValueList(p);
isDisabled = (this.indexOf(v, property.control.dependsOnChoice.value) == -1)
}
}
var id = this._generateId();
property.controlId = id;
property.dependents = this._getDependentProperties(name, group);
var html = '';
if (type == 'text'){
var value = valueList.length > 0 ? valueList[0]: '';
// Text control
html += '';
}else if (type == 'radio' || type=='checkbox'){
// Radio control
for (var i = 0; i < property.control.choiceList.length; i++){
var isChecked = (( valueList.length == 0) && i == 0 && type == 'radio') ||
(this.indexOf(valueList, property.control.choiceList[i].value) != -1);
html += this._getChoice(property, property.control.choiceList[i], type, name, group, isChecked, isDisabled, id);
}
} else if (type == 'cmobject'){
var propertyName = this.htmlEncode(name);
var parentID = this.getUniqueId('objectSelect');
var selectorID = this.getUniqueId(propertyName);
var validTypes;
if (property.control.value == undefined) {
validTypes = property.control.valueList;
} else {
validTypes = new Array(property.control.value);
}
var _self = this;
function objectSelectOkCallback(cmObjs) {
var cmObj = cmObjs[0];
document.getElementById(selectorID + "_tooltip").innerHTML = cmObj.tooltip + ' ';
document.getElementById(selectorID + "_input").value = cmObj.storeID;
document.getElementById(selectorID + '_input').value = cmObj.storeID;
document.getElementById(selectorID + '_inputImg').value = cmObj.iconLink;
document.getElementById(selectorID + '_inputPath').value = cmObj.pathString;
document.getElementById(selectorID + '_inputName').value = cmObj.tooltip;
document.getElementById(selectorID + "_path").innerHTML = cmObj.pathString;
document.getElementById(selectorID + "_icon").src = cmObj.iconLink;
document.getElementById(selectorID + "_tooltip").innerHTML = cmObj.tooltip + ' ';
document.getElementById(selectorID + "_clear").style.display = 'block';
objectSelectCancelCallback();
}
function objectSelectCancelCallback() {
document.getElementById(selectorID).style.display = 'none';
document.getElementById(_self.getUniqueId('EditorMain')).style.display = 'block';
}
//Create CMObjectSelect instance
if (!this.objectSelectMap[selectorID]) {
this.objectSelectMap[selectorID] = new CMObjectSelect(selectorID, parentID, objectSelectCancelCallback, objectSelectOkCallback, validTypes, this.context);
this.objectSelectMap[selectorID].render();
}
var input = '';
var inputImg = '';
var inputPath = '';
var inputName = '';
var path = '';
var icon = '';
var tooltip = '';
var clearVisibility = 'none';
if (this.context.settings[this.htmlEncode(name)] != undefined && this.context.settings[this.htmlEncode(name)] != '') {
input = this.context.settings[this.htmlEncode(name)];
inputImg = this.context.settings[this.htmlEncode(name) + '.img'];
inputPath = this.context.settings[this.htmlEncode(name) + '.path'];
inputName = this.context.settings[this.htmlEncode(name) + '.name'];
path = this.context.settings[this.htmlEncode(name) + '.path'];
icon = this.context.settings[this.htmlEncode(name) + '.img'];
tooltip = this.context.settings[this.htmlEncode(name) + '.name'] + ' ';
clearVisibility = 'block';
}
html += '' + path + '';
html += '';
html += '' + tooltip + '';
html += 'Select an object... ';
html += 'Clear';
html += '';
html += '';
html += '';
html += '';
}
return html;
},
_getChoice:function(property, choice, type, name, group, checked, isDisabled, id){
var choiceDependents = property.dependents[choice.value];
var hasDependents = choiceDependents && choiceDependents.length > 0;
var html = '';
html += this.htmlEncode(this._getMessageFromObject(choice.label)) + ' ';
// Render dependent properties
if (hasDependents){
html +='
';
for (var i = 0; i < choiceDependents.length; i++){
html += this._getEditPageProperty(choiceDependents[i], group);
}
html+='
';
}
return html;
},
_getPropertyValueList: function(property) {
var value = this.context.getSettingValues(property.name);
if(value === undefined && property.control){
value = property.control.defaultValueList;
}
if(value === undefined){
value = [];
}
return value;
},
_getControlAttribute: function(property, attribute, defaultValue ){
var value;
if(property.control){
value = property.control[attribute];
}
if (!value){
value = defaultValue;
}
return value;
},
_getPropertyById:function(id){
if (this.currentApp.properties && this.currentApp.properties.propertyGroupList ){
for (var i = 0 ; i< this.currentApp.properties.propertyGroupList.length; i++){
var group = this.currentApp.properties.propertyGroupList[i];
if (group.propertyList){
for (var i = 0 ; i ';
var icon = this.applications.applicationList[i].icon;
html += '
'
if (icon){
html += '
';
html += '';
html += '
';
}else{
html += '
';
html += '';
html += '
';
}
html += '
';
html += '
';
html += this.htmlEncode(this._getMessageFromObject(this.applications.applicationList[i].title));
html += '
';
html += '
';
html += this.htmlEncode(this._getMessageFromObject(this.applications.applicationList[i].description));
html += '
';
html += '
';
html += '';
html +='
';
}
}
html+='';
var mainDiv = document.getElementById(this.getUniqueId('EditorMain'));
mainDiv.innerHTML = html;
var _self = this;
var entries = this.getElementsByClassName(mainDiv, 'cogAppEntry');
for (var i = 0 ; i < entries.length; i++){
entries[i].onclick = function(event){
_self.renderApplicationSettings(this.id);
};
}
},
_objectSelectClear: function(selectorID) {
document.getElementById(selectorID + "_path").innerHTML ='';
document.getElementById(selectorID + "_icon").src = '';
document.getElementById(selectorID + "_tooltip").innerHTML = '';
document.getElementById(selectorID + "_clear").style.display = 'none';
document.getElementById(selectorID + "_input").value = '';
document.getElementById(selectorID + "_inputPath").value ='';
document.getElementById(selectorID + "_inputImg").value = '';
document.getElementById(selectorID + "_inputName").value = '';
},
_objectSelect:function(selectorID) {
document.getElementById(this.getUniqueId('EditorMain')).style.display = 'none';
document.getElementById(selectorID).style.display = 'block';
this.objectSelectMap[selectorID].resizePager();
},
/******* Utility functions ******/
scope: function(scope, func){
return function(){
func.apply(scope, arguments);
}
},
getElementsByClassName: function(node, className){
return node.getElementsByClassName(className);
},
indexOf: function(array, value){
return array.indexOf(value +'');
},
/*Not used so far */
replaceTokens:function(template, tokenValues){
for (var name in tokenValues){
template.replace('$'+name+'$', tokenValues[name]);
}
return template;
},
/*Not used so far */
cancelEventBuble: function(e){
var evt = e ? e:window.event;
if (evt.stopPropagation){
evt.stopPropagation();
}
if (evt.cancelBubble!=null){
evt.cancelBubble = true;
}
},
htmlEncode: function(text)
{
return text.toString()
.replace(/\&/g, "&")
.replace(//g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
},
/*Not used so far */
getCssMapping: function(originalClass) {
var newClass = this.context.getCssMapping(originalClass);
if (!newClass) {
return originalClass;
}
return newClass;
}
}