Merge pull request #1285 from NativeScript/feature/action-item-page

Implement page property for ActionItem
This commit is contained in:
Alexander Vakrilov
2015-12-22 17:14:48 +02:00
3 changed files with 20 additions and 0 deletions

View File

@ -186,6 +186,17 @@ export function test_actionItem_inherit_bindingContext_inXML() {
TKUnit.assertEqual(actionItem.text, "success", "actionItem.text");
};
export function test_actionItem_page_property_inXML() {
var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar> <ActionBar.actionItems>" +
"<ActionItem text=\"test\" />" +
"</ActionBar.actionItems> </ActionBar> </Page.actionBar> </Page>");
var actionItem = p.actionBar.actionItems.getItemAt(0);
TKUnit.assertEqual(actionItem.page, p, "actionItem.page");
};
export function test_navigationButton_inherit_bindingContext_inXML() {
var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar>" +

View File

@ -297,6 +297,10 @@ export class ActionItem extends bindable.Bindable implements dts.ActionItem {
}
}
get page(): pages.Page {
return this.actionBar ? this.actionBar.page : undefined;
}
public _raiseTap() {
this._emit(ActionItem.tapEvent);
}

View File

@ -128,6 +128,11 @@ declare module "ui/action-bar" {
*/
actionBar: ActionBar;
/**
* Gets the page that contains the action item.
*/
page: pages.Page;
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").