On Wednesday, October 1, 2014 4:13:52 PM UTC-7, skye riquelme wrote:
>
> Humm....no answers....what I need to know is how to write a call to
> showPopup macro from inside javascript.......seems it should be possible
> and easy, but I cant get it right, and no-one is answering my question...
>
var popupScript="tiddler:upload_PDF label:upload width:400px
popupClass:sticky";
var uploadDoc='<script
label="uploadable">localStorage.docTipo="temaDocumento";localStorage.fonte="'
+itemDetails[0]+'";config.macros.showPopup('+popupScript+');</scri'+'pt><<setIcon
Logos/smallPDF.png "" notext>>';
display uploadDoc;
ShowPopupPlugin doesn't provide a direct API to trigger display of an
arbitrary popup. Rather, the handler for the <<showPopup>> macro creates a
button (link) with certain attributes (using values it unpacks from the
macro parameters), and then sets the "onclick" handler for that link to
invoke the popup. However, in your case, you don't want another button
created.. you just want to use the button created by InlineJavscriptPlugin
to trigger the popup ShowPopupPlugin handling.
The good news is that there is a way to trick the handlers to do what you
want: in your inline script code, first set the required attributes on the
button, and then trigger the ShowPopupPlugin click handler, using the
button from the InlineJavascript code as the 'root' of the popup, like this:
<script label="upload">
localStorage.docTipo="...";
localStorage.fonte="...";
place.setAttribute("tid","GettingStarted");
place.setAttribute("popupClass","sticky");
place.setAttribute("width","400px");
config.macros.showPopup.click.apply(place,event);
</script>
Notes:
* "place" is defined by InlineJavascriptPlugin to be the button (link) that
was clicked on
* "event" is defined by the browser itself as part of the onclick
processing.
* .apply(...) allows the macro's click handler to be invoked in the correct
context, so that it will use the button from the inline script, rather than
the button it normally creates on it's own.
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
http://TiddlyTools.github.com/fundraising.html#MakeADonation
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.