Here is script we threw together.
Changes:
1) It allows the Aboutview to accept persist data being passed in.
2) It fixes the Widget Naem truncation not being set
Passing in data to the view:
CODE
{BackButtonTitle: 'Sample Widget Information'+temp,
pages: [
{
id: 'copyright',
name: $_('copyright_policy'),
srcString: $_('copyright_policy_body_string')
},
{
id: 'tos',
name: $_('tos'),
srcString: $_('tos_body_string')
},
{
id: 'privacy',
name: $_('privacy_policy'),
srcString: $_('privacy_policy_body_string')
}
]}
Full source:
CODE
// JavaScript Document
KONtx.views.AboutBox = new KONtx.Class({
ClassName: 'AboutBoxView',
Extends: KONtx.views.AboutBox,
config: {
BackButtonTitle: 'About',
buttons: {}
},
updateView: function() {
//fix the truncation on the title
var wid = Theme.keys.sidebar.width - 10*(screen.availHeight/540);
this.metadataName.setStyles({width: wid, truncation:"end"});
print($dump(this.persist));
if(!this.persist){return;}
if(this.persist.BackButtonTitle) {this.backButton.setText(this.persist.BackButtonTitle);}
if(this.persist.name){ this.metadataName.setText(this.persist.name); }
if(this.persist.description) { this.metadataDescription.setText(this.persist.description); }
if (this.metadataUrl && (widget.authorURL || widget.url)) {
this.metadataUrl.setText(this.persist.authorURL || this.persist.url)
}
if(this.persist.copyright){ this.metadataCopyright.setText( KONtx.utility.INTL.get('COPYRIGHT') + ' ' + this.persist.copyright); }
if(this.persist.pages){this.updateButtons(this.persist.pages);}
},
updateButtons: function(set) {
for(i in set)
{
this.config.buttons[set[i].id].setText(set[i].name)
this.config.buttons[set[i].id].config.value = set[i].srcString || "";
}
},
createView: function() {
KONtx_automation_log("function","KONtx.views.AboutBox","createView");
var providedPages = ['copyright', 'tos', 'privacy'];
var buttonHeight = Theme.getStyles('ControlTextButton', 'normal').height;
this.backButton = new KONtx.control.BackButton({
guid: this._ktxID+'.BackButton',
label: this.config.BackButtonTitle,
}).appendTo(this);
//log("this.config.pages",$dump(this.config.pages));
var list = [];
// validate the pages
if (this.config.pages instanceof Array) {
var page = null;
for (var i = 0; i < this.config.pages.length; i++) {
page = this.config.pages[i];
if (providedPages.indexOf(page.id) > -1) {
// this check allows someone to provide a srcString in their config
// if one isn't provided, then we do the XML lookup below
if(!('srcString' in page)) {
try {
page.srcString = filesystem.readFile('About/' + yahooSettings.get('countryCode') + '/' + page.id + '.txt');
} catch (e) {
page.srcString = '';
}
}
list.splice(0, 0, page);
} else {
list.push(page);
}
}
//this.config.pages.length = (this.config.pages.length > 5) ? 5 : this.config.pages.length;
list.length = (list.length > 5) ? 5 : list.length;
//log("this.config.pages",$dump(this.config.pages,3));
} else {
this.config.pages = [];
}
var menuHeight = buttonHeight * this.config.pages.length;
var contentHeight = this.height - (menuHeight + this.backButton.height);
var contentContainer = new KONtx.element.Container({
styles: {
width: this.width,
height: contentHeight,
vOffset: this.backButton.height
}
}).appendTo(this);
var containerBackground = new KONtx.element.Image({
src: Theme.storage.get('AboutBoxView.containerBackground', 'source'),
styles: Theme.storage.get('AboutBoxView.containerBackground', 'styles')
}).appendTo(this);
var widgetIcon = widget.getImage(Theme.keys.screen + '.icon'),
themeIcon = Theme.storage.get('AboutBoxView.metadataIcon', 'source');
var metadataIcon = new KONtx.element.Image({
element: widgetIcon || Image,
styles: Theme.storage.get('AboutBoxView.metadataIcon', 'styles')
}).appendTo(contentContainer);
widgetIcon || metadataIcon.setSource(themeIcon);
var metadataIconOverlay = new KONtx.element.Image({
src: Theme.storage.get('AboutBoxView.metadataIconOverlay', 'source'),
styles: Theme.storage.get('AboutBoxView.metadataIconOverlay', 'styles')
}).appendTo(contentContainer);
//
// vOffset is provided in theme for metadataName
// rest are y-positioned relative to previous node
//
this.metadataName = new KONtx.element.Text({
label: widget.name,
styles: Theme.storage.get('AboutBoxView.metadataName', 'styles')
}).appendTo(contentContainer);
this.metadataDescription = new KONtx.element.Text({
label: widget.description,
styles: Theme.storage.get('AboutBoxView.metadataDescription', 'styles')
}).setStyles({
vOffset: this.metadataName.height + this.metadataName.vOffset
}).appendTo(contentContainer);
var PAD = Theme.storage.get('AboutBoxView.metadataAuthorNote', 'PAD_TOP');
this.metadataAuthorNote = new KONtx.element.Text({
label: KONtx.utility.INTL.get('WIDGET_BY') + '...',
styles: Theme.storage.get('AboutBoxView.metadataAuthorNote', 'styles')
}).setStyles({
vOffset: this.metadataDescription.height + this.metadataDescription.vOffset + PAD
}).appendTo(contentContainer);
this.metadataAuthor = new KONtx.element.Text({
label: ($empty(widget.author) || (widget.author == widget.company)) ? widget.company : widget.author + ', ' + widget.company,
styles: Theme.storage.get('AboutBoxView.metadataAuthor', 'styles')
}).setStyles({
vOffset: this.metadataAuthorNote.height + this.metadataAuthorNote.vOffset
}).appendTo(contentContainer);
this.metadataVersion = new KONtx.element.Text({
label: widget.version,
styles: Theme.storage.get('AboutBoxView.metadataVersion', 'styles')
}).setStyles({
vOffset: this.metadataAuthor.height + this.metadataAuthor.vOffset,
}).appendTo(contentContainer);
if (widget.authorURL || widget.url) {
PAD = Theme.storage.get('AboutBoxView.metadataUrlNote', 'PAD_TOP');
this.metadataUrlNote = new KONtx.element.Text({
label: KONtx.utility.INTL.get('MORE_INFO') + '...',
styles: Theme.storage.get('AboutBoxView.metadataUrlNote', 'styles')
}).setStyles({
vOffset: this.metadataVersion.height + this.metadataVersion.vOffset + PAD
}).appendTo(contentContainer);
this.metadataUrl = new KONtx.element.Text({
label: widget.authorURL || widget.url,
styles: Theme.storage.get('AboutBoxView.metadataUrl', 'styles')
}).setStyles({
vOffset: this.metadataUrlNote.height + this.metadataUrlNote.vOffset
}).appendTo(contentContainer);
}
PAD = Theme.storage.get('AboutBoxView.metadataCopyright', 'PAD_BOTTOM');
this.metadataCopyright = new KONtx.element.Text({
label: KONtx.utility.INTL.get('COPYRIGHT') + ' ' + widget.copyright,
styles: Theme.storage.get('AboutBoxView.metadataCopyright', 'styles')
}).setStyles({
vOffset: contentContainer.height - PAD
}).appendTo(contentContainer);
PAD = Theme.storage.get('AboutBoxView.metadataReserved', 'PAD_BOTTOM');
this.metadataReserved = new KONtx.element.Text({
label: KONtx.utility.INTL.get('RIGHTS_RESERVED'),
styles: Theme.storage.get('AboutBoxView.metadataReserved', 'styles')
}).setStyles({
vOffset: contentContainer.height - PAD
}).appendTo(contentContainer);
if (list.length) {
var button = null;
this.buttonContainer = new KONtx.element.Core({
styles: {
height: (buttonHeight * list.length),
vAlign: 'bottom'
}
}).appendTo(this);
//log("page.srcString",page.srcString);
for( i in list)
{
if (list[i] instanceof KONtx.element.Button) {
button = page;
} else {
button = new KONtx.control.TextButton({
id: list[i].id,
label: list[i].name,
value: list[i].srcString,
styles: {
vOffset: button ? button.outerHeight : 0
},
events: {
onSelect: function(event) {
var viewClass = KONtx.system.AboutDocView;
//log("this.config.value",this.config.value);
var viewConfig = {
id: this._ktxID + '.' + viewClass.prototype.ClassName + '.' + animator.milliseconds,
data: {
guid: this.config.guid,
backLabel: this.config.label,
value: this.config.value
},
viewClass: viewClass
};
KONtx.application.addViewConfig(viewConfig);
KONtx.application.loadView(viewConfig.id, {
documentText: this.config.value
});
}
}
});
}
this.config.buttons[list[i].id] = button;
button.appendTo(this.buttonContainer);
}
}
// EJF : 2009-06-04 : adding missing custom content area back into about box
if ( this.config.customContent ) {
// lock down this custom content so it can't destroy the rest of the page
var customContentHeight = KONtx.utility.scale( 100 ),
customContentWidth = KONtx.utility.scale( 100 );
this.customContent = new KONtx.element.Container( {
styles: {
height: customContentHeight,
width: customContentWidth,
hOffset: this.width - ( customContentWidth + KONtx.utility.scale( 5 ) ),
vAlign: 'bottom',
vOffset: this.height - ( buttonContainer.height + KONtx.utility.scale( 5 ) ),
}
} ).appendTo( contentContainer );
this.config.customContent.appendTo( customContent );
}
}
});