Can I disable "Back" on a Google add-on card? - google-apps-script

I'm building a Google add-on using Google Apps Script.
Is there any way to disable the Back button on a card (indicated below)?

Answer:
This is not possible.
More Information:
From the documentation on card navigation (emphasis my own):
...the 🡰 button is always available for the user to navigate from your contextual cards to your non-contextual cards.

It is actually possible with a get around (might be a bit messy). Here is the way I did it in case someone is looking for this :
I manage all navigations from a card to another so that it doesn't stack the cards, but instead pop the current card and add the new one, so I always only have one card in the stack, therefore having no "back" button in the header of the card.
So, appart from the homepage trigger from the manifest which return directly a card.build(), I navigate from card to card using a function such as :
function showMainCard(e) {
var card = buildMainCard();
var nav = CardService.newNavigation().popCard().pushCard(card);
var actionresponse = CardService.newActionResponseBuilder()
.setNavigation(nav);
return actionresponse.build();
}
And the build[something]Card() function returns the card.build()
The only drawback is that when the add-on is reloaded, it goes back to the first card you build in the homepage trigger. In order to get around this, you need to save page navigation in userProperties when building each card.
Then, the homepageTrigger can work this way to load the right card :
function onLoad(e) {
// Create the card
switch (userProperties.getProperty("pageNavigation")) {
case pages.MAIN:
return buildMainCard();
case pages.CREATE_NEW_FILE_REQUEST:
return buildNewFileRequestCard();
case pages.MANAGE_DEFAULT_OPTIONS:
return buildManageDefaultOptionsCard();
case pages.MANAGE_OPTIONS:
return buildManageOptionsCard();
case pages.CREATE_NEW_FILE_REQUEST_AFTER_AUTHORIZATION:
return buildNewFileRequestCard();
case pages.SHOW_FILE_REQUEST_DETAIL:
return buildFileRequestDetailCard();
case pages.EDIT_FILE_REQUEST:
return buildEditFileRequestCard();
default:
console.log("Problem with navigation, main card is loaded");
return buildMainCard();
}
}

Related

What code should I paste into the HTML window of Wordpress to generate a large button which will randomly redirect to one of three websites?

I'm using a basic Wordpress (or Google Sites) page to randomly redirect to one of three URLs. I'm not sure how to do this in HTML. The idea is to have a big button in the middle of the page which, on click, will send you to one of three links randomly. Any advice would be appreciated.
You couldn't do that only with html, you will need to do that with javascript.
You must store the links in an array and on click on the button call a function that randomly choose a link and go to it.
In the example below I only display the chosen link so you can click how many time you want to see the link change. Remove the line that do that and uncomment the line that make the redirection work.
var locations = ['https://google.com', 'https://stackoverflow.com', 'https://bing.com'];
document.getElementById("redirectButton").onclick = function () {
var link = locations[Math.floor(Math.random() * locations.length)];
// Remove this line
document.querySelector('.link').innerText = link;
// Uncomment this line
// location.href = link;
};
<button id="redirectButton">Random redirection</button>
<!-- You don't need that --> <p class="link"></p> <!-- Remove it on your site-->

How to refresh particular div in the html

I am getting a problem to reflect the value in the view, I don't want to load the complete page because its very costly to load the page,
I have two controllers(controller1 and controller2), one service(service1) and two views(modalwindow.html and product.html).
The scenario is:
1.User is on product.html(contains multiple accordions) and user explicitly close all the accordions.
2.User clicked on icon which opened modal window, since it's opened the modal window it's not going to change the URL on the address bar.
3.Modal window(Modalwindow.html ) has the link of show product, since the product page is the active page(show product is the accordion which closed by user explicitly) on the browser.
on the click of link, appropriate accordion should be open on the product.html
I am communicating between modal window controller (controller2.js) and product page(controller1.js) through service (service.js), I am calling controller2
how to fix this issue without loading a complete page
Assuming the modal closes when a product is selected, it can return the value to the calling controller. Then it opens the specified accordion.
I fiddled around in your fiddle. You are mixing two ways of showing your categories in the fiddle: an accordion value, and two boolean values (categoryAccordion, productAccordion). I moved to using one way and it seems to work with the eventCallback. Also, you checked wrongly for your 'args' in the eventCallback. You're passing it back as an array, so get the value out of the array first.
Also, you checked wrongly for your 'args' in the eventCallback.`
if (args[0] == 'Product') {
$scope.productAccordion = true;
$scope.categoryAccordion = false;
} else {
$scope.productAccordion = false;
$scope.categoryAccordion = true;
}
See fiddle.
Should it not be working in your real code, it might have something to do with the following SO question.

Highslide: how to use only specific images

How do I make my highslide gallery take only specific images (e.g., contained in a specific div)?
I've got a gallery here: http://civicsector.org.ua/agitation/247-kampanya-chesn-vibori.html, but the problem is that the CMS I'm using outputs the content twice: once for a desktop screen, and once for a mobile screen.
While highslide is loading images from both divs (for desktop and for mobile), the images in the thumbstrip get duplicated.
How do I fix this?
Thanks.
Place your images into a slideShowGroup, per the Highslide JS API:
http://highslide.com/ref/hs.slideshowGroup
Then, the script will load only the images that are tagged as belonging to that group. The references to the images that your CMS creates won't be tagged as belonging to the group, so they won't get loaded into the slideshow twice.
MisterNeutron's answer was perfect for the common usage of highslide. However, in case anyone would use unobtrusive highslide (like myself), you just have to add a check in the hs.onSetClickEventHandler:
hs.onSetClickEvent = function ( sender, e ) {
if ($(e.element).closest('.hidden-desktop').length>0) {
return false;
}
// set the onclick for the element
e.element.onclick = function () {
return hs.expand(this, inPageOptions);
}
// return false to prevent the onclick being set once again
return false;
}

Return Selection from LonglistSelector to calling Page in windows phone 8

I have a mainpage with a Button with some content. I want to open a second page or popup in witch i must have a longlistselector with X items in it. when i choose one of them i want to change the content of the button to the selected item.
I can make the main page and the second page i dont know how to send back the result to the first page. ?
if you are using "MVVM Light" library then you can use Messenger service Like this....
in second page after selection is changed send a message
Messenger.Default.Send<type>(message,token);
and then in the consructor of page 1 viewmodel
Messenger.Default.Register<type>(this,token,Method);
here token should be same as sender token....
then
void Method(type message)
{
button.content = message;
}
Use Popup to show your LongListSelector ,and when set popupElement.IsOpen=false; the set Button Content same as required,
If you wish to change content as selected list then use popupElement.IsOpen=false; on selection change method and get selected item there.
Remember use selection change method on page not inside popup child class.
If you are using a separate page to show the longlistselector, then you could try something like this.
//in long list page,
Void longlist_SelectionChanged()
{
PhoneApplicationService.Current.State["key"] = longlist.selecteditem;
NavigationService.GoBack();
}
//in your main page where the selected data has to be displayed..
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if(PhoneApplicationService.Current.State.ContainsKey("key"))
{
Button.Content = PhoneApplicationService.Current.State["key"];
}
}

Continuous Pagination with LongListSelector

When my LongListSelector is scrolled to bottom, I want to automatically load more data from a web service. Just like the Store app does. My problem is that I can't found any event to trigger the load more action.
The recommandation from Microsoft is to use the LongListSelector.ItemRealized event, check if it's the last item (or the Nth last item) in the list to be "realized" and if it is, then it will start fetching new records. In terms of UX, it's best to show a ProgressIndicator on the SystemTray at the time and not try to imitate iOS with inline spinners.
LongListSelector.ItemRealized is actually a very interesting event since it fires when an Item has been data bound to a virtualized ListBoxItem. That means that the LongListSelector virtualization logic thinks it needs to prepare the FrameworkElement to be shown on screen. The ListBoxItem may or may not be on screen yet, but it's a good indication it's getting there.
For a code sample see # http://code.msdn.microsoft.com/wpapps/TwitterSearch-Windows-b7fc4e5e
void resultListBox_ItemRealized(object sender, ItemRealizationEventArgs e)
{
if (!_viewModel.IsLoading && resultListBox.ItemsSource != null && resultListBox.ItemsSource.Count >= _offsetKnob)
{
if (e.ItemKind == LongListSelectorItemKind.Item)
{
if ((e.Container.Content as TwitterSearchResult).Equals(resultListBox.ItemsSource[resultListBox.ItemsSource.Count - _offsetKnob]))
{
Debug.WriteLine("Searching for {0}", _pageNumber);
_viewModel.LoadPage(_searchTerm, _pageNumber++);
}
}
}
}