<?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>eklog</title>
	<atom:link href="http://www.ekstasis.net/log/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ekstasis.net/log</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Tue, 29 Nov 2011 16:15:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Scrolling overlays</title>
		<link>http://www.ekstasis.net/log/javascript/scrolling-overlays.html</link>
		<comments>http://www.ekstasis.net/log/javascript/scrolling-overlays.html#comments</comments>
		<pubDate>Sun, 20 Nov 2011 00:00:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=601</guid>
		<description><![CDATA[If you have pop-up overlays with content that necessitates scrollbars, there&#8217;s no scrollbar functionality when viewed on a mobile phone. If you feel the finger drag functionality is not obvious enough, you can add up and down buttons to assist with the scrolling. The jQuerires: The CSS: The HTMLs: See example:]]></description>
			<content:encoded><![CDATA[<p>If you have pop-up overlays with content that necessitates scrollbars, there&#8217;s no scrollbar functionality when viewed on a mobile phone. If you feel the finger drag functionality is not obvious enough, you can add up and down buttons to assist with the scrolling.</p>
<p>The jQuerires:</p>
<pre class="brush: jscript; title: ; notranslate">
$(function() {
	$('.pagination').children().wrapAll('&lt;div class=&quot;content&quot;/&gt;;');
	$('.next').click(function() {
		moveContent($('.pagination').scrollTop() + $('.pagination').height() - 9);
	});
	$('.previous').click(function() {
		moveContent($('.pagination').scrollTop() - $('.pagination').height() + 9);
	});
	function moveContent(newTop) {
		$('.pagination').scrollTop(newTop);
	}
});
</pre>
<p>The CSS:</p>
<pre class="brush: css; title: ; notranslate">
.pagination {
     width: 300px;
     height: 300px;
     overflow: hidden;
     position:relative;
     border: 1px solid #eee;
     padding: 5px;
}
.content {
    position:absolute;
}
.next, .previous {
    color: black;
    background: #D6D6D6;
    padding: 5px;
    cursor: pointer;
}
</pre>
<p>The HTMLs:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;span class=&quot;next&quot;&gt;next&lt;/span&gt;
&lt;span class=&quot;previous&quot;&gt;previous&lt;/span&gt;

&lt;div class=&quot;pagination&quot;&gt;
&lt;h1&gt;Whatever&lt;/h1&gt;
&lt;p&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus&lt;/p&gt;
&lt;/div&gt;
</pre>
<p>See example:<br />
<iframe style="width: 100%; height: 300px;" src="http://jsfiddle.net/matsstuff/4pPQU/1/embedded/result/" frameborder="0" width="320" height="240"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/javascript/scrolling-overlays.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Styling drop-downs</title>
		<link>http://www.ekstasis.net/log/css/select-styling.html</link>
		<comments>http://www.ekstasis.net/log/css/select-styling.html#comments</comments>
		<pubDate>Wed, 02 Nov 2011 19:07:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=541</guid>
		<description><![CDATA[Here&#8217;s how to style the options for a select drop-down. It uses some javaScript to add a class to the select options to match each option, and to add the selected option&#8217;s class to the select element itself. The CSS: The jQueries:]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to style the options for a select drop-down. It uses some javaScript to add a class to the select options to match each option, and to add the selected option&#8217;s class to the select element itself.</p>
<p>The CSS:</p>
<pre class="brush: css; title: ; notranslate">
.store-countries {
    padding-left: 20px;
    background-position: 4px 2px;
    background-repeat: no-repeat;
}
.store-countries option {
    padding: 0 0 0 24px;
    background-position: 2px 4px;
    background-repeat: no-repeat;
}
.store-countries option.Belgium {
    background-image: url(../images/icons/flags/be.gif);
}
.store-countries option.France {
    background-image: url(../images/icons/flags/fr.gif);
}
.store-countries option.Germany {
    background-image: url(../images/icons/flags/de.gif);
}
</pre>
<p>The jQueries:</p>
<pre class="brush: jscript; title: ; notranslate">
function dropDownCountries() {
    $('.store-countries').find('option').each(function() {
        var country = $j(this).val();
        $(this).addClass(country);
    });

    var selectedFlag = $('.store-countries').find('option:selected').css('background-image');
    $('.store-countries').css('background-image',selectedFlag)

    $('.store-countries').change( function() {
        var selectedFlag = $('.store-countries').find('option:selected').css('background-image');
        $('.store-countries').css('background-image',selectedFlag)
    });
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/css/select-styling.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Highlight current page</title>
		<link>http://www.ekstasis.net/log/javascript/highlight-current-page.html</link>
		<comments>http://www.ekstasis.net/log/javascript/highlight-current-page.html#comments</comments>
		<pubDate>Tue, 25 Oct 2011 18:11:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=526</guid>
		<description><![CDATA[Here&#8217;s a handy script to highlight a menu link when the link&#8217;s URL matches the current location (i.e. the browser&#8217;s address bar url). You create regexp to match current url pathname and remove trailing slash if present (as it could collide with the link in navigation in case trailing slash wasn&#8217;t present there.) Then grab [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a handy script to highlight a menu link when the link&#8217;s URL matches the current location (i.e. the browser&#8217;s address bar url).</p>
<p>You create regexp to match current url pathname and remove trailing slash if present (as it could collide with the link in navigation in case trailing slash wasn&#8217;t present there.)</p>
<p>Then grab every link from the navigation and test its normalized href against the url pathname regexp and add a classname &#8216;current&#8217; if it matches.</p>
<pre class="brush: jscript; title: ; notranslate">
function menuCurrentHighlight(){
    var url = window.location.pathname,
    urlRegExp = new RegExp(url.replace(/\/$/,'') + &quot;$&quot;);
	/* create regexp to match current url pathname and remove trailing slash if present: */
    if( $('ul a').length&gt;0 ) {
	    $('ul a').each(function(){
		// test its normalized href against the url pathname regexp
		if(urlRegExp.test(this.href.replace(/\/$/,''))){
		    $(this).addClass('current');
		}
	    });
	};
};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/javascript/highlight-current-page.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More jQuery snippets</title>
		<link>http://www.ekstasis.net/log/javascript/morejquery-snippets.html</link>
		<comments>http://www.ekstasis.net/log/javascript/morejquery-snippets.html#comments</comments>
		<pubDate>Sat, 15 Oct 2011 18:31:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[dhtml]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=529</guid>
		<description><![CDATA[Inject HTMLs: Chaining: Create a function: Check for something: Find a Selected Phrase and Manipulate It: Add Pseudo-Selector Support in IE: Manage Search Box Values: Easily Respond to Event Data: jQuery passes an event parameter into all bound/triggered functions, which is commonly called e: Encode HTML Entities: Open External Links in a New Window: How [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
function onLoadDoThis() {
    alert('Page is loaded!');
}
$(document).ready(onLoadDoThis);
// $(onLoadDoThis); is the same thing
</pre>
<p><br/><br />
<hr/><br/></p>
<pre class="brush: jscript; title: ; notranslate">
//Instead of
$(document).ready(function() {
    //document ready
});
//Use
$(function(){
    //document ready
});
</pre>
<pre class="brush: jscript; title: ; notranslate">
//To run the script before the DOM has loaded (&amp; without $ conflict):
(function($){
	...
})(jQuery);
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Inject HTMLs:</p>
<pre class="brush: jscript; title: ; notranslate">
var myList = $('.myList');
var myListItems = '&lt;ul&gt;';

for (i = 0; i &lt; 1000; i++) {
    myListItems += '&lt;li&gt;This is list item ' + i + '&lt;/li&gt;';
}

myListItems += '&lt;/ul&gt;';
myList.html(myListItems);
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Chaining:</p>
<pre class="brush: jscript; title: ; notranslate">
$('#myTable')
    .find('.firstColumn')
        .css('background','red')
    .end()
    .find('.lastColumn')
        .css('background','blue');
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Create a function:</p>
<pre class="brush: jscript; title: ; notranslate">
$.fn.makeRed = function() {
    return $(this).css('background', 'red');
}

$('#myTable').find('.firstColumn').makeRed().append('hello');
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Check for something:</p>
<pre class="brush: jscript; title: ; notranslate">
if( $(&quot;.active&quot;).length != 0 ){
	//Now the code here will only be executed if there is at least one active element
}
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Find a Selected Phrase and Manipulate It:</p>
<pre class="brush: jscript; title: ; notranslate">
//First define your search string, replacement and context:
var phrase = &quot;your search string&quot;;  var replacement = &quot;new string&quot;;
var context = $(body);

context.html(
	context.html().replace('/'+phrase+'/gi', replacement);
);
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Add Pseudo-Selector Support in IE:</p>
<pre class="brush: jscript; title: ; notranslate">
//add hover support:
function hoverOn(){
	var currentClass = $(this).attr('class').split(' ')[0]; //Get first class name
	$(this).addClass(currentClass + '-hover');
}
function hoverOff(){
	var currentClass = $(this).attr('class').split(' ')[0]; //Get first class name
	$(this).removeClass(currentClass + '-hover');
}
$(&quot;.nav-item&quot;).hover(hoverOn,hoverOff);

//add first-child support:
jQuery.fn.firstChild = function(){
	return this.each(function(){
		var currentClass = $(this).attr('class').split(' ')[0]; //Get first class name
		$(this).children(&quot;:first&quot;).addClass(currentClass + '-first-child');
	});
}
$(&quot;.searchform&quot;).firstChild();
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Manage Search Box Values:</p>
<pre class="brush: jscript; title: ; notranslate">
//set default value:
$(&quot;#searchbox&quot;)
	.val('search?');
	.focus(function(){this.val('')})
	.blur(function(){
		(this.val() === '')? this.val('search?') : null;
	});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Easily Respond to Event Data: jQuery passes an event parameter into all bound/triggered functions, which is commonly called e:</p>
<pre class="brush: jscript; title: ; notranslate">
//We can get X/Y coordinates on click events:
$(&quot;a&quot;).click(function(e){
	var clickX = e.pageX;
	var clickY = e.pageX;
});

//Or detect which key was pressed:
$(&quot;window&quot;).keypress(function(e){
	var keyPressed = e.which;
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Encode HTML Entities:</p>
<pre class="brush: jscript; title: ; notranslate">
var text = $(&quot;#someElement&quot;).text();
var text2 = &quot;Some &lt;code&gt; &amp; such to encode&quot;;
//you can define a string or get the text of an element or field

var html = $(text).html();
var html2 = $(text2).html();
//Done - html and html2 now hold the encoded values!
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Open External Links in a New Window:</p>
<pre class="brush: jscript; title: ; notranslate">
$('a[rel$='external']').click(function(){
	this.target = &quot;_blank&quot;;
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>How to tell when images have loaded:</p>
<pre class="brush: jscript; title: ; notranslate">
$('#myImage').attr('src', 'image.jpg').load(function() {
    alert('Image Loaded');
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Creating an HTML Element and keeping a reference</p>
<pre class="brush: jscript; title: ; notranslate">
var newDiv = $(&quot;&lt;div /&gt;&quot;);

newDiv.attr(&quot;id&quot;, &quot;myNewDiv&quot;).appendTo(&quot;body&quot;);

/* Now whenever I want to append the new div I created,
   I can just reference it from the &quot;newDiv&quot; variable */

var e = $(&quot;&lt; a /&gt;&quot;, { href: &quot;#&quot;, class: &quot;a-class another-class&quot;, title: &quot;...&quot;, css: {
        color: &quot;#FF0000&quot;,
        display: &quot;block&quot;
    }});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Nesting Filters:</p>
<pre class="brush: jscript; title: ; notranslate">
.filter(&quot;:not(:has(.selected))&quot;)
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Toggle states:</p>
<pre class="brush: jscript; title: ; notranslate">
function onState(){
    // do something
}

function offState(){
    // do something else
}

$('div').toggle( offState, onState );
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Preventing an animation from repeating:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#someElement&quot;).hover(function(){
    $(&quot;div.desc&quot;, this).stop(true,true).fadeIn();
},function(){
    $(&quot;div.desc&quot;, this).fadeOut();
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Preloading images:</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery.preloadImages = function()
{
  for(var i = 0; i&quot;).attr(&quot;src&quot;, arguments[i]);
  }
};

// Usage
$.preloadImages(&quot;image1.gif&quot;, &quot;/path/to/image2.png&quot;, &quot;some/image3.jpg&quot;);
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Timer callback functions:</p>
<pre class="brush: jscript; title: ; notranslate">
window.setTimeout(function() {
 $('#id').empty();
}, 1000);
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Adding to the width with every click:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#box&quot;).one( &quot;click&quot;, function () {
    $( this ).css( &quot;width&quot;,&quot;+=200&quot; );
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Calculate which element is the highest:</p>
<pre class="brush: jscript; title: ; notranslate">
    var t=0;
    var t_elem;
    var elem = $('.whattever');
    $(&quot;*&quot;,elem).each(function () {
	$this = $(this);
	if ( $this.outerHeight() &gt; t ) {
	    t_elem=this;
	    t=$this.outerHeight();
	}
    });
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Using jQuery for browser sniffing:</p>
<pre class="brush: jscript; title: ; notranslate">
if ($.browser.mozilla &amp;&amp; $.browser.version.indexOf('1.8.') &gt; -1) {
  $('body').addClass('ff2');
}

// add a body class for firefox 3.0 only
if($.browser.mozilla &amp;&amp; $.browser.version.substr(0,5)==&quot;1.9.0&quot;) {
  $('body').addClass('ff3');
}
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Increment or decrease an input quantity with plus &#038; minus &#8216;buttons&#8217;:</p>
<pre class="brush: jscript; title: ; notranslate">
function changeProductQuantity() {
        $('#form1').find(&quot;.plus&quot;).click(function(e)
	{
	    e.preventDefault();
            var currentVal = parseInt($('#form1').find('#qty').val());
            if (currentVal != NaN)
            {
                $('#form1').find('#qty').val(currentVal + 1);
            }
        });

        $('#product_addtocart_form').find('.minus').click(function(e)
	{
	    e.preventDefault();
            var currentVal = parseInt($('#form').find('#qty').val());
            if (currentVal != NaN &amp;&amp; currentVal &gt; 0)
            {
                $('#form1').find('#qty').val(currentVal - 1);
            }
        });
};
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Basic JSON:</p>
<pre class="brush: jscript; title: ; notranslate">
var json = [
    { &quot;red&quot;: &quot;#f00&quot; },
    { &quot;green&quot;: &quot;#0f0&quot; },
    { &quot;blue&quot;: &quot;#00f&quot; }
];

$.each(json, function() {
  $.each(this, function(name, value) {
    /// do stuff
    console.log(name + '=' + value);
  });
});
//outputs: red=#f00 green=#0f0 blue=#00f
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Example of using an argument:</p>
<pre class="brush: jscript; title: ; notranslate">
function showHeight(ele, h) {
      $(&quot;div&quot;).text(&quot;The height for the &quot; + ele +
                    &quot; is &quot; + h + &quot;px.&quot;);
    }
    $(&quot;#getp&quot;).click(function () {
      showHeight(&quot;paragraph&quot;, $(&quot;p&quot;).height());
    });
    $(&quot;#getd&quot;).click(function () {
      showHeight(&quot;document&quot;, $(document).height());
    });
    $(&quot;#getw&quot;).click(function () {
      showHeight(&quot;window&quot;, $(window).height());
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/javascript/morejquery-snippets.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scroll to show more</title>
		<link>http://www.ekstasis.net/log/javascript/scroll-to-show-more.html</link>
		<comments>http://www.ekstasis.net/log/javascript/scroll-to-show-more.html#comments</comments>
		<pubDate>Tue, 11 Oct 2011 20:24:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=561</guid>
		<description><![CDATA[This handy script allows you to show/hide a div. - if the revealed div content appears &#8216;below&#8217; the bottom of the browser window &#8211; i.e normally part of the div would not appear inside the fold &#8211; the page is scrolled up so that as much as possible of the div is displayed. - it [...]]]></description>
			<content:encoded><![CDATA[<p>This handy script allows you to show/hide a div.<br />
- if the revealed div content appears &#8216;below&#8217; the bottom of the browser window &#8211; i.e normally part of the div would not appear inside the fold &#8211; the page is scrolled up so that as much as possible of the div is displayed.<br />
- it uses {height: 0} to ensure SEO spiders don&#8217;t penalise hidden text.</p>
<p>To activate:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function(){
	expandableInfo('hiddenInfo', 'activation-button');
});
</pre>
<p>*where #hiddenInfo is the ID of the div to be revealed and #activation-button is the ID of the link to reveal the extra content.</p>
<pre class="brush: jscript; title: ; notranslate">
var currentPos = null;

function expandableInfo(moreId, moreButton){
    var moreDivID = $('#'+moreId); //Id of expandable content div
    var moreButtonId = $('#'+moreButton); //Id of button for this content div
    var moreTextLink = $(moreButtonId).text(); //Link Text
    var moreHeight = moreDivID.height(); // Get the height of expandable content div

	//Set the expandable content height to 0 / Hidden!
        moreDivID.css({ height : 0 });

	//Scroll down past the header
	function scrollWinDown(){

		currentPos = $('html,body').scrollTop(); //Store Current position before we scroll
		var divPos = $(moreDivID).offset().top; // Position of div from top
		var buttonPos = $(moreButtonId).offset().top; //Position of button from top
		var amountToScroll = buttonPos - 50; // Distance to Scroll

		if ($(window).height() &gt; divPos + moreHeight &amp;&amp; currentPos ===0){
			//console.log('no need to scroll you!');
		}else{
			if (currentPos === 0){ //If user hasnt scrolled yet
				$('html,body').animate({scrollTop: moreHeight}, 500); //Move just the height of the div
			}else{
				$('html,body').animate({scrollTop: amountToScroll}, 500); // Move to the top of button
			}
		}
	}

	//Scroll down upto the header
	function scrollWinUp(){
		$('html,body').animate({scrollTop: currentPos}, 500); //Take user back to where they were
	}

	//More open and close functionality
	$(moreButtonId).click(
            function(){
                    if(moreDivID.hasClass('open')) // If the content is already on display
                    {
                            moreDivID.stop().animate({ height: 0 });  //hide it
                            moreDivID.removeClass('open'); // and remove the class
                            $(this).text(moreTextLink); // and change the text back
                            scrollWinUp();
			    return false;
                    }else{ // Otherwise
                            moreDivID.stop().animate({ height: moreHeight }); //Show the div
                            moreDivID.addClass('open'); //add the class
                            $(this).text('Close'); // change the text
			    scrollWinDown();
                            return false;
                    }
            }

    );

}
</pre>
<p>This code was devised by <a href="http://www.hannahstothard.co.uk/">Hannah</a>. Amazing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/javascript/scroll-to-show-more.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Javascript Show Hide</title>
		<link>http://www.ekstasis.net/log/javascript/simple-javascript-show-hide.html</link>
		<comments>http://www.ekstasis.net/log/javascript/simple-javascript-show-hide.html#comments</comments>
		<pubDate>Sat, 01 Oct 2011 22:30:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=217</guid>
		<description><![CDATA[This snippet will show / hide content and change the link or button text. If javascript is turned off the content is displayed. It is helpful to set the cursor to pointer, underline the span and add a hove effect with CSS to aid usability. An alternative method, to stop the initial flash of content, [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet will show / hide content and change the link or button text. If javascript is turned off the content is displayed.</p>
<pre class="brush: jscript; title: ; notranslate">[/javascript]
function toggleText(id) {
	$('#toggleText').hide();
	$('#displayText').click(function() {
		$('#toggleText').slideToggle();
		var text = $j(this).text() == 'View the content' ? 'Hide the content' : 'View the content';
		$(this).text(text);
	});
}
1</pre>
<pre class="brush: xml; title: ; notranslate">
&lt;p id=&quot;toggleText&quot;&gt;Lorem ipsum, flotsum jetsum, and then some blah blah blah&lt;/p&gt;

&lt;span id=&quot;displayText&quot;&gt;Hide info&lt;/span&gt;
</pre>
<p>It is helpful to set the cursor to pointer, underline the span and add a hove effect with CSS to aid usability. An alternative method, to stop the initial flash of content, would be to use a link instead of a span (with return false or e.preventDefault in the javascript) and set the #displayText to display: none with CSS. The link would take the user to the content in a separate page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/javascript/simple-javascript-show-hide.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checkbox link</title>
		<link>http://www.ekstasis.net/log/css/checkbox-link.html</link>
		<comments>http://www.ekstasis.net/log/css/checkbox-link.html#comments</comments>
		<pubDate>Wed, 07 Sep 2011 21:15:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=573</guid>
		<description><![CDATA[Turning a checkbox into a &#8216;clickable&#8217; label 1. Wrap the checkbox in a label: 2: Hide the checkbox and style the label: 3. Check the box when the label is clicked:]]></description>
			<content:encoded><![CDATA[<p>Turning a checkbox into a &#8216;clickable&#8217; label</p>
<p>1. Wrap the checkbox in a label:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;label&gt;Save for later &lt;input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;list&quot; class=&quot;checkbox&quot; /&gt;&lt;/label&gt;
</pre>
<p>2: Hide the checkbox and style the label:</p>
<pre class="brush: css; title: ; notranslate">
.save-for-later {
	cursor: pointer;
}
.save-for-later input {
	display: none;
}
.checked {
	text-shadow: 1px -1px 1px rgba(68,68,68,0.4);
	position: relative;
	top: 1px;
	left: 1px;
}
</pre>
<p>3. Check the box when the label is clicked:</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery(function() {
    labelCheck();
});

function labelCheck() {
    $(&quot;#container .save-for-later&quot;).each( function(){
	$(this).find('input:checkbox').change(function() {
	    $(this).parent().toggleClass('checked');
	});
    });
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/css/checkbox-link.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery snippets</title>
		<link>http://www.ekstasis.net/log/javascript/jquery-snippets-2.html</link>
		<comments>http://www.ekstasis.net/log/javascript/jquery-snippets-2.html#comments</comments>
		<pubDate>Mon, 22 Aug 2011 21:09:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=567</guid>
		<description><![CDATA[Alter the first paragraph: Count list: Using the .hover() method: Change dimensions of an element: $(this) refers to all jQuery objects while this refers to the calling object in javascript. For example, we want to use .each and fadeIn() of jQuery after a selector such as below, since fadeIn() is a jQuery effect function, we [...]]]></description>
			<content:encoded><![CDATA[<p>Alter the first paragraph:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;h2 + p&quot;).addClass(&quot;Large&quot;);
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Count list:</p>
<pre class="brush: jscript; title: ; notranslate">
var myList = $('.myList');

for (i = 0; i &lt; 1000; i++) {
    myList.append('This is list item ' + i);
}
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Using the .hover() method:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;p&quot;).hover(function () {
    $(this).css({'background-color' : 'yellow', 'font-weight' : 'bolder'});
}, function () {
    var cssObj = {
      'background-color' : '#ddd',
      'font-weight' : '',
      'color' : 'blue'
    }
    $(this).css(cssObj);
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Change dimensions of an element:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;div&quot;).click(function() {
    $(this).css({
      width: function(index, value) {
        return parseFloat(value) * 1.2;
      },
      height: function(index, value) {
        return parseFloat(value) * 1.2;
      }

    });
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>$(this) refers to all jQuery objects while this refers to the calling object in javascript.  For example, we want to use .each and fadeIn() of jQuery after a selector such as below,</p>
<pre class="brush: jscript; title: ; notranslate">
$('div#product').each(function(){
	$(this).fadeIn()
})
</pre>
<p>since fadeIn() is a jQuery effect function, we use $(this) but if we are not dealing with jQuery objects we use this instead.</p>
<pre class="brush: jscript; title: ; notranslate">
$('.product').each(function(){
	var myClass = this.className; // provided you have multiple class product
})
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Click on each word in paragraph:</p>
<pre class="brush: jscript; title: ; notranslate">
var words = $(&quot;p:first&quot;).text().split(&quot; &quot;);
var text = words.join(&quot;&lt;/span&gt; &lt;span&gt;&quot;);
$(&quot;p:first&quot;).html(&quot;&lt;span&gt;&quot; + text + &quot;&lt;/span&gt;&quot;);
$(&quot;span&quot;).click(function () {
    $(this).css(&quot;background-color&quot;,&quot;yellow&quot;);
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Remove a word in a text:</p>
<pre class="brush: jscript; title: ; notranslate">
var el = $('#id');
el.html(el.html().replace(/word/ig, &quot;&quot;));
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Replace a div:</p>
<pre class="brush: jscript; title: ; notranslate">
$('#thatdiv').replaceWith('&lt;p&gt;Your new content goes here&lt;/p&gt;');
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Append text:</p>
<pre class="brush: jscript; title: ; notranslate">
$('#lal').append(&quot;&lt;b&gt;lol&lt;/b&gt;&quot;);
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Combine more than one effects in jQuery to animate and remove:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#myButton&quot;).click(function() {
         $(&quot;#myDiv&quot;).fadeTo(&quot;slow&quot;, 0.01, function(){ //fade
             $(this).slideUp(&quot;slow&quot;, function() { //slide up
                 $(this).remove(); //then remove from the DOM
             });
         });
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Test if something is hidden using jQuery:</p>
<pre class="brush: jscript; title: ; notranslate">
if($(element).is(&quot;:visible&quot;) == &quot;true&quot;) {
       //The element is Visible
}
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Center an element on the Screen:</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery.fn.center = function () {
    this.css(&quot;position&quot;,&quot;absolute&quot;);
    this.css(&quot;top&quot;, ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + &quot;px&quot;);
    this.css(&quot;left&quot;, ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + &quot;px&quot;);
    return this;
}
</pre>
<p>//Use the above function as:<br />
$(element).center();</p>
<p><br/><br />
<hr/><br/></p>
<p>Smooth Scrolling:</p>
<pre class="brush: jscript; title: ; notranslate">
$('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
      &amp;&amp; location.hostname == this.hostname) {
       var $target = $(this.hash);
       $target = $target.length &amp;&amp; $target || $('[name=' + this.hash.slice(1) +']');
       if ($target.length) {
           $target.ScrollTo(400);
           return false;
       }
    };
 });
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Equal Height Columns:</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery.fn.equalHeight = function () {
	var tallest = 0;
	this.each(function() {
		tallest = ($(this).height() &gt; tallest)? $(this).height() : tallest;
	});
	return this.height(tallest);
}

//Now you can call equalHeight
$(&quot;.content-column&quot;).equalHeight();
</pre>
<p><br/><br />
<hr/><br/></p>
<pre class="brush: jscript; title: ; notranslate">
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight &gt; tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

//Usage:
$(document).ready(function() {
    equalHeight($(&quot;.recent-article&quot;));
    equalHeight($(&quot;.footer-col&quot;));
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Extending jQuery with a custom selector:</p>
<pre class="brush: jscript; title: ; notranslate">
//extend the jQuery functionality
$.extend($.expr[':'], {  

    //name of your special selector
    moreThanAThousand : function (a){
        //Matching element
        return parseInt($(a).html()) &gt; 1000;
    }
});  

$(document).ready(function() {
    $('td:moreThanAThousand').css('background-color', '#ff0000');
});
</pre>
<pre class="brush: jscript; title: ; notranslate">
$.extend($.expr[&quot;:&quot;], {
    over100pixels: function (e)
    {
        return $(e).height() &gt; 100;
    }
});

$(&quot;.box:over100pixels&quot;).click(function ()
{
    alert(&quot;The element you clicked is over 100 pixels height&quot;);
});
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Access iFrame Elements:</p>
<pre class="brush: jscript; title: ; notranslate">
var iFrameDOM = $(&quot;iframe#someID&quot;).contents();
//Now you can use find() to access any element in the iframe:

iFrameDOM.find(&quot;.message&quot;).slideUp();
//Slides up all elements classed 'message' in the iframe
</pre>
<p><br/><br />
<hr/><br/></p>
<p>Fade in page:</p>
<pre class="brush: jscript; title: ; notranslate">
var $container = $(&quot;body&quot;);
$container.hide().fadeIn(400);

$(&quot;a&quot;).live('click', function(e) {
	e.preventDefault();
	$container.fadeOut(400, function() {
		document.location = this.href;
	});
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/javascript/jquery-snippets-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display images from gallery</title>
		<link>http://www.ekstasis.net/log/wordpress-dev/display-images-from-gallery.html</link>
		<comments>http://www.ekstasis.net/log/wordpress-dev/display-images-from-gallery.html#comments</comments>
		<pubDate>Sat, 16 Jul 2011 21:42:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=585</guid>
		<description><![CDATA[You can use this snippet in your wordpress functions.php file to get all images attached to a post (i.e. in the gallery of that post.) I use it in this blog to show post images or slideshows. Add the following in the template: Here&#8217;s how I&#8217;m using it with a carousel: Here&#8217;s a more straight-forward [...]]]></description>
			<content:encoded><![CDATA[<p>You can use this snippet in your wordpress functions.php file to get all images attached to a post (i.e. in the gallery of that post.) I use it in this blog to show post images or slideshows.</p>
<pre class="brush: php; title: ; notranslate">
function getPostImages() {
	global $post;
	$attachments = get_children(
				    array(
				    'post_parent' =&gt; $post-&gt;ID,
				    'post_status' =&gt; 'inherit',
				    'post_type' =&gt; 'attachment',
				    'post_mime_type' =&gt; 'image',
				    'exclude' =&gt; array(get_post_thumbnail_id()),
				    'order' =&gt; 'ASC',
				    'orderby' =&gt; 'menu_order ID') );
	if( empty($attachments) ) {
	return false;
	}
	return $attachments;
}
</pre>
<p>Add the following in the template:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
    $postImages = getPostImages();
    if($postImages !=0) :
        $images = array_values(getPostImages());
        $num_images = count($images);

        for ($i = 0; $i &lt; $num_images; $i++): $image = $images[$i];
            while (have_posts()) :
                the_post();
?&gt;
                &lt;img src=&quot;&lt;?php echo $images[$i]-&gt;guid ?&gt;&quot; alt=&quot;&lt;?php echo $images[$i]-&gt;post_title ?&gt;&quot; /&gt;
&lt;?php
            endwhile;
        endfor; 

    endif;
?&gt;
</pre>
<p>Here&#8217;s how I&#8217;m using it with a carousel:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
    $postImages = getPostImages(); //gets all images related to this post
    if($postImages !=0) :

        $images = array_values(getPostImages());
        $num_images = count($images);

        if($num_images ==1): ?&gt;
            &lt;div id=&quot;single_image&quot;&gt;
                &lt;img src=&quot;&lt;?php echo $images[0]-&gt;guid ?&gt;&quot; alt=&quot;&lt;?php echo $images[0]-&gt;post_title ?&gt;&quot; /&gt;
            &lt;/div&gt;
&lt;?php
        elseif($num_images &gt; 1) :
?&gt;
            &lt;div class=&quot;scrollable&quot; id=&quot;single-scrollable&quot;&gt;
                &lt;a class=&quot;prev browse left&quot;&gt;&lt;/a&gt;
                &lt;div class=&quot;items&quot;&gt;
                    &lt;?php for ($i = 0; $i &lt; $num_images; $i++): $image = $images[$i]; ?&gt;
                        &lt;?php while (have_posts()) : ?&gt;
                            &lt;?php the_post(); ?&gt;
                            &lt;div class=&quot;item&quot;&gt;&lt;img src=&quot;&lt;?php echo $images[$i]-&gt;guid ?&gt;&quot; alt=&quot;&lt;?php echo $images[$i]-&gt;post_title ?&gt;&quot; /&gt;&lt;/div&gt;
                        &lt;?php endwhile; ?&gt;
                    &lt;?php endfor; ?&gt;
                &lt;/div&gt; &lt;!-- /.items --&gt;

                &lt;div class=&quot;navi&quot;&gt;&lt;/div&gt;
                &lt;a class=&quot;next browse right&quot;&gt;&lt;/a&gt;
            &lt;/div&gt; &lt;!-- END .scrollable #single-scrollable --&gt;

&lt;?php
         endif; // &lt;&lt;&lt; CAROUSEL
    endif; // HAS ANY IMAGES
?&gt;
</pre>
<p>Here&#8217;s a more straight-forward method &#8211; Just add this inside the template:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$attachments = get_posts(array
	(
	'post_type' =&gt; 'attachment',
	'numberposts' =&gt; -1,
	'post_status' =&gt; 'published',
	'exclude' =&gt; array(get_post_thumbnail_id()),
	'post_parent' =&gt; $post-&gt;ID,
	)
);
	if ($attachments) {
		foreach ( $attachments as $attachment ) {?&gt;
			&lt;div class=&quot;classname&quot;&gt;
				&lt;?php echo wp_get_attachment_image($attachment-&gt;ID, 'fullsize'); ?&gt;
			&lt;/div&gt;
		&lt;?php }
	}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/wordpress-dev/display-images-from-gallery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS3 graceful degredation</title>
		<link>http://www.ekstasis.net/log/css/css3-graceful-degredation.html</link>
		<comments>http://www.ekstasis.net/log/css/css3-graceful-degredation.html#comments</comments>
		<pubDate>Wed, 13 Jul 2011 22:27:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>

		<guid isPermaLink="false">http://www.ekstasis.net/log/?p=577</guid>
		<description><![CDATA[1. Use @font-face with a @font-face generator (e.g. from font squirrel) that includes EOT (to target IE 6 &#8211; 8), WOFF (for IE9+, FF3.6+, Chrome 5+) and SVG (for iOS devices before version 4.2.) and TrueType (for everything else) 2. http://www.modernizr.com/ &#8211; adds feature capability as classes to the HTML tag. 3. http://selectivizr.com/ &#8211; adds [...]]]></description>
			<content:encoded><![CDATA[<p>1. Use @font-face with a @font-face generator (e.g. from font squirrel) that includes EOT (to target IE 6 &#8211; 8), WOFF (for IE9+, FF3.6+, Chrome 5+) and SVG (for iOS devices before version 4.2.) and TrueType (for everything else)</p>
<p>2. http://www.modernizr.com/ &#8211; adds feature capability as classes to the HTML tag.</p>
<p>3. http://selectivizr.com/ &#8211; adds pseudo classes for IE6 &#038; 7</p>
<p>4. Webkit doesn&#8217;t do inset shadows with round corners, but adding normal drop shadow in a minus direction may give a good equivalent. (corrected in latest version)</p>
<p>5. For IE it&#8217;s difficult to add round corners and drop shadows.</p>
<p>There&#8217;s a good tutorial from http://www.w3.org/Style/Examples/007/roundshadow.en.html to add drop shadows without extra markup. Good only for IE8.</p>
<p>In conjunction with http://selectivizr.com/ this can allow us to even add round corners in IE6 &#038; 7. (also good for zebra table styling, IE6 hover, targeting a variety of different inputs)</p>
<p>or use jQuery: </p>
<pre class="brush: jscript; title: ; notranslate">
$('blockquote:after').addClass(&amp;quot;boom&amp;quot;); &lt;br /&gt;
$('blockquote').after(' &amp;lt;img src=&amp;quot;/images/external.png&amp;quot; alt=&amp;quot;external link&amp;quot;/&amp;gt;'); &lt;br /&gt;
$(&amp;quot;img.dropshadow&amp;quot;).wrap(&amp;quot;&amp;lt;div class='wrap1'&amp;gt;&amp;lt;div class='wrap2'&amp;gt;&amp;quot; + &amp;quot;&amp;lt;div class='wrap3'&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;);
</pre>
<p>Or use curvy corners: http://blue-anvil.com/jquerycurvycorners/test.html</p>
<p>6. Gradient filters<br />
- e.g.<br />
filter:  progid:DXImageTransform.Microsoft.gradient(startColorStr=&#8217;#c31026&#8242;, EndColorStr=&#8217;#5f0004&#8242;);</p>
<p>for IE &#8211; only work on IE6 &#038; 7 if a height is set. (If you cannot use a height then set a background image &#8211; you will need background images for gradients in older versions of Firefox and Safari.)</p>
<p>7. Combining background images and gradients:</p>
<p>Opera cannot combine background images and gradients, but purports to support css-gradiesnts. Therefore the background image needs to be positioned using a separate element e.g. a span inside a button, &#8211; if for example you want just the gradient to reverse on hover, or you need to serve different css to opera browsers. This is the same for IE (including IE9)</p>
<p>8. Test in:</p>
<p>Firefox 3.6.13<br />
Firefox 3.0 (No support for CSS3 round corners &#038; gradients)<br />
Firefox 2.0 (No support for CSS3 round corners &#038; gradients)</p>
<p>IE 8 &#8211; (No support for CSS3 round corners)<br />
IE 7 &#8211; (No support for CSS3 round corners &#038; gradients)<br />
IE 6 &#8211; (Fully functional, No support for PNG opacity, CSS3)</p>
<p>Safari 5 (5.0.2)<br />
Safari 4 (4.0.5)<br />
Safari 3 (3.2.3)</p>
<p>Chrome 8</p>
<p>Opera 11<br />
Opera 10 (10.6.3) (No support for CSS3 round corners &#038; gradients)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ekstasis.net/log/css/css3-graceful-degredation.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

