[tw] Re: Conditional MarkupPreHead

2010-10-04 Thread colmjude
On Oct 4, 8:10 pm, elnoi elnoi...@gmail.com wrote:
 Hello all,
 I'm developing a web page using TW and I was wondering if is it
 possible to do an iPhoneMarkupPreHead that
 only loads when the device is an iPhone.

Hi einoi,

What sort of thing are you looking to apply to the iphone only?
If it is just css then you can just use media queries, either in the
MarkupPreHead linking out to an external stylesheet or you can use
media queries in the StyleSheet tiddlers of your tiddlywiki.

TiddlySpace[1] uses this sort of technique. Here is an example
@media all and (max-device-width: 480px) {
div.toolbar { visibility:visible;}
}

Hope that is the sort of thing you needed

Colm

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: Conditional MarkupPreHead

2010-10-04 Thread Eric Shulman
  Hello all,
  I'm developing a web page using TW and I was wondering if is it
  possible to do an iPhoneMarkupPreHead that
  only loads when the device is an iPhone.

Whenever you *save* a TiddlyWiki document, the contents of
MarkupPreHead (and other Markup* tiddlers) are copied directly into
the TiddlyWiki source document, so that they will be automatically
processed by the browser when it loads the document.

Note that this processing occurs BEFORE the 'onLoad' event is
triggered, so NONE of the TiddlyWiki code has been invoked yet.  As a
consequence, you cannot use TiddlyWiki syntax within a Markup tiddler.

However, *ALL* the normal browser-based syntax (HTML/CSS/Javascript)
can be used (including script.../script blocks -- which are not
natively supported by TiddlyWiki unless you add
http://www.TiddlyTools.com/#InlineJavascriptPlugin)

Thus, to conditionalize the loading of MarkupPreHead content, you
should be able to use some Javascript to check the browser's
navigator.userAgent variable and then only invoke the remainder of the
content if the desired browser is detected.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: Conditional MarkupPreHead

2010-10-04 Thread elnoi
Colm,
Thanks for the reponse probably I'll use for other purposses.

Eric,
I have InlineJavascriptPlugin in this TW but I don't know how to use
the javascript
to detect the navigator.userAgent.
At this moment I have this piece of code.
// ![CDATA[
if ((navigator.userAgent.indexOf('iPhone') != -1) ||
(navigator.userAgent.indexOf('iPod') != -1) ||
(navigator.userAgent.indexOf('iPad') != -1))
{ config.shadowTiddlers.MarkupPreHead='[[IphoneMarkupPreHead]]';
} // ]]
But I don't know if is correct.

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: Conditional MarkupPreHead

2010-10-04 Thread Eric Shulman
 At this moment I have this piece of code.
 // ![CDATA[
         if ((navigator.userAgent.indexOf('iPhone') != -1) ||
 (navigator.userAgent.indexOf('iPod') != -1) ||
 (navigator.userAgent.indexOf('iPad') != -1))
 { config.shadowTiddlers.MarkupPreHead='[[IphoneMarkupPreHead]]';
         } // ]]
 But I don't know if is correct.

That code will not work... and shows a misunderstanding about the
MarkupPreHead content

First
you CANNOT make reference ANY TiddlyWiki runtime variable (such as
config.shadowTiddlers.*).  When the content injected into the source
file from MarkupPreHead is processed, the TiddlyWiki code has NOT been
invoked yet, so NONE of the TW runtime data exists!

Second...
Even if you could re-assign the value of the MarkupPreHead SHADOW
tiddler, that content is not *processed* during startup.  The
processing occurs on a COPY of that content that was injected into the
source file when the document was *previously* saved.

Third...
The content you assigned into the shadow was simply a TiddlyWiki-
syntax *link* to a named tiddler.  As noted before, you CANNOT use
TiddlyWiki syntax in the Markup* tiddlers, because their content is
processed directly by the browser, without the availability of the
TiddlyWiki run time code.  In any event, even if this syntax was
supported, it would NOT *invoke* the content from IPhoneMarkupPreHead,
but simply place a TiddlyLink into the output.

What you need to do it to put the conditional statement AND *all* the
code it invokes *directly* into the MarkupPreHead tiddler, and don't
use any TW syntax or try to access TW run-time data from within that
code.

-e

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: Conditional MarkupPreHead

2010-10-04 Thread elnoi
Thanks a lot Eric,
I've done.

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.