(function( $ ) { $(function() { // setup sample data window.numbers = [ 0, 1, 10, 100, 1000, 10000, 0.1, 0.12, 0.123, 0.1234, 0.12345, 1000.123, 10000.12345, -1, -10, -100, -1000, -10000, -0.1, -0.12, -0.123, -0.1234, -0.12345, -1000.123, -10000.12345 ]; window.formats = [ "n", "n1", "n3", "d", "d2", "d3", "p", "p1", "p3", "c", "c0" ]; window.dates = $.map([ "Jan 1, 1970 1:34 PM", "Dec 31, 1970 1:34 PM", "Apr 1, 1999 1:34 PM", "Dec 31, 1999 1:34 PM", "Jan 1, 2000 1:34 PM", "Nov 5, 1955 1:34 PM" ], function(d) { return d instanceof Date ? d : new Date(Date.parse(d)); } ); window.dateFormats = [ "d", "D", "f", "F", "M", "S", "t", "T", "Y" ]; // add template extensions to format numbers and dates declaratively $.extend( $.tmplcmd, { demoFormat: { _default: [0,0], prefix: "_.push(Globalize.format(numbers[$2],formats[$1]));" }, demoDateFormat: { _default: [0,0], prefix: "_.push(Globalize.format(dates[$2],typeof $1 === 'number' ? dateFormats[$1] : $1));" } }); // activate tabs $(".tab").click(function() { $(".active").removeClass("active").addClass("inactive"); $("#" + this.id + "content").removeClass("inactive").addClass("active"); $(this).removeClass("inactive").addClass("active"); }); // fill cultures dropdown with the available cultures $.each(sortByName(Globalize.cultures), function(i, culture) { $("