Accessing the Selected property on TitleBar tabs - titlebar

I am using the Application Layout control and have tabs in the TitleBar. I want to change the style of the tab if it is selected. I am currently doing it by comparing the value of the tab to a sessionScope variable I am setting when the tab is clicked.
I saw something (though I can't find it now) about using the Selected property of the Basic Node I am using for the tab. How would I access that in SSJS so that I can do something like this?
if(thisnode.selected) {
return "lotusTabs liActive";
} else {
return "lotusTabs li";
}
Thanks.

You can also access the tabs programmatically:
var layout = getComponent("layoutId");
var selectedTab = null;
var tabs = layout.getConfiguration().getTitleBarTabs();
for (var tab in tabs) {
if (tab.getSelected()) {
selectedTab = tab;
}
}

The following CSS rule will target the selected title tab:
div.lotusTitleBar ul.lotusTabs li.lotusSelected {
// your code here
}

Related

Change toolbars according to the condition

I am working with xamarin android. I have a layout where initially a toolbar with edit will be visible, when user selects edit the current tool bar should be replaced with another toolbar. I have written code as following.
public override bool OnCreateOptionsMenu(IMenu menu)
{
_localMenu = menu;
var toolbar = _isMultiSelect ? Resource.Menu.MultipleFormsDeleteToolBarMenu : Resource.Menu.FormToolbarMenu;
MenuInflater.Inflate(toolbar, menu);
return base.OnCreateOptionsMenu(menu);
}
And when Edit option in first toolbar is selected, Iam calling OnCreateOptionsMenu
else if (item.ItemId == Resource.Id.edit)
{
_isMultiSelect = true;
OnCreateOptionsMenu(_localMenu);
}
Here the problem is,instead of showing second toolbar... the Edit option in first toolbar is replaced by three dots and while tapping on those three dots Edit and Delete options are dislaying.
How can I change those toolbars acconding to the requirements?

Weird behavior of back button for fragments within fragments

Hi I have a navigation drawer and am showing fragments based on selection from the navigation drawer. I have a tab layout along with view pager in majority of my fragments. And coming to the weird behavior, in one of the tabs I'm having to again switch fragments based on user behavior which is working as expected but when I press the back button the whole fragment is getting popped instead of the child fragments being popped first.
This is how I'm populating the tabbed fragment from mainActivity
fragment = new EquipmentFragment();
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.content_frame, fragment)
.AddToBackStack(null).Commit();
This is how I've setup the tabLayout and viewPager
TabLayout tabLayout = view.FindViewById<TabLayout>(Resource.Id.tab_layout);
_viewpager = view.FindViewById<ViewPager>(Resource.Id.viewpager);
SetupViewPager(_viewpager);
tabLayout.SetupWithViewPager(_viewpager);
This is how I'm switching fragments within one of my tabs
FragmentTransaction transaction = FragmentManager.BeginTransaction();
transaction.AddToBackStack(null);
transaction.Add(Resource.Id.fragmentContainer, fragment);
transaction.Commit();
but pressing on back button results in the whole tabbedFragment being popped instead of the child items being popped first
You can override the "OnBackPressed" and the "OnOptionsItemSelected" and check, and here you need to handle the back navigation - determine whether to pop from ChildFragmentManager, FragmentManager, or finish the activity.
It could look something like this:
public override void OnBackPressed()
{
var didPopFromFragment = TryPopFromFragment();
if (didPopFromFragment == false)
{
Finish();
}
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Android.Resource.Id.Home:
var didPopFromFragment = TryPopFromFragment();
if (didPopFromFragment)
{
return true;
}
break;
}
return false;
}
private bool TryPopFromFragment()
{
var hasChildFragments = yourFragment.ChildFragmentManager.BackStackEntryCount > 0;
if (hasChildFragments)
{
yourFragment.ChildFragmentManager.PopBackStack();
}
return hasChildFragments;
}
... hope it helps.

How test Vaadin Accordion tabs?

I have created a Vaadin (7.4.3) accordion with a number of captions/tabs.
I need to be able to select a tab and check the contents within that tab.
However in the code below, even though the tab is found, the click() function
does not expand the tab and the contents of the tab remain unobtainable.
How can I check the contents of the tabs in an accordion?
Thank you...
List<WebElement> tabList = findElements(By.className("v-accordion-item"));
WebElement selectedTab = null;
for (WebElement tab : tabList) {
List<WebElement> captionElements = tab.findElements(By
.className("v-captiontext");
if (captionElements.size() > 0) {
if (captionElements.get(0).getText().equals("Caption_of_tab_to_be_checked")) {
// this is run
selectedTab = tab;
break;
}
}
}
selectedTab.click(); // the accordion does not open this tab and contents are still hidden???
TabSheetElement
tabSheetElement=$(TabSheetElement.class).id(TAB_AUTOMATIC_EMAIL);
tabSheetElement.openTab(2);
the Same you can check for multiple Tabs by adding click(); at last for example
tabSheetElement.openTab(2).click();

Tab to Window or Vice Versa in Firefox AddOn

In a Firefox AddOn, is there a way to get a window object from a tab object? Or vice versa? For instance, if I get a TabClose event, is there a way to get the associated window object?
Yes in TabClose the event argument holds a lot of useful stuff:
function tabclosee(e) {
console.error('TabClose, e:', e);
}
gBrowser.tabContainer.addEventListener("TabAttrModified", tabclosee, false);
So in this image we see that e.view is the DOMWindow (xul window/chrome window). The target is the tab element, in the close situation the HTMLWindow was destoryed so e.target.linkedBrowser will be null, but in TabSelect it won't be null and you can access the html window like e.target.linkedBrowser.contentWindow
If you want window from tab object you can do this too: e.target.ownerDocument.defaultView, this is the same as doing e.view above.
From window you can access all tabs like this:
if (aDOMWindow.gBrowser && aDOMWindow.gBrowser.tabContainer) {
var tabs = aDOMWindow.gBrowser.tabContainer.childNodes;
for (var t=0; t<tabs.length; t++) {
var tab = tabs[t];
var tab_linkedBrowser = tab.linkedBrowser;
var tab_htmlWin = tab.linkedBrowser.contentWindow;
}
}

How to get the tab Index of the right clicked inactive tab?

Who to get the tab Index of the right clicked tab that fires the Tab context-menu. Tab is NOT the active tab (not the selectedIndex)?
As an example. "Close Tabs to the Right" in Tab context menu works regardless of which tab (active/not-active) tab is right-clicked. How does it get the correct tab index?
Listen for for the popupshown event of the tabContextMenu element.
Since this a restartless addon I assume that you already have a reference to the ChromeWindow.
var tabContextMenu = chromewin.document.getElementById("tabContextMenu");
tabContextMenu.addEventListener("popupshown", function(){
var rightclickedtab = chromewin.TabContextMenu.contextTab;
// now proceed as you wish
}, false);
You can also add your own menu item and listen for its command event.
In any case, remember to cleanup when your extension gets unloaded.
What about on click take the event.target, which is the tab element, then loop through the parentNode of that tab element which has childNoedes of the tabs. then find your event.target in there?
So lick add on click listeners and do this:
var foundAtIndex = -1;
var tab = event.target;
var tabContainer = tab.parentNode;
var tabs = tabContainer.childNodes;
for (var i=0; i<tabs.length; i++) {
if (tabs[i] == tab) {
foundAtIndex = i;
break;
}
}
if (foundAtIndex !== -1) {
console.error('very weird, tab not found');
} else {
console.info('tab found at index:', foundAtIndex);
}

Resources