<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>littled.net &#187; javascript</title>
	<atom:link href="http://www.littled.net/new/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littled.net/new</link>
	<description>David Little&#039;s home on the Web</description>
	<lastBuildDate>Mon, 02 Aug 2010 11:57:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to close a jQuery dialog box by clicking outside of it</title>
		<link>http://www.littled.net/new/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/</link>
		<comments>http://www.littled.net/new/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 15:34:58 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[blog-post]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.littled.net/new/?p=392</guid>
		<description><![CDATA[JQuery gives you a very simple way to create dialog overlays with the dialog() event. So, by clicking an HTML element you can activate a &#8220;stay-on-the-page&#8221; overlay dialog box.
Traditionally one might use dialog boxes to ask the user a question to which she must respond (e.g. with an &#8220;Ok&#8221; or &#8220;Cancel&#8221;) but their use can [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />JQuery gives you a very simple way to <a href="http://docs.jquery.com/UI/Dialog">create dialog overlays</a> with the dialog() event. So, by clicking an HTML element you can activate a &#8220;stay-on-the-page&#8221; overlay dialog box.</p>
<p>Traditionally one might use dialog boxes to ask the user a question to which she must respond (e.g. with an &#8220;Ok&#8221; or &#8220;Cancel&#8221;) but their use can extend beyond this. For instance I&#8217;ve used a dialog to show a <a href="http://www.useit.com/alertbox/mega-dropdown-menus.html">mega drop-down menu</a>; i.e. clicking a link opens a dialog box with a list of categorised links.</p>
<p>JQuery&#8217;s default behaviour for closing dialog boxes is not unreasonable: the user must click on the &#8220;Close&#8221; button (e.g. in the form of text or an &#8220;x&#8221;) or hit the escape key. However it&#8217;s possible you may want to provide more options for your users to close a box by simply clicking outside it.</p>
<p>I puzzled over this and didn&#8217;t get very far with Googling but came up with the following solution which seems to work.</p>
<p>When your dialog is created, a div with the class &#8220;ui-widget-overlay&#8221; is also created which &#8220;greys out&#8221; the background allowing the user to fully focus on the dialog. You can use this as a hook to add your dialog closing code, e.g.</p>
<p><code><br />
$(".ui-widget-overlay").live("click", function() {  $("#quick-links-modal").dialog("close"); } );<br />
</code></p>
<p>In this case my dialog has the ID &#8220;quick-links-modal&#8221;. NB you need to use the &#8220;live&#8221; event (rather than &#8220;click&#8221; etc.)  in order to bind the event to your dialog before the dialog has been initiated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littled.net/new/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8220;Internet Explorer cannot open the Internet site&#8221; error</title>
		<link>http://www.littled.net/new/2008/08/01/internet-explorer-cannot-open-the-internet-site-error/</link>
		<comments>http://www.littled.net/new/2008/08/01/internet-explorer-cannot-open-the-internet-site-error/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 15:33:30 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[non-plone]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.littled.net/new/?p=66</guid>
		<description><![CDATA[So, Internet Explorer 6 has just claimed another hour and a half of my life by refusing to act like a decent browser and demanding its own specific hack.
The problem in question has been well-documented but most of the references I found to the solution linked to a website that is now defunct, so I [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />So, Internet Explorer 6 has just claimed another hour and a half of my life by refusing to act like a decent browser and demanding its own specific hack.</p>
<p>The problem in question has been well-documented but most of the references I found to the solution linked to a website that is now defunct, so I thought I&#8217;d include my own solution below in case it&#8217;s of any use.</p>
<p>I&#8217;m running a Google Map on a page. The Google Map script is referenced in my page&#8217;s &lt;head&gt; as is my own script which generates a map and then does things with it. Pretty standard stuff.</p>
<p>However, in Internet Explorer 6 when you access the page you get the following message alert,&#8221;Internet Explorer cannot open the Internet site &#8211; operation aborted&#8221; and then you see a &#8220;Page cannot be displayed&#8221; message. The reasons for this are outlined in Nirmal&#8217;s post, <a href="http://www.nirmaltv.com/2007/08/08/how-to-fix-internet-explorer-cannot-open-the-internet-site-operation-aborted-error/">How to Fix &#8220;Internet Explorer Cannot Open the Internet Site- Operation Aborted&#8221; Error</a>.</p>
<p>I fixed it by moving both the call to the Google Maps Javascript and my own Javascript file to the end of the page, just before the closing &lt;body&gt; tag.  I also threw in a defer=&#8221;defer&#8221; attribute to my own script reference just for extra safety. This will prevent IE from executing the script until the page has completed loading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littled.net/new/2008/08/01/internet-explorer-cannot-open-the-internet-site-error/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>KML overlays in Google Maps in two minutes</title>
		<link>http://www.littled.net/new/2007/06/23/kml-overlays-in-google-maps-in-two-minutes/</link>
		<comments>http://www.littled.net/new/2007/06/23/kml-overlays-in-google-maps-in-two-minutes/#comments</comments>
		<pubDate>Sat, 23 Jun 2007 13:22:12 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[google-maps]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[non-plone]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://www.littled.net/blog/?p=13</guid>
		<description><![CDATA[Following on from the Google Developer Day a few weeks back, in which we were all encouraged to encode our geographical data in KML format (Google can index data encoded in KML), I thought I&#8217;d have a play around with KML overlays in Google Maps. KML is used mainly to mark up overlays in Google [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />Following on from the <a href="http://code.google.com/events/developerday/uk-home.html">Google Developer Day</a> a few weeks back, in which we were all encouraged to encode our geographical data in KML format (Google can index data encoded in KML), I thought I&#8217;d have a play around with KML overlays in Google Maps. KML is used mainly to mark up overlays in Google Earth, but a <a href="http://code.google.com/apis/kml/documentation/mapsSupport.html" title="More information on the KML subset available in Google Maps">subset of it is available for use in Google Maps</a>.</p>
<p>The title of this post is a little misleading &#8212; show me anything you can do in Google Maps in two minutes and I&#8217;ll buy you a bun. By the time you&#8217;ve worked out the longitude and latitude references for your map and its placemarks you&#8217;ve probably lost a couple of hours at least but we&#8217;ll brush over that for now.</p>
<p>However, using KML overlays for maps can save you a bit of time fiddling around with the API when creating your markers and setting the event listeners and the like. Encode your data in a KML file, point your maps script at it and much of the work is done. It&#8217;s not quite as flexible as using the API, but for a basic map it will save you some time. What&#8217;s more, you can use your KML file on the Google Maps site, export it for use in Google Earth and get your data indexed on Google.</p>
<p>I&#8217;ve created a basic example which plots three points of interest in Greenwich, London. The references may not be very accurate  but I don&#8217;t care, it&#8217;s a demonstration. First create your KML file.  This is a XML file with a .kml extension:</p>
<pre style="overflow:scroll;width:400px;height:300px;background-color:#ffffff;color:#000000;">&lt;kml xmlns="http://earth.google.com/kml/2.1"&gt;

&lt;Document&gt;
&lt;name&gt;A small map of Greenwich&lt;/name&gt;

&lt;description&gt;A very basic map of Greenwich,
 SE10 made to demonstrate KML
overlays&lt;/description&gt;
&lt;placemark&gt;
 &lt;name&gt;The National Maritime
Museum&lt;/name&gt;

&lt;description&gt;

&lt;!--[CDATA[

&lt;!-- html code goes in here --&gt;

]]--&gt;

&lt;/description&gt;

&lt;/placemark&gt;

&lt;point&gt;

&lt;coordinates&gt;
 -0.003747,51.481154,-1
&lt;/coordinates&gt;

&lt;/point&gt;

&lt;/Document&gt;

&lt;/kml&gt;</pre>
<p>Then create your Javascript file. Create an instance of GGeoXML and give it the location of your KML file. Then use the overlay method of GMap2 to overlay it on your map. Be warned that your KML files will be cached by Google Maps which can be a tad frustrating when you&#8217;re trying to debug your file. To avoid caching, add a query string parameter to your file name with a value of the date and time  (this will change every second which should be enough for you). E.g.</p>
<pre style="overflow:scroll;width:400px;height:300px;background-color:#ffffff;color:#000000;">
url_end = "?nocache=" + (new Date()).valueOf();
myKML = "http://www.myserver.com/kml.file" + url_end
var map = new GMap2(document.getElementById("map"));
// Add controls

map.addControl(new GLargeMapControl());

map.addControl(new GMapTypeControl());

geoxml = new GGeoXml(myKML);

map.addOverlay(geoxml);</pre>
<p>That&#8217;s about it.</p>
<ul>
<li><a href="http://www.littled.net/exp/gmapkml.html">View example</a></li>
<li><a href="http://www.littled.net/exp/gmapkml.html.txt">Download example HTML and Javascript</a></li>
<li><a href="http://www.littled.net/exp/gmap.kml.txt">Download example KML file</a></li>
</ul>
<p>If you want to play with the code yourself, don&#8217;t forget you&#8217;ll need to substitute my maps API key for yours.</p>
<h3>A couple of things to look out for</h3>
<p>Make sure you keep the CDATA sections in the placemark description tag, otherwise you&#8217;ll need to escape your html with entities.</p>
<p>Don&#8217;t bother putting class names into the HTML in your KML file&#8217;s description tags as these will be stripped by Google Maps. Google Maps uses inline styles instead. Ouch. To get round this problem you can build some styles in your map page stylesheet. As a default Firefox will display the text of the name element of your placemark in bold, although Internet Explorer 7 won&#8217;t. I got round this problem thus:</p>
<pre style="overflow:scroll;width:400px;height:300px;background-color:#ffffff;color:#000000;">
#map div { font-weight:bold;}

#map #iwsw p { font-weight:normal !important;}</pre>
<p>The iwsw id is what appears to be generated around your placemark window, so you can use this to cascade your styles down.</p>
<p>If you make a syntax error in your KML file, you won&#8217;t get any warnings &#8212; it just won&#8217;t display. It may be best to edit your file as .xml file in your editor of choice and then save it out as .kml.</p>
<p><a href="http://reynard.files.wordpress.com/2007/06/gmap.jpg" title="Screenshot of the Google Maps code in action"><img src="http://reynard.files.wordpress.com/2007/06/gmap.jpg" alt="Screenshot of the Google Maps code in action" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.littled.net/new/2007/06/23/kml-overlays-in-google-maps-in-two-minutes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
