<?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>mFabrik - mobile sites, apps, HTML5 and CMS software development &#187; jquery</title>
	<atom:link href="http://blog.mfabrik.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mfabrik.com</link>
	<description>Freedom delivered.</description>
	<lastBuildDate>Wed, 03 Aug 2011 09:47:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AJAX proxy view with Python, urllib and Plone</title>
		<link>http://blog.mfabrik.com/2011/08/02/ajax-proxy-view-with-python-urllib-and-plone/</link>
		<comments>http://blog.mfabrik.com/2011/08/02/ajax-proxy-view-with-python-urllib-and-plone/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 08:26:42 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[access control]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[allow-access-origin]]></category>
		<category><![CDATA[cors]]></category>
		<category><![CDATA[cross domain]]></category>
		<category><![CDATA[getjson]]></category>
		<category><![CDATA[grok]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[restful]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1365</guid>
		<description><![CDATA[Old web browsers do not support Allow-acces-origin HTTP header needed to do cross-domain AJAX requests (IE6, IE7). Below is an example how to work around this for jQuery getJSON() calls by Detecting browsers which do not support this using jQuery.support API Doing an alternative code path through a local website proxy view which uses Python [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>Old web browsers do not support <a class="reference external" href="https://developer.mozilla.org/en/HTTP_access_control">Allow-acces-origin HTTP header</a> needed to do cross-domain AJAX requests (IE6, IE7).</p>
<p>Below is an example how to work around this for jQuery getJSON() calls by</p>
<ul class="simple">
<li>Detecting browsers which do not support this using jQuery.support API</li>
<li>Doing an alternative code path through a local website proxy view which uses Python <tt class="docutils literal">urllib</tt> to make server-to-server call and return it as it would be a local call, thus working around cross-domain restriction</li>
</ul>
<p>This example is for Plone/Grok, but the code is easily port to other Python web frameworks.</p>
<div class="note">
<p class="last"><em>Note: This is not a full example code. Basic Python and Javascript skills are needed to interpret and adapt the code for your use case.</em></p>
</div>
<p>Javascript example</p>
<pre class="literal-block">/**
 * Call a RESTful service vie AJAX
 *
 * The final URL is constructed by REST function name, based
 * on a base URL from the global settings.
 *
 * If the browser does not support cross domain AJAX calls
 * we'll use a proxy function on the local server. For
 * performance reasons we do this only when absolutely needed.
 *
 * @param {String} functionName REST function name to a call
 *
 * @param {Object} Arguments as a dictionary like object, passed to remote call
 */
function callRESTful(functionName, args, callback) {

    var src = myoptions.restService + "/" +functionName;

    // set to true to do proxied request on every browser
    // useful if you want to use Firebug to debug your server-side proxy view
    var debug = false;

        console.log("Doing remote call to:" + src)

        // We use jQuery API to detect whether a browser supports cross domain AJAX calls
        // http://api.jquery.com/jQuery.support/
        if(!jQuery.support.cors || debug) {
                // http://alexn.org/blog/2011/03/24/cross-domain-requests.html
                // Opera 10 doesn't have this feature, neither do IExplorer &lt; 8, Firefox &lt; 3.5

                console.log("Mangling getJSON to go through a local proxy")

                // Change getJSON to go to our proxy view on a local server
                // and pass the orignal URL as a parameter
                // The proxy view location is given as a global JS variable
                args.url = src;
                src = myoptions.portalUrl + "/@@proxy";
        }

        // Load data from the server
        $.getJSON(src, args, function(data) {
                // Parse incoming data and construct Table rows according to it
                console.log("Data succesfully loaded");
                callback(data, args);

     });

}</pre>
<p>The server-side view:</p>
<pre class="literal-block">import socket
import urllib
import urllib2
from urllib2 import HTTPError

from five import grok
from Products.CMFCore.interfaces import ISiteRoot
from mysite.app import options

class Proxy(grok.CodeView):
    """
    Pass a AJAX call to a remote server. This view is mainly indended to be used
    with jQuery.getJSON() requests.

    This will work around problems when a browser does not support Allow-Access-Origin HTTP header (IE).

    Asssuming only HTTP GET requests are made.s
    """

    # This view is available only at the root of Plone site
    grok.context(ISiteRoot)

    def isAllowed(self, url):
        """
        Check whether we are allowed to call the target URL.

        This prevents using your service as an malicious proxy
        (to call any internet service).
        """

        allowed_prefix = options.REST_SERVICE_URL

        if url.startswith(allowed_prefix):
            return True

        return False

    def render(self):
        """
        Use HTTP GET ``url`` query parameter for the target of the real request.
        """

        # Make sure any theming layer won't think this is HTML
        # http://stackoverflow.com/questions/477816/the-right-json-content-type
        self.request.response.setHeader("Content-type", "application/json")

        url = self.request.get("url", None)
        if not url:
            self.request.response.setStatus(500, "url parameter missing")

        if not self.isAllowed(url):
            # The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeate
            self.request.response.setStatus(403, "proxying to the target URL not allowed")
            return

        # Pass other HTTP GET query parameters direclty to the target server
        params = {}
        for key, value in self.request.form.items():
            if key != "url":
                params[key] = value

        # http://www.voidspace.org.uk/python/articles/urllib2.shtml
        data = urllib.urlencode(params)

        full_url = url + "?" + data
        req = urllib2.Request(full_url)

        try:

            # Important or if the remote server is slow
            # all our web server threads get stuck here
            # But this is UGLY as Python does not provide per-thread
            # or per-socket timeouts thru urllib
            orignal_timeout = socket.getdefaulttimeout()
            try:
                socket.setdefaulttimeout(10)

                response = urllib2.urlopen(req)
            finally:
                # restore orignal timeoout
                socket.setdefaulttimeout(orignal_timeout)

            # XXX: How to stream respone through Zope
            # AFAIK - we cannot do it currently

            return response.read()

        except HTTPError, e:
            # Have something more useful to log output as plain urllib exception
            # using Python logging interface
            # http://docs.python.org/library/logging.html
            logger.error("Server did not return HTTP 200 when calling remote proxy URL:" + url)
            for key, value in params.items():
                logger.error(key + ": "  + value)

            # Print the server-side stack trace / error page
            logger.error(e.read())

            raise e</pre>
</div>
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/08/02/ajax-proxy-view-with-python-urllib-and-plone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple image roll-over effect with jQuery</title>
		<link>http://blog.mfabrik.com/2011/05/26/simple-image-roll-over-effect-with-jquery/</link>
		<comments>http://blog.mfabrik.com/2011/05/26/simple-image-roll-over-effect-with-jquery/#comments</comments>
		<pubDate>Thu, 26 May 2011 09:18:00 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[mouseout]]></category>
		<category><![CDATA[mouseover]]></category>
		<category><![CDATA[roll over]]></category>
		<category><![CDATA[rollover]]></category>
		<category><![CDATA[tinymce]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1268</guid>
		<description><![CDATA[Here is a simple jQuery method to enable image roll-over effects (hover). This method is suitable for content editors who can add images only through TinyMCE or normal upload -  naming image files specially is the only requirement. No CSS, Javascript or other knowledge needed by the person who needs to add the images with [...]]]></description>
			<content:encoded><![CDATA[<div class="body">
<p>Here is a simple jQuery method to enable image roll-over effects (hover). This method is suitable for content editors who can add images only through TinyMCE or normal upload -  naming image files specially is the only requirement. No CSS, Javascript or other knowledge needed by the person who needs to add the images with roll-overs.</p>
<p>Just include this script on your HTML page and it will automatically scan image filenames, detects image filenames with special roll-over marker strings and then applies the roll-over effect on them. Roll-over images are preloaded to avoid image blinking on slow connections.</p>
<p>The script:</p>
<pre class="literal-block">/**
 * Automatic image hover placement with jQuery
 *
 * If image has -normal tag in it's filename assume there exist corresponding
 * file with -hover in its name.
 *
 * E.g. http://host.com/test-normal.gif -&gt; http://host.com/test-hover.gif
 *
 * This image is preloaded and shown when mouse is placed on the image.
 *
 * Copyright Mikko Ohtamaa 2011
 *
 * http://twitter.com/moo9000
 */

(function (jQuery) {
        var $ = jQuery;

        // Look for available images which have hover option
        function scanImages() {
                $("img").each(function() {

                        $this = $(this);

                        var src = $this.attr("src");

                        // Images might not have src attribute, if they
                        if(src) {

                                // Detect if this image filename has hover marker bit
                                if(src.indexOf("-normal") &gt;= 0) {

                                        console.log("Found rollover:" + src);

                                        // Mangle new URL for over image based on orignal
                                        var hoverSrc = src.replace("-normal", "-hover");

                                        // Preload hover image
                                        var preload = new Image(hoverSrc);

                                        // Set event handlers

                                        $this.mouseover(function() {
                                                this.src = hoverSrc;
                                        });

                                        $this.mouseout(function() {
                                                this.src = src;
                                        });

                                }
                        }
                });
        }

        $(document).ready(scanImages);

})(jQuery);</pre>
</div>
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/05/26/simple-image-roll-over-effect-with-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Everyone loves and hates console.log()</title>
		<link>http://blog.mfabrik.com/2011/03/15/everyone-loves-and-hates-console-log/</link>
		<comments>http://blog.mfabrik.com/2011/03/15/everyone-loves-and-hates-console-log/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 13:35:40 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[commit hook]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[preprocessor]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1119</guid>
		<description><![CDATA[console.log()  is the best friend of every Javascript junkie. However, the lack of it isn&#8217;t. console.log() function is only available in Webkit based browsers and with Firebug in Firefox. It&#8217;s the infamous situation that someone leaves console.log() to Javascript code, doesn&#8217;t notice its presence, commits the file and suddenly all Javascript on the production server [...]]]></description>
			<content:encoded><![CDATA[<p>console.log()  is the best friend of every Javascript junkie. However, the lack of it isn&#8217;t. console.log() function is only available in Webkit based browsers and with Firebug in Firefox. It&#8217;s the infamous situation that someone leaves console.log() to Javascript code, doesn&#8217;t notice its presence, commits the file and suddenly all Javascript on the production server stops working for Internet Explorer users&#8230;.</p>
<p>To tackle the lack of console.log() problem there are several approaches.</p>
<h2>Use dummy placeholder if console is missing</h2>
<p>This snippet wraps console.log (need to repeat for console.error etc.):</p>
<pre>// Ignore console on platforms where it is not available
if (typeof(window["console"]) == "undefined") { console = {}; console.log = function(a) {}; }</pre>
<p>Pros</p>
<ul>
<li>Easy</li>
</ul>
<p>Cons</p>
<ul>
<li>Need to add to every Javascript file</li>
<li>Messes with global namespace</li>
</ul>
<h2>Use module specific log function</h2>
<p>This makes your code little bit ugly, more Java like. Each Javascript module declares their own log() function which checks the existence of console.log() and outputs there if it&#8217;s present.</p>
<pre>mfabrik.log =function(x) {
 if(console.log) {
 console.log(x);
 }
}

mfabrik.log("My log messages")</pre>
<p>Pros</p>
<ul>
<li>Easy to hook other logg</li>
<li>You can disable all logging output with one if</li>
</ul>
<p>Cons</p>
<ul>
<li>Not as natural to write as console.log()</li>
<li>Need to add to every Javascript module</li>
</ul>
<h2>Preprocess Javascript files</h2>
<p>Plone (Kukit / KSS) uses this approach. All debug Javascript is  hidden behind conditional comments and it is filtered out when JS files  are bundled for the production deployment. (<a href="http://codespeak.net/svn/kukit/kss.core/trunk/kss/core/pluginregistry/_concatresource/compression/javascript.py">The preprocessing code is here in Python for those who are interested in it</a>).</p>
<pre>if (_USE_BASE2) {
 // Base2 legacy version: matchAll has to be used
 // Base2 recent version: querySelectorAll has to be used
 var _USE_BASE2_LEGACY = (typeof(base2.DOM.Document.querySelectorAll) == 'undefined');
 if (! _USE_BASE2_LEGACY) {
 ;;;     kukit.log('Using cssQuery from base2.');</pre>
<p>Pros</p>
<ul>
<li>Makes production Javascript files lighter</li>
<li>Make production Javascript files more professional &#8211; you do not deliver logging statements indented for internal purposes for your site visitors</li>
</ul>
<p>Cons</p>
<ul>
<li>Complex &#8211; preprocessing is required</li>
</ul>
<h2>Commit hooks</h2>
<p>You can use Subversion and Git commit hooks to check that committed JS files do not contain console.log. For example, Plone repositories do this for the Python statement  import pdb ; pdb.set_trace() (enforce pdb breakpoint).</p>
<p>Pros</p>
<ul>
<li>Very robust approach &#8211; you cannot create code with console.log()</li>
</ul>
<p>Cons</p>
<ul>
<li>Prevents also legitimate use of console.log()</li>
<li>Github, for example, lacks possibility to push client-side commit hooks to the repository cloners. This means that every developer must manually install commit hooks themselves. Everything manual you need to do makes the process error prone.</li>
</ul>
<h2>Other approaches?</h2>
<p>Please tell us!
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/15/everyone-loves-and-hates-console-log/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Lazily load elements becoming visible using jQuery</title>
		<link>http://blog.mfabrik.com/2011/03/09/lazily-load-elements-becoming-visible-using-jquery/</link>
		<comments>http://blog.mfabrik.com/2011/03/09/lazily-load-elements-becoming-visible-using-jquery/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 09:57:52 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[plone]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[discussion]]></category>
		<category><![CDATA[disqus]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lazy load]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[varnish]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1078</guid>
		<description><![CDATA[It is a useful trick to lazily load comments or such elements at the bottom of page. Some elements may be loaded only when they are scrolled visible. All users are not interested in the information and do not necessary read the article long enough to see it By lazily loading such elements one can [...]]]></description>
			<content:encoded><![CDATA[<p>It is a useful trick to lazily load comments or such elements at the bottom of page. Some elements may be loaded only when they are scrolled visible.</p>
<ul>
<li>All users are not interested in the information and do not necessary read the article long enough to see it</li>
<li>By lazily loading such elements one can speed up the initial page load time</li>
<li>You save bandwidth</li>
<li>If you use AJAX for the dynamic elements of the page you can more easily cache your pages in static page cache (Varnish) even if the pages contain personalized bits</li>
</ul>
<p>For example, Disqus is doing this (see <a href="http://api.jquery.com/jQuery.ajax/">comments in jQuery API documentation</a>).</p>
<p>You can achieve this with <a href="http://remysharp.com/2009/01/26/element-in-view-event-plugin/">in-view plug-in for jQuery</a>.</p>
<p>Below is an example for Plone triggering <span style="text-decoration: underline;"><em>productappreciation_view</em></span> loading when our placeholder <em>div</em> tag becomes visible.</p>
<pre>...
&lt;head&gt;
  &lt;script type="text/javascript" tal:attributes="src string:${portal_url}/++resource++your.app/in-view.js"&gt;&lt;/script&gt;
&lt;/head&gt;
...
&lt;div id="comment-placefolder"&gt;

 &lt;!-- Display spinning AJAX indicator gif until our AJAX call completes --&gt;

 &lt;p&gt;
 &lt;!-- Image is in Products.CMFPlone/skins/plone_images --&gt;
 &lt;img tal:attributes="src string:${context/@@plone_portal_state/portal_url}/spinner.gif" /&gt; Loading comments
 &lt;/p&gt;

 &lt;!-- Hidden link to a view URL which will render the view containing the snippet for comments --&gt;                       
 &lt;a rel="nofollow" style="display:none" tal:attributes="href string:${context/absolute_url}/productappreciation_view" /&gt;

 &lt;script&gt;

 jq(document).ready(function() {

   // http://remysharp.com/2009/01/26/element-in-view-event-plugin/                                        
   jq("#comment-placeholder").bind("inview", function() {

     // This function is executed when the placeholder becomes visible

     // Extract URL from HTML page
     var commentURL = jq("#comment-placeholder a").attr("href");

     if (commentURL) {
     // Trigger AJAX call
       jq("#comment-placeholder").load(commentURL);
     }

   });                                     

 });     
 &lt;/script&gt;
&lt;/div&gt;</pre>
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/09/lazily-load-elements-becoming-visible-using-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Integrating jQuery UI 1.8 with Plone 4</title>
		<link>http://blog.mfabrik.com/2011/02/23/integrating-jquery-ui-1-8-with-plone-4/</link>
		<comments>http://blog.mfabrik.com/2011/02/23/integrating-jquery-ui-1-8-with-plone-4/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 13:15:22 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[plone]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[tal]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1003</guid>
		<description><![CDATA[We had some problems integrating jQuery UI to Plone 4. Looks like jQuery UI wants to define jQuery.tabs() and Plone 4 wants to do this also (form_tabbing.js).  After loading jQuery UI, Edit page tabs stopped working. The solution is to build a custom jQuery UI download bundle without Tabs feature includes. Then you should be [...]]]></description>
			<content:encoded><![CDATA[<p>We had some problems integrating jQuery UI to Plone 4.</p>
<p>Looks like jQuery UI wants to define jQuery.tabs() and Plone 4 wants to do this also (form_tabbing.js).  After loading jQuery UI, Edit page tabs stopped working.</p>
<p>The solution is to build a custom <a href="http://jqueryui.com/download">jQuery UI download bundle</a> without <em>Tabs</em> feature includes. Then you should be able to simple drop jQuery UI to any page:</p>
<pre> &lt;metal:head define-macro="javascript_head"&gt;    
 &lt;link rel="stylesheet" tal:attributes="href string:${context/portal_url}/jquery-ui-1.8.9.custom/css/ui-lightness/jquery-ui-1.8.9.custom.css" type="text/css" /&gt;
 &lt;script type="text/javascript" tal:attributes="src string:${context/portal_url}/jquery-ui-1.8.9.custom/js/jquery-ui-1.8.9.custom.min.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="yourjqueryuiscript.js"&gt;&lt;/script&gt;
 &lt;/metal:head&gt;</pre>
<p>Maybe jQuery object is the next battlefield of namespace conflicts&#8230;
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/02/23/integrating-jquery-ui-1-8-with-plone-4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Setting table column widths non-intrusively using CSS and JQuery</title>
		<link>http://blog.mfabrik.com/2009/07/08/setting-table-column-widths-non-intrusively-using-css-and-jquery/</link>
		<comments>http://blog.mfabrik.com/2009/07/08/setting-table-column-widths-non-intrusively-using-css-and-jquery/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 22:53:02 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[plone]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[cell]]></category>
		<category><![CDATA[column]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://blog.twinapex.fi/?p=186</guid>
		<description><![CDATA[Below is a Javascript snipped which will mark each table cell with a CSS class containing the column number. This allows you to set the table column widths using just one CSS rule and without hand editing the table HTML code. This is to workaround the lack of nth-child pseudoclass CSS selector in IE6, IE7 [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a Javascript snipped which will mark each table cell with a CSS class containing the column number. This allows you to set the table column widths using just one CSS rule and without hand editing the table HTML code. This is to workaround the lack of nth-child pseudoclass CSS selector in IE6, IE7 and IE8 &#8211; there is no direct Internet Explorer compatible way to set table column widths from CSS.</p>
<p>This was originally created to workaround the limitation of Kupu : one couldn&#8217;t set table column widths from WYSIWYG editor. Instead, the content editor has predefined table classes and column width sets.</p>
<p><a href="http://snipplr.com/view/16741/set-table-column-widths-using-css-jquery-and-automatically-generated-pseudoclasses/">The code is also available in the snipplr</a>.</p>
<pre>
/*  Add column index pseudoclasses to table cells.

    A JQuery snippet to be executed after DOM model has been loaded.

    Each table cell will be marked with a CSS class containing the cell's column number.
    This is to workaround the lack of nth-child pseudoclass CSS selector support in
    IE6, IE7 and IE8.

    Read this sad fact sheet:

http://msdn.microsoft.com/en-us/library/cc351024(VS.85).aspx

    This way we can style table columns without explicitly settings classes
    for each cell in WYSIWYG editor.

    &lt;table&gt;
        &lt;tbody&gt;
            &lt;tr&gt;
                &lt;td&gt;
                &lt;/td&gt;
                &lt;td&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;

    will become

    &lt;table&gt;
        &lt;tbody&gt;
            &lt;tr&gt;
                &lt;td class="column-1"&gt;
                &lt;/td&gt;
                &lt;td class="column-2"&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;

    Both &lt;tbody&gt;&lt;td&gt; and &lt;thead&gt;&lt;th&gt; elements will be fixed.

    Use the following CSS to style tables:

    table.course-schedule-table .column-1 {
        width: auto;
    }

    table.course-schedule-table .column-2 {
        width: 150px;
    }

    table.course-schedule-table .column-3 {
        width: 150px;
    }

    @author Mikko Ohtamaa

    @license 3-clause BSD

http://www.twinapex.com

*/

function createTableColumnPseudoClasses() {

    jq("tr").each( function()  {
        var counter = 1;
        jq(this).children("td,th").each( function()  {
            jq(this).addClass("column-" + counter);
            counter++;
        });
    });
}

// Run code on document load
jq(createTableColumnPseudoClasses);</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2009/07/08/setting-table-column-widths-non-intrusively-using-css-and-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Catching silent Javascript exceptions with a function decorator</title>
		<link>http://blog.mfabrik.com/2008/08/19/catching-silent-javascript-exceptions-with-a-function-decorator/</link>
		<comments>http://blog.mfabrik.com/2008/08/19/catching-silent-javascript-exceptions-with-a-function-decorator/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 22:08:59 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[event handler]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[onready]]></category>
		<category><![CDATA[silent]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/?p=61</guid>
		<description><![CDATA[The one utterly annoying thing with the otherwise excellent Firefox/Firebug combo is that some exceptions are let silently through without being end up to be visible in the Firebug console. This makes debugging very difficult, unless you are aware of the phenomenon. I am not sure whether this is caused by some internal Firefox logic [...]]]></description>
			<content:encoded><![CDATA[<p>The one utterly annoying thing with the otherwise excellent Firefox/Firebug combo is that some exceptions are let silently through without being end up to be visible in the Firebug console. This makes debugging very difficult, unless you are aware of the phenomenon. I am not sure whether this is caused by some internal Firefox logic flow, since IE + Visual Web Developer doesn&#8217;t seem to be affected by this.</p>
<p>Since this problem pops up constantly, I decided to create an easy way to deal with the situation. I decorate all functions which made have silent exceptions (e.g. one called from document load event) with a custom logger function which will first log the exception and then rethrow it.</p>
<p>Thus instead of writing (JQuery example)</p>
<pre>myfunction() {
    // crash here
    var i = foobar; // missing variable foobar
}

$(document).ready(myfunction);</pre>
<p>write</p>
<pre>myfunction() {
    // crash here
    var i = foobar; // missing variable foobar
}

$document.ready(logExceptions(myFunction));</pre>
<p>or</p>
<pre>// myFunction can be bind to many events and exceptions are logged always
myfunction = logExceptions(function() {
  // crash here
    var i = foobar; // missing variable foobar
});

$document.ready(logExceptions(myFunction));</pre>
<p>The Javascript code for the decorator:</p>
<pre>/**
 * Enhancd Javascript logging and exception handler.
 *
 * Copyright 2008 Red Innovation Ltd.
 *
 * @author Mikko Ohtamaa
 * @license 3-clause BSD
 *
 */

// Browser specific logging output initialization
// Supports Firefox/Firebug. Other (Opera) can be hooked in here.
if(!console) {
	// Install dummy functions, so that logging does not break the code if Firebug is not present
    var console = {};
    console.log = function(msg) {};
    console.info = function(msg) {};
    console.warn = function(msg) {};
} else {
    // console.log provided by Firefox + Firebug
}

/**
 * Try print human digestable exception stack trace to Firebug console.
 *
 * http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Error
 *
 * @param e: Error
 */
function printStackTrace(e) {

	var msg = e.name + ":" + e.message;

	if (e.fileName) {
		msg += " at " + e.fileName + ":" + e.lineNumber;
	}
	console.log(msg);

	if (e.stack) {
		// Extract Firefox stack information. This tells how you ended up
		// to the exception in the first place. I didn't find
		// instructions how to parse this stuff.
		console.log(e.stack);
	}
}

/**
 * Decorate function so that exceptions falling through are printed always.
 *
 * Returns a decorated function which will be used instead of the normal function.
 * The decorated function has preplaced try ... catch block which will not let
 * through any exceptions silently or without logging. Even though there is an
 * exception it is normally throw upwards in the stack after logging.
 *
 * @param func: Javascript function reference
 */
function logExceptions(func) {

	var orignal = func;

	decorated = function() {
		try {
			orignal.apply(this, arguments);
		} catch(exception) {
			printStackTrace(exception);
			throw exception;
		}
	}

	return decorated;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2008/08/19/catching-silent-javascript-exceptions-with-a-function-decorator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated: Eclipse web developer plug-in memo</title>
		<link>http://blog.mfabrik.com/2008/07/14/updated-eclipse-web-developer-plug-in-memo/</link>
		<comments>http://blog.mfabrik.com/2008/07/14/updated-eclipse-web-developer-plug-in-memo/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 23:13:04 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Plone (old)]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[aptana]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pydev]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql explorer]]></category>
		<category><![CDATA[subclipse]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/?p=54</guid>
		<description><![CDATA[Below are my personal notes what plug-ins are needed to get &#8220;perfect&#8221; Eclipse web development set-up. Basically they are just my own notes so that I don&#8217;t need to Google everything all over again every time I reinstall. I hope the readers can find new pearls here or suggest improvements. This post is update to [...]]]></description>
			<content:encoded><![CDATA[<p>Below are my personal notes what plug-ins are needed to get &#8220;perfect&#8221; Eclipse web development set-up. Basically they are just my own notes so that I don&#8217;t need to Google everything all over again every time I reinstall. I hope the readers can find new pearls here or suggest improvements.</p>
<p>This post is update to previous <a href="http://blog.redinnovation.com/2007/11/27/eclipse-web-developer-plug-in-memo/">Eclipse web developer plug-in</a> memo post. New versions are available and some plug-ins have become deprecated. This blog post reflects those changes.</p>
<p>These instructions are good for:</p>
<ul>
<li>Python developer</li>
<li>PHP developer</li>
<li>Java developer</li>
</ul>
<h2>Choosing Eclipse distribution</h2>
<ul>
<li>On Window, use <a href="http://www.easyeclipse.org/site/home/">EasyEclipse</a></li>
<li>On Linux, use Eclipse provided by the distribution &#8211; Eclipse links against the embedded Mozilla browser and this is distribution specific &#8211; EasyEclipse has some issues here. For Ubuntu users:</li>
</ul>
<pre style="padding-left: 60px;">sudo apt-get install sun-java6 eclipse</pre>
<ul>
<li>On OSX, use <a href="http://www.easyeclipse.org/site/home/">EasyEclipse</a></li>
</ul>
<p>EasyEclipse bundles some of the stuff listed here with it &#8211; when using EasyEclipse you don&#8217;t need to have separate PyDev and Subclipse downloads.</p>
<p>Eclipse for 64-bit Linux has various problems. <a href="http://www.64bitjungle.com/tech/eclipse-32-bit-pdt-install-on-64-bit-ubuntu/">You might want to run 32-bit Eclipse</a> (<a href="http://rachaelandtom.info/node/1485">another relevant blog post)</a>. When you use Linux distribution specific Eclipse install, all your personal Eclipse files go to .eclipse folder under your home folder.</p>
<h2 id="Eclipsesetup">Installing plug-ins<a class="anchor" title="Link to this section" href="https://trac.yebotv.com/wiki/EclipseSetup#Eclipsesetup"> </a></h2>
<p>Eclipse has internal updater/web installer. All plug-ins are downloaded as ZIP files and extracted to Eclipse folder or installed through the internal updater. Paste Eclipse update site URLs to menu <em>Help</em> -&gt; <em>Software updates</em> -&gt;<em> Find and Install</em>,<em> New Remote Location</em>.</p>
<h3 id="Python">Python<a class="anchor" title="Link to this section" href="https://trac.yebotv.com/wiki/EclipseSetup#Python"> </a></h3>
<p>PyDev is a plug-in for Python and Jython development. It has enhanced commercial extensions for professional developers with more intelligent autocomplete and debugger.</p>
<p>Site URL: <a class="ext-link" href="http://pydev.sourceforge.net/"><span class="icon">http://pydev.sourceforge.net</span></a></p>
<p>PyDev Eclipse update URL: <a class="ext-link" href="http://pydev.sourceforge.net/updates/"><span class="icon">http://pydev.sourceforge.net/updates/</span></a></p>
<p>PyDev extensions Eclipse update URL (<a href="http://www.fabioz.com/pydev/buy.html">this commercial, but worth of every penny</a>): <a href="http://www.fabioz.com/pydev/updates">http://www.fabioz.com/pydev/updates<br />
</a></p>
<h3 id="PDT">PDT<a class="anchor" title="Link to this section" href="https://trac.yebotv.com/wiki/EclipseSetup#PDT"> </a></h3>
<p>PDT download provides Eclipse, HTML editor, PHP editor and CSS editor.</p>
<p>Site URL: <a class="ext-link" href="http://www.eclipse.org/"><span class="icon">http://www.eclipse.org</span></a></p>
<p>Eclipse update site URL: <a class="ext-link" href="http://download.eclipse.org/tools/pdt/updates/"><span class="icon">http://download.eclipse.org/tools/pdt/updates/</span></a></p>
<h3>Java</h3>
<p>If you need to do J2EE development use IBM&#8217;s <a href="http://www.eclipse.org/webtools/">Web Tools Platform</a>. If you don&#8217;t need Java capabilities don&#8217;t install these, since they just bloat Eclipse and make the start up time worse.</p>
<h3 id="Subclipse">Subclipse<a class="anchor" title="Link to this section" href="https://trac.yebotv.com/wiki/EclipseSetup#Subclipse"> </a></h3>
<p><a href="http://subclipse.tigris.org/">Subclipse</a> provides Subversion version control integration to Eclipse.</p>
<p>Eclipse update site URL: <a href="http://subclipse.tigris.org/update_1.4.x/">http://subclipse.tigris.org/update_1.4.x/</a><a class="ext-link" href="http://subclipse.tigris.org/update_1.2.x"></a></p>
<p>In the installer, uncheck the integration modules checkbox or the installer will complain about missing modules.</p>
<h3>Aptana Studio<a href="http://aptana.com/studio/"><br />
</a></h3>
<p><a href="http://aptana.com/studio/">Aptana Studio</a> is state-of-the-art Web 2.0 development suite for Eclipse. It has Javascript, CSS and HTML editors. It supports various Javascript libraries out of the box and has support <a href="http://aptana.com/docs/index.php/Installing_the_JavaScript_debugger">for Firefox and IE in-browser Javascript debugging</a>.</p>
<p>Eclipse update site URL: <a href="http://update.aptana.com/update/studio/3.2/site.xml">http://update.aptana.com/update/studio/3.2/site.xml</a></p>
<h3 id="SQLExplorer">ShellEd<a class="anchor" title="Link to this section" href="https://trac.yebotv.com/wiki/EclipseSetup#SQLExplorer"> </a></h3>
<p>Syntax coloring for Unix shell scripts</p>
<p>Project site:<a class="ext-link" href="http://sourceforge.net/projects/shelled/"><span class="icon"> http://sourceforge.net/projects/shelled</span></a></p>
<h3 id="SQLExplorer">SQL Explorer<a class="anchor" title="Link to this section" href="https://trac.yebotv.com/wiki/EclipseSetup#SQLExplorer"> </a></h3>
<p>SQL terminal and SQL editor with some GUI capabilities.</p>
<p>Eclipse update site URL <a href="http://eclipsesql.sourceforge.net/">http://eclipsesql.sourceforge.net/</a></p>
<p>SQL Explorer needs MySQL JDBC driver. Download from <a href="http://dev.mysql.com/downloads/connector/j/5.1.html">here</a>. Install MySQL connector by extracting the file and adding it from SQL Explorer preferences.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2008/07/14/updated-eclipse-web-developer-plug-in-memo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

