html5 – Correct way to use Modernizr to detect IE? – Stack Overflow

var BrowserDetect = {
        init: function () {
            this.browser = this.searchString(this.dataBrowser) || "Other";
            this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown";
        },
        searchString: function (data) {
            for (var i = 0; i < data.length; i++) {
                var dataString = data[i].string;
                this.versionSearchString = data[i].subString;

                if (dataString.indexOf(data[i].subString) !== -1) {
                    return data[i].identity;
                }
            }
        },
        searchVersion: function (dataString) {
            var index = dataString.indexOf(this.versionSearchString);
            if (index === -1) {
                return;
            }

            var rv = dataString.indexOf("rv:");
            if (this.versionSearchString === "Trident" && rv !== -1) {
                return parseFloat(dataString.substring(rv + 3));
            } else {
                return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
            }
        },

        dataBrowser: [
            {string: navigator.userAgent, subString: "Chrome", identity: "Chrome"},
            {string: navigator.userAgent, subString: "MSIE", identity: "Explorer"},
            {string: navigator.userAgent, subString: "Trident", identity: "Explorer"},
            {string: navigator.userAgent, subString: "Firefox", identity: "Firefox"},
            {string: navigator.userAgent, subString: "Safari", identity: "Safari"},
            {string: navigator.userAgent, subString: "Opera", identity: "Opera"}
        ]

    };
    
    BrowserDetect.init();
    document.write("You are using <b>" + BrowserDetect.browser + "</b> with version <b>" + BrowserDetect.version + "</b>");

html5 – Correct way to use Modernizr to detect IE? – Stack Overflow. (more…)

Read More

How to Change the WooCommerce Return to Shop Button

// Tutorial: http://www.skyverge.com/blog/change-woocommerce-return-to-shop-button/
function skyverge_change_empty_cart_button_url() {
	return get_site_url();
	//Can use any page instead, like return '/sample-page/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'skyverge_change_empty_cart_button_url' );

How to Change the WooCommerce Return to Shop Button – https://www.skyverge.com/blog/change-woocommerce-return-to-shop-button/. (more…)

Read More

Taxonomy title output

if( is_tax() ) {
    global $wp_query;
    $term = $wp_query->get_queried_object();
    $title = $term->name;
}

via WordPress › Support » Taxonomy title output. (more…)

Read More

Sort table rows by column

Html:
<table name="mytable" id="mytable">
  <thead>
    <tr><th>column1</th><th>column2</th><th>column3</th></tr>
  </thead>
  <tbody>
    <tr><td>value1</td><td>value2</td><td>value3</td></tr>
    <tr><td>value4</td><td>value5</td><td>value6</td></tr>
    <tr><td>value7</td><td>value8</td><td>value9</td></tr>
  </tbody>
</table>

Javascript
function sortTable(){
		  var rows = $('#cartable tbody  tr').get();

		  rows.sort(function(a, b) {

		  var A = $(a).children('td').eq(1).text().toUpperCase();
		  var B = $(b).children('td').eq(1).text().toUpperCase();

		  if(A < B) {
		    return -1;
		  }

		  if(A > B) {
		    return 1;
		  }

		  return 0;

		  });

		  $.each(rows, function(index, row) {
		    $('#cartable').children('tbody').append(row);
		  });
		}

  (more…)

Read More

jQuery Tabs Tutorial

Tabs are easy to implement and can be built to work with your existing markup. This guide will walk through the process.

 $('ul.tabs').each(function(){
    // For each set of tabs, we want to keep track of
    // which tab is active and it's associated content
    var $active, $content, $links = $(this).find('a');

    // If the location.hash matches one of the links, use that as the active tab.
    // If no match is found, use the first link as the initial active tab.
    $active = $($links.filter('[href="'+location.hash+'"]')[0] || $links[0]);
    $active.addClass('active');

    $content = $($active[0].hash);

    // Hide the remaining content
    $links.not($active).each(function () {
      $(this.hash).hide();
    });

    // Bind the click event handler
    $(this).on('click', 'a', function(e){
      // Make the old tab inactive.
      $active.removeClass('active');
      $content.hide();

      // Update the variables with the new link and content
      $active = $(this);
      $content = $(this.hash);

      // Make the tab active.
      $active.addClass('active');
      $content.show();

      // Prevent the anchor's default click action
      e.preventDefault();
    });
  });

jQuery Tabs Tutorial. (more…)

Read More

Fade in/out carousel

$(document).ready(function(){
		function fade(){
			$div = $('.item');
			$first = $('.item:first-child');
			$last = $('.item:last-child');

			

				if($first.is(':visible')){
					$first.hide();

					$next = $first.next();
					$next.fadeIn();
				}
				else if($last.is(':visible')){ $last.hide(); $first.fadeIn();}
				else{
					$next.hide();

					$next = $next.next();
					$next.fadeIn();
				}


			setTimeout( function(){fade();} , 5000);
		}

		setTimeout( function(){fade();} , 5000);
	})

(more…)

Read More