titanium - get the current window - titanium

I'd like to be able to show an error message (or maybe even a success message!) to the user. However, this would be for an asynchronous event - so it is presumably possible for the user to have jumped to another page in-between the sending for the event and the response.
Given that that is the case, and given that i use a tabgroup as the "base" in the initial app.xml, how am i meant to access the current window? Ti.UI.getCurrentWindow() doesn't do anything on my system - no error, no nothing.
I'm using the Titanium 3 api.

Since your using a tab group you can use Titanium.UI.currentTab. Then you can get the window of the tab like this:
var theWindow = Titanium.UI.currentTab.window;
Specific doc reference (just in case).
Also, you can always use a Titanium.UI.AlertDialog, that will show up no matter what window your on, if it meets your requirements.

Yes you can use
Ti.UI.currentTab.window().
and since this is function so use "()", otherwise it will not give correct output

to get current window use Ti.UI.getCurrentWindow and not Ti.UI.getCurrentWindow()

Ti.UI.currentWindow only works if there is a window already open. The error you have is coming from the fact that when you create the MasterView, you have not yet opened up the window.
Look inside ApplicationWindow.js, you will see that you create the masterview before even opening the window.
If you want to set navbar items, either add them in the ApplicationWindow, app.js, or pass the window to the MasterView.

currentTab only works if your app uses tabs.
currentWindow and getCurrentWindow() only work if the window was opened using the url property of the Ti.UI.createWindow method.
If you're in any other situation, the current window is just not available, it seems.

Related

Best way to run an action until expected condition is met in Nightwatch.js?

I am automating a portion of a website that kicks off a job when you click a button. The status of the job is reported on the page in another field, but it isn't automatically pushed. The end user needs to click a Refresh button inside the page to see the latest status.
Something like this
browser.expect.element('#status').text.to.equal('Done').before(10000);
would work if the data was pushed without using interaction, but since I have to manually click another button to get the latest status that wouldn't work.
Is there a built in method to do something every [interval here] until [condition true] or [timeout reached] in Nightwatch? I don't want to use a hard pause since the job could take more or less time depending how the server is feeling.
By another field do you mean an iFrame, svg or perhaps another tab/window?
You don't need manually, there is an option to switch to a different window with the following:
Window Handles + SwitchTo:
command(windowNum){
const result = browser.windowHandles();
let handle = result.value[windowNum];
browser.switchWindow(handle);
}
Refresh a page
browser.refresh();
I don't believe there is a built in method in Nightwatch but I'm sure you can use a for loop and an if statement

Aurelia: Show Dialog State In URL

I have a simple Aurelia application that displays accounts. The default view is a list of accounts. There's also an account details view.
I'd to make the details view open in a modal/dialog over the top of the list view. However, I want the presence of the modal to show up as part of the URL.
I found it easy to use the aurelia-dialog plugin to display the details view, but can't figure out how to get the dialog's presence to show up in the URL.
Another option might be to throw out aurelia-dialog and use a child router to display the details view, then figure out how to make that show and hide as a modal.
And, of course, another possibility is that there's a better way that I just don't see yet.
Has anybody seen or created something like this?
One possibility that occurs to me would be to add the dialog's presence as a parameter to the current route and then call it. You could use the route like /account?dialog=true. Run some tests to ensure that the ?dialog=true still routes to the same page. Then, use that route to check whether that parameter is set and display or hide the dialog window. When you refresh the page, the dialog window should still be open/closed. This also means that whenever you open or close the dialog window, you need to send a new route to the router (basically same route but different parameter).
This isn't a detailed solution but might get you on the right path.

GWTP - Identify when Presenter is removed from Slot

I want to add a confirmation popup when a user navigates away from one of my presenters and is replaced in a NestedSlot. Can I intervene before a place is revealed and check the current presenter?
Edit: I just learned that the PlaceManager has some support for this using the setOnLeaveConfirmation method. That said, I still don't think this will work for my case because I want the confirmation popup to be associated with a single nested presenter. I would also prefer to manually intervene because I already have a confirmation modal for a cancel button that I want to reuse.
It would have been simple if you could override window.confirm() using GQuery the same way as you can in JQuery, however that's not the case. Your best option is still using placeManager.setOnLeaveConfirmation(). You could probably emulate the same behaviour as window.confirm() with a PopupWidget, but then it wont block access to other parts of the page.

Difference between selenium.selectFrame() and selenium.selectWindow()

I've been struggling with the difference between the following commands, used while accessing widgets contained within iframes:
selenium.selectFrame("widget0");
selenium.selectWindow("name=widget0");
In the past (prior to IDE v1.0.12), I have been using these interchangeably, preferring the former over the latter in most cases. However, with 1.0.12, swapping them out after recording does not work. In what cases would each one be used?
Thanks.
selectFrame is the API of selenium to select a particular frame form HTML source.
Say, some HTML elements are present inside a iframe of HTML source, therefore u are
not able to take event on those elements until to use selectFrame API.
selectWindow will be used in those cases where after take some event a new browser popup
window open and u need to take action on the popup window instead of main browser page.
After doing ur operation u need to select back ur main browser window.

Determing whether dijit.dialog content has displayed

Does anyone know of a way to determine whether the content of a dijit.dialog has become visible to the user? As in if the content of the dialog has actually been displayed yet or not.
Thanks
There's also an onShow event that you could connect to, or even set:
dijit.byId("dialog1").onShow = function(){console.log("hello world")};
The function onDownloadEnd() is called when the dialog's download finishes.
You could connect your own code to that event using dojo.connect().