From 2760db08b2de71f7489d7165d13a3c0cad0b5448 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 1 Nov 2011 16:07:20 -0700 Subject: [PATCH] Back porting Pager shapes from dev branch --HG-- branch : 1.x --- src/Orchard.Web/Core/Orchard.Core.csproj | 1 - src/Orchard.Web/Core/Shapes/CoreShapes.cs | 297 +- .../Core/Shapes/Views/Pager.cshtml | 54 - .../Services/UrlAlternatesFactory.cs | 10 +- .../Orchard.jQuery/Scripts/jquery.utils.js | 3300 ++++++++--------- .../Themes/TheAdmin/Styles/site.css | 4 +- .../Themes/TheAdmin/Views/Pager.cshtml | 86 +- .../Themes/TheThemeMachine/Styles/Site.css | 30 +- .../TheThemeMachine/Views/Pager.First.cshtml | 1 + .../TheThemeMachine/Views/Pager.Last.cshtml | 1 + .../Themes/TheThemeMachine/Views/Pager.cshtml | 9 + src/Orchard.Web/Themes/Themes.csproj | 9 + .../CSharpExtensionBuildProviderShim.cs | 4 + 13 files changed, 1998 insertions(+), 1808 deletions(-) delete mode 100644 src/Orchard.Web/Core/Shapes/Views/Pager.cshtml create mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.First.cshtml create mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.Last.cshtml create mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.cshtml diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 092645456..0abe6ec2f 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -388,7 +388,6 @@ - diff --git a/src/Orchard.Web/Core/Shapes/CoreShapes.cs b/src/Orchard.Web/Core/Shapes/CoreShapes.cs index 51de1cd3d..24e7bedf3 100644 --- a/src/Orchard.Web/Core/Shapes/CoreShapes.cs +++ b/src/Orchard.Web/Core/Shapes/CoreShapes.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; @@ -6,10 +7,12 @@ using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; +using System.Web.Routing; using Orchard.DisplayManagement; using Orchard.DisplayManagement.Descriptors; using Orchard.DisplayManagement.Descriptors.ResourceBindingStrategy; using Orchard.Environment; +using Orchard.Localization; using Orchard.Mvc; using Orchard.Settings; using Orchard.UI; @@ -33,8 +36,12 @@ namespace Orchard.Core.Shapes { _workContext = workContext; _resourceManager = resourceManager; _httpContextAccessor = httpContextAccessor; + + T = NullLocalizer.Instance; } + public Localizer T { get; set; } + public void Discover(ShapeTableBuilder builder) { // the root page shape named 'Layout' is wrapped with 'Document' // and has an automatic zone creating behavior @@ -95,7 +102,7 @@ namespace Orchard.Core.Shapes { menu.Classes.Add("localmenu"); menu.Metadata.Alternates.Add("LocalMenu__" + menuName); }); - + builder.Describe("LocalMenuItem") .OnDisplaying(displaying => { var menuItem = displaying.Shape; @@ -103,6 +110,73 @@ namespace Orchard.Core.Shapes { menuItem.Metadata.Alternates.Add("LocalMenuItem__" + menu.MenuName); }); + #region Pager alternates + builder.Describe("Pager") + .OnDisplaying(displaying => { + var pager = displaying.Shape; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + displaying.Shape.Metadata.Alternates.Add("Pager__" + EncodeAlternateElement(pagerId)); + }); + + builder.Describe("Pager_Gap") + .OnDisplaying(displaying => { + var pager = displaying.Shape.Pager; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + pager.Metadata.Alternates.Add("Pager_Gap__" + EncodeAlternateElement(pagerId)); + }); + + builder.Describe("Pager_First") + .OnDisplaying(displaying => { + var pager = displaying.Shape.Pager; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + displaying.Shape.Metadata.Alternates.Add("Pager_First__" + EncodeAlternateElement(pagerId)); + }); + + builder.Describe("Pager_Previous") + .OnDisplaying(displaying => { + var pager = displaying.Shape.Pager; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + displaying.Shape.Metadata.Alternates.Add("Pager_Previous__" + EncodeAlternateElement(pagerId)); + }); + + builder.Describe("Pager_Next") + .OnDisplaying(displaying => { + var pager = displaying.Shape.Pager; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + displaying.Shape.Metadata.Alternates.Add("Pager_Next__" + EncodeAlternateElement(pagerId)); + }); + + builder.Describe("Pager_Last") + .OnDisplaying(displaying => { + var pager = displaying.Shape.Pager; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + displaying.Shape.Metadata.Alternates.Add("Pager_Last__" + EncodeAlternateElement(pagerId)); + }); + + builder.Describe("Pager_CurrentPage") + .OnDisplaying(displaying => { + var pager = displaying.Shape.Pager; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + displaying.Shape.Metadata.Alternates.Add("Pager_CurrentPage__" + EncodeAlternateElement(pagerId)); + }); + + builder.Describe("Pager_Links") + .OnDisplaying(displaying => { + var pager = displaying.Shape; + string pagerId = pager.PagerId; + if (!String.IsNullOrWhiteSpace(pagerId)) + displaying.Shape.Metadata.Alternates.Add("Pager_Links__" + EncodeAlternateElement(pagerId)); + }); + + #endregion + // 'List' shapes start with several empty collections builder.Describe("List") .OnCreated(created => { @@ -240,12 +314,12 @@ namespace Orchard.Core.Shapes { [Shape] public void Style(TextWriter Output, ResourceDefinition Resource, string Url, string Condition, Dictionary TagAttributes) { - UI.Resources.ResourceManager.WriteResource(Output, Resource, Url, Condition, TagAttributes); + ResourceManager.WriteResource(Output, Resource, Url, Condition, TagAttributes); } [Shape] public void Resource(TextWriter Output, ResourceDefinition Resource, string Url, string Condition, Dictionary TagAttributes) { - UI.Resources.ResourceManager.WriteResource(Output, Resource, Url, Condition, TagAttributes); + ResourceManager.WriteResource(Output, Resource, Url, Condition, TagAttributes); } private static void WriteLiteralScripts(TextWriter output, IEnumerable scripts) { @@ -296,6 +370,206 @@ namespace Orchard.Core.Shapes { } } + [Shape] + public IHtmlString Pager_Links(dynamic Shape, dynamic Display, + int Page, + int PageSize, + double TotalItemCount, + int? Quantity, + object FirstText, + object PreviousText, + object NextText, + object LastText, + object GapText, + string PagerId + // parameter omitted to workaround an issue where a NullRef is thrown + // when an anonymous object is bound to an object shape parameter + /*object RouteValues*/) { + + var currentPage = Page; + if (currentPage < 1) + currentPage = 1; + + var pageSize = PageSize; + if (pageSize < 1) + pageSize = _workContext.Value.CurrentSite.PageSize; + + var numberOfPagesToShow = Quantity ?? 0; + if (Quantity == null || Quantity < 0) + numberOfPagesToShow = 7; + + var totalPageCount = Math.Ceiling(TotalItemCount / pageSize); + + var firstText = FirstText ?? T("<<"); + var previousText = PreviousText ?? T("<"); + var nextText = NextText ?? T(">"); + var lastText = LastText ?? T(">>"); + var gapText = GapText ?? T("..."); + + // workaround: get it from the shape instead of parameter + var RouteValues = (object)Shape.RouteValues; + var RouteData = RouteValues is RouteValueDictionary ? (RouteValueDictionary) RouteValues : new RouteValueDictionary(RouteValues); + var queryString = _workContext.Value.HttpContext.Request.QueryString; + if (queryString != null) { + foreach (var key in from string key in queryString.Keys where key != null && !RouteData.ContainsKey(key) let value = queryString[key] select key) { + RouteData[key] = queryString[key]; + } + } + + if (Shape.RouteData != null) { + var shapeRouteData = Shape.RouteData is RouteValueDictionary ? (RouteValueDictionary) RouteValues : new RouteValueDictionary(RouteValues); + foreach (var rd in shapeRouteData) { + shapeRouteData[rd.Key] = rd.Value; + } + } + + if (RouteData.ContainsKey("id")) + RouteData.Remove("id"); + + // HACK: MVC 3 is adding a specific value in System.Web.Mvc.Html.ChildActionExtensions.ActionHelper + // when a content item is set as home page, it is rendered by using Html.RenderAction, and the routeData is altered + // This code removes this extra route value + var removedKeys = RouteData.Keys.Where(key => RouteData[key] is DictionaryValueProvider).ToList(); + foreach (var key in removedKeys) { + RouteData.Remove(key); + } + + var firstPage = Math.Max(1, Page - (numberOfPagesToShow / 2)); + var lastPage = Math.Min(totalPageCount, Page + (numberOfPagesToShow / 2)); + + var pageKey = String.IsNullOrEmpty(PagerId) ? "page" : PagerId; + + Shape.Classes.Add("pager"); + Shape.Metadata.Alternates.Clear(); + Shape.Metadata.Type = "List"; + + // first and previous pages + if (Page > 1) { + if (RouteData.ContainsKey(pageKey)) { + RouteData.Remove(pageKey); // to keep from having "page=1" in the query string + } + // first + Shape.Add(Display.Pager_First(Value: firstText, RouteValues: RouteData, Pager: Shape)); + + // previous + if (currentPage > 2) { // also to keep from having "page=1" in the query string + RouteData[pageKey] = currentPage - 1; + } + Shape.Add(Display.Pager_Previous(Value: previousText, RouteValues: RouteData, Pager: Shape)); + } + + // gap at the beginning of the pager + if (firstPage > 1 && numberOfPagesToShow > 0) { + Shape.Add(Display.Pager_Gap(Value: gapText, Pager: Shape)); + } + + // page numbers + if (numberOfPagesToShow > 0) { + for (var p = firstPage; p <= lastPage; p++) { + if (p == currentPage) { + Shape.Add(Display.Pager_CurrentPage(Value: p, RouteValues: RouteData, Pager: Shape)); + } + else { + if (p == 1) + RouteData.Remove(pageKey); + else + RouteData[pageKey] = p; + Shape.Add(Display.Pager_Link(Value: p, RouteValues: RouteData, Pager: Shape)); + } + } + } + + // gap at the end of the pager + if (lastPage < totalPageCount && numberOfPagesToShow > 0) { + Shape.Add(Display.Pager_Gap(Value: gapText, Pager: Shape)); + } + + // next and last pages + if (Page < totalPageCount) { + // next + RouteData[pageKey] = Page + 1; + Shape.Add(Display.Pager_Next(Value: nextText, RouteValues: RouteData, Pager: Shape)); + // last + RouteData[pageKey] = totalPageCount; + Shape.Add(Display.Pager_Last(Value: lastText, RouteValues: RouteData, Pager: Shape)); + } + + return Display(Shape); + } + + [Shape] + public IHtmlString Pager(dynamic Shape, dynamic Display) { + Shape.Metadata.Alternates.Clear(); + Shape.Metadata.Type = "Pager_Links"; + return Display(Shape); + } + + [Shape] + public IHtmlString Pager_First(dynamic Shape, dynamic Display) { + Shape.Metadata.Alternates.Clear(); + Shape.Metadata.Type = "Pager_Link"; + return Display(Shape); + } + + [Shape] + public IHtmlString Pager_Previous(dynamic Shape, dynamic Display) { + Shape.Metadata.Alternates.Clear(); + Shape.Metadata.Type = "Pager_Link"; + return Display(Shape); + } + + [Shape] + public IHtmlString Pager_CurrentPage(HtmlHelper Html, dynamic Display, object Value) { + var tagBuilder = new TagBuilder("span"); + tagBuilder.InnerHtml = Html.Encode(Value is string ? (string)Value : Display(Value)); + + return MvcHtmlString.Create(tagBuilder.ToString()); + } + + [Shape] + public IHtmlString Pager_Next(dynamic Shape, dynamic Display) { + Shape.Metadata.Alternates.Clear(); + Shape.Metadata.Type = "Pager_Link"; + return Display(Shape); + } + + [Shape] + public IHtmlString Pager_Last(dynamic Shape, dynamic Display) { + Shape.Metadata.Alternates.Clear(); + Shape.Metadata.Type = "Pager_Link"; + return Display(Shape); + } + + [Shape] + public IHtmlString Pager_Link(dynamic Shape, dynamic Display) { + Shape.Metadata.Alternates.Clear(); + Shape.Metadata.Type = "ActionLink"; + return Display(Shape); + } + + [Shape] + public IHtmlString ActionLink(HtmlHelper Html, dynamic Shape, dynamic Display, object Value) { + var RouteValues = (object)Shape.RouteValues; + RouteValueDictionary rvd; + if (RouteValues == null) { + rvd = new RouteValueDictionary(); + } + else { + rvd = RouteValues is RouteValueDictionary ? (RouteValueDictionary)RouteValues : new RouteValueDictionary(RouteValues); + } + + string value = Html.Encode(Value is string ? (string)Value : Display(Value)); + return @Html.ActionLink(value, (string)rvd["action"], (string)rvd["controller"], rvd, null); + } + + [Shape] + public IHtmlString Pager_Gap(HtmlHelper Html, dynamic Display, object Value) { + var tagBuilder = new TagBuilder("span"); + tagBuilder.InnerHtml = Html.Encode(Value is string ? (string)Value : Display(Value)); + + return MvcHtmlString.Create(tagBuilder.ToString()); + } + [Shape] public void List( dynamic Display, @@ -311,7 +585,8 @@ namespace Orchard.Core.Shapes { if (Items == null) return; - var count = Items.Count(); + var itemDisplayOutputs = Items.Select(item => Display(item)).Where(output => !string.IsNullOrWhiteSpace(output.ToHtmlString())).ToList(); + var count = itemDisplayOutputs.Count(); if (count < 1) return; @@ -322,14 +597,14 @@ namespace Orchard.Core.Shapes { Output.Write(listTag.ToString(TagRenderMode.StartTag)); var index = 0; - foreach (var item in Items) { + foreach (var itemDisplayOutput in itemDisplayOutputs) { var itemTag = GetTagBuilder(itemTagName, null, ItemClasses, ItemAttributes); if (index == 0) itemTag.AddCssClass("first"); if (index == count - 1) itemTag.AddCssClass("last"); Output.Write(itemTag.ToString(TagRenderMode.StartTag)); - Output.Write(Display(item)); + Output.Write(itemDisplayOutput); Output.Write(itemTag.ToString(TagRenderMode.EndTag)); ++index; } @@ -386,5 +661,13 @@ namespace Orchard.Core.Shapes { public ViewDataDictionary ViewData { get; set; } } + /// + /// Encodes dashed and dots so that they don't conflict in filenames + /// + /// + /// + private string EncodeAlternateElement(string alternateElement) { + return alternateElement.Replace("-", "__").Replace(".", "_"); + } } } diff --git a/src/Orchard.Web/Core/Shapes/Views/Pager.cshtml b/src/Orchard.Web/Core/Shapes/Views/Pager.cshtml deleted file mode 100644 index 721cfe498..000000000 --- a/src/Orchard.Web/Core/Shapes/Views/Pager.cshtml +++ /dev/null @@ -1,54 +0,0 @@ -@{ - var nextText = HasText(Model.NextText) ? Model.NextText : T("Older").Text; - var previousText = HasText(Model.PreviousText) ? Model.PreviousText : T("Newer").Text; - - var routeData = new RouteValueDictionary(ViewContext.RouteData.Values); - var queryString = ViewContext.HttpContext.Request.QueryString; - if (queryString != null) { - foreach (string key in queryString.Keys) { - if (key != null && !routeData.ContainsKey(key)) { - var value = queryString[key]; - routeData[key] = queryString[key]; - } - } - } - - if (routeData.ContainsKey("id") && !HasText(routeData["id"])) { - routeData.Remove("id"); - } - - // HACK: MVC 3 is adding a specific value in System.Web.Mvc.Html.ChildActionExtensions.ActionHelper - // when a content item is set as home page, it is rendered by using Html.RenderAction, and the routeData is altered - // This code removes this extra route value - var removedKeys = routeData.Keys.Where(key => routeData[key] is DictionaryValueProvider).ToList(); - foreach(string key in removedKeys) { - routeData.Remove(key); - } - - var hasNextPage = (Model.Page * Model.PageSize) < Model.TotalItemCount; - - Model.Classes.Add("pager"); - Model.Classes.Add("group"); - var tag = Tag(Model, "ul"); -} -@if (hasNextPage || Model.Page > 1) { - @tag.StartElement - if(hasNextPage) { - routeData["page"] = Model.Page + 1; -
  • - @Html.ActionLink((string)nextText, (string)routeData["action"], (string)routeData["controller"], routeData, null) -
  • - } - if(Model.Page > 1) { - routeData["page"] = Model.Page - 1; - - // don't render the page parameter as default is 1 - if (Model.Page - 1 == 1) { - routeData.Remove("page"); - } -
  • - @Html.ActionLink((string)previousText, (string)routeData["action"], (string)routeData["controller"], routeData, null) -
  • - } - @tag.EndElement -} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/UrlAlternatesFactory.cs b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/UrlAlternatesFactory.cs index 31223dd43..8af3a17c3 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/UrlAlternatesFactory.cs +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/UrlAlternatesFactory.cs @@ -14,6 +14,11 @@ namespace Orchard.DesignerTools.Services { public UrlAlternatesFactory(IHttpContextAccessor httpContextAccessor) { _httpContextAccessor = httpContextAccessor; + var httpContext = _httpContextAccessor.Current(); + + if(httpContext == null) { + return; + } var request = _httpContextAccessor.Current().Request; @@ -32,7 +37,10 @@ namespace Orchard.DesignerTools.Services { } public override void Displaying(ShapeDisplayingContext context) { - + if (_urlAlternates == null || !_urlAlternates.Any()) { + return; + } + context.ShapeMetadata.OnDisplaying(displayedContext => { // appends Url alternates to current ones displayedContext.ShapeMetadata.Alternates = displayedContext.ShapeMetadata.Alternates.SelectMany( diff --git a/src/Orchard.Web/Modules/Orchard.jQuery/Scripts/jquery.utils.js b/src/Orchard.Web/Modules/Orchard.jQuery/Scripts/jquery.utils.js index ecad701e2..5d607761e 100644 --- a/src/Orchard.Web/Modules/Orchard.jQuery/Scripts/jquery.utils.js +++ b/src/Orchard.Web/Modules/Orchard.jQuery/Scripts/jquery.utils.js @@ -1,823 +1,823 @@ -/* - jQuery utils - 0.8.5 - http://code.google.com/p/jquery-utils/ - - (c) Maxime Haineault - http://haineault.com - - MIT License (http://www.opensource.org/licenses/mit-license.php - -*/ - -(function($){ - $.extend($.expr[':'], { - // case insensitive version of :contains - icontains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").toLowerCase().indexOf(m[3].toLowerCase())>=0;} - }); - - $.iterators = { - getText: function() { return $(this).text(); }, - parseInt: function(v){ return parseInt(v, 10); } - }; - - $.extend({ - - // Returns a range object - // Author: Matthias Miller - // Site: http://blog.outofhanwell.com/2006/03/29/javascript-range-function/ - range: function() { - if (!arguments.length) { return []; } - var min, max, step; - if (arguments.length == 1) { - min = 0; - max = arguments[0]-1; - step = 1; - } - else { - // default step to 1 if it's zero or undefined - min = arguments[0]; - max = arguments[1]-1; - step = arguments[2] || 1; - } - // convert negative steps to positive and reverse min/max - if (step < 0 && min >= max) { - step *= -1; - var tmp = min; - min = max; - max = tmp; - min += ((max-min) % step); - } - var a = []; - for (var i = min; i <= max; i += step) { a.push(i); } - return a; - }, - - // Taken from ui.core.js. - // Why are you keeping this gem for yourself guys ? :| - keyCode: { - BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, CONTROL: 17, DELETE: 46, DOWN: 40, - END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, - NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108, - NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, - PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38 - }, - - // Takes a keyboard event and return true if the keycode match the specified keycode - keyIs: function(k, e) { - return parseInt($.keyCode[k.toUpperCase()], 10) == parseInt((typeof(e) == 'number' )? e: e.keyCode, 10); - }, - - // Returns the key of an array - keys: function(arr) { - var o = []; - for (k in arr) { o.push(k); } - return o; - }, - - // Redirect to a specified url - redirect: function(url) { - window.location.href = url; - return url; - }, - - // Stop event shorthand - stop: function(e, preventDefault, stopPropagation) { - if (preventDefault) { e.preventDefault(); } - if (stopPropagation) { e.stopPropagation(); } - return preventDefault && false || true; - }, - - // Returns the basename of a path - basename: function(path) { - var t = path.split('/'); - return t[t.length] === '' && s || t.slice(0, t.length).join('/'); - }, - - // Returns the filename of a path - filename: function(path) { - return path.split('/').pop(); - }, - - // Returns a formated file size - filesizeformat: function(bytes, suffixes){ - var b = parseInt(bytes, 10); - var s = suffixes || ['byte', 'bytes', 'KB', 'MB', 'GB']; - if (isNaN(b) || b === 0) { return '0 ' + s[0]; } - if (b == 1) { return '1 ' + s[0]; } - if (b < 1024) { return b.toFixed(2) + ' ' + s[1]; } - if (b < 1048576) { return (b / 1024).toFixed(2) + ' ' + s[2]; } - if (b < 1073741824) { return (b / 1048576).toFixed(2) + ' '+ s[3]; } - else { return (b / 1073741824).toFixed(2) + ' '+ s[4]; } - }, - - fileExtension: function(s) { - var tokens = s.split('.'); - return tokens[tokens.length-1] || false; - }, - - // Returns true if an object is a String - isString: function(o) { - return typeof(o) == 'string' && true || false; - }, - - // Returns true if an object is a RegExp - isRegExp: function(o) { - return o && o.constructor.toString().indexOf('RegExp()') != -1 || false; - }, - - isObject: function(o) { - return (typeof(o) == 'object'); - }, - - // Convert input to currency (two decimal fixed number) - toCurrency: function(i) { - i = parseFloat(i, 10).toFixed(2); - return (i=='NaN') ? '0.00' : i; - }, - - /*-------------------------------------------------------------------- - * javascript method: "pxToEm" - * by: - Scott Jehl (scott@filamentgroup.com) - Maggie Wachs (maggie@filamentgroup.com) - http://www.filamentgroup.com - * - * Copyright (c) 2008 Filament Group - * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses. - * - * Description: pxToEm converts a pixel value to ems depending on inherited font size. - * Article: http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/ - * Demo: http://www.filamentgroup.com/examples/pxToEm/ - * - * Options: - scope: string or jQuery selector for font-size scoping - reverse: Boolean, true reverses the conversion to em-px - * Dependencies: jQuery library - * Usage Example: myPixelValue.pxToEm(); or myPixelValue.pxToEm({'scope':'#navigation', reverse: true}); - * - * Version: 2.1, 18.12.2008 - * Changelog: - * 08.02.2007 initial Version 1.0 - * 08.01.2008 - fixed font-size calculation for IE - * 18.12.2008 - removed native object prototyping to stay in jQuery's spirit, jsLinted (Maxime Haineault ) - --------------------------------------------------------------------*/ - - pxToEm: function(i, settings){ - //set defaults - settings = jQuery.extend({ - scope: 'body', - reverse: false - }, settings); - - var pxVal = (i === '') ? 0 : parseFloat(i); - var scopeVal; - var getWindowWidth = function(){ - var de = document.documentElement; - return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth; - }; - - /* When a percentage-based font-size is set on the body, IE returns that percent of the window width as the font-size. - For example, if the body font-size is 62.5% and the window width is 1000px, IE will return 625px as the font-size. - When this happens, we calculate the correct body font-size (%) and multiply it by 16 (the standard browser font size) - to get an accurate em value. */ - - if (settings.scope == 'body' && $.browser.msie && (parseFloat($('body').css('font-size')) / getWindowWidth()).toFixed(1) > 0.0) { - var calcFontSize = function(){ - return (parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(3) * 16; - }; - scopeVal = calcFontSize(); - } - else { scopeVal = parseFloat(jQuery(settings.scope).css("font-size")); } - - var result = (settings.reverse === true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em'; - return result; - } - }); - - $.extend($.fn, { - type: function() { - try { return $(this).get(0).nodeName.toLowerCase(); } - catch(e) { return false; } - }, - // Select a text range in a textarea - selectRange: function(start, end){ - // use only the first one since only one input can be focused - if ($(this).get(0).createTextRange) { - var range = $(this).get(0).createTextRange(); - range.collapse(true); - range.moveEnd('character', end); - range.moveStart('character', start); - range.select(); - } - else if ($(this).get(0).setSelectionRange) { - $(this).bind('focus', function(e){ - e.preventDefault(); - }).get(0).setSelectionRange(start, end); - } - return $(this); - }, - - /*-------------------------------------------------------------------- - * JQuery Plugin: "EqualHeights" - * by: Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com) - * - * Copyright (c) 2008 Filament Group - * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) - * - * Description: Compares the heights or widths of the top-level children of a provided element - and sets their min-height to the tallest height (or width to widest width). Sets in em units - by default if pxToEm() method is available. - * Dependencies: jQuery library, pxToEm method (article: - http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/) - * Usage Example: $(element).equalHeights(); - Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true); - * Version: 2.1, 18.12.2008 - * - * Note: Changed pxToEm call to call $.pxToEm instead, jsLinted (Maxime Haineault ) - --------------------------------------------------------------------*/ - - equalHeights: function(px){ - $(this).each(function(){ - var currentTallest = 0; - $(this).children().each(function(i){ - if ($(this).height() > currentTallest) { currentTallest = $(this).height(); } - }); - if (!px || !$.pxToEm) { currentTallest = $.pxToEm(currentTallest); } //use ems unless px is specified - // for ie6, set height since min-height isn't supported - if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); } - $(this).children().css({'min-height': currentTallest}); - }); - return this; - }, - - // Copyright (c) 2009 James Padolsey - // http://james.padolsey.com/javascript/jquery-delay-plugin/ - delay: function(time, callback){ - jQuery.fx.step.delay = function(){}; - return this.animate({delay:1}, time, callback); - } - }); -})(jQuery); -/* - jQuery strings - 0.3 - http://code.google.com/p/jquery-utils/ - - (c) Maxime Haineault - http://haineault.com - - MIT License (http://www.opensource.org/licenses/mit-license.php) - - Implementation of Python3K advanced string formatting - http://www.python.org/dev/peps/pep-3101/ - - Documentation: http://code.google.com/p/jquery-utils/wiki/StringFormat - -*/ -(function($){ - var strings = { - strConversion: { - // tries to translate any objects type into string gracefully - __repr: function(i){ - switch(this.__getType(i)) { - case 'array':case 'date':case 'number': - return i.toString(); - case 'object': - var o = []; - for (x=0; xon! Inserted a space. - // @ http://jsfromhell.com/string/pad [v1.0] - __pad: function(str, l, s, t){ - var p = s || ' '; - var o = str; - if (l - str.length > 0) { - o = new Array(Math.ceil(l / p.length)).join(p).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2)) + str + p.substr(0, l - t); - } - return o; - }, - __getInput: function(arg, args) { - var key = arg.getKey(); - switch(this.__getType(args)){ - case 'object': // Thanks to Jonathan Works for the patch - var keys = key.split('.'); - var obj = args; - for(var subkey = 0; subkey < keys.length; subkey++){ - obj = obj[keys[subkey]]; - } - if (typeof(obj) != 'undefined') { - if (strings.strConversion.__getType(obj) == 'array') { - return arg.getFormat().match(/\.\*/) && obj[1] || obj; - } - return obj; - } - else { - // TODO: try by numerical index - } - break; - case 'array': - key = parseInt(key, 10); - if (arg.getFormat().match(/\.\*/) && typeof args[key+1] != 'undefined') { return args[key+1]; } - else if (typeof args[key] != 'undefined') { return args[key]; } - else { return key; } - break; - } - return '{'+key+'}'; - }, - __formatToken: function(token, args) { - var arg = new Argument(token, args); - return strings.strConversion[arg.getFormat().slice(-1)](this.__getInput(arg, args), arg); - }, - - // Signed integer decimal. - d: function(input, arg){ - var o = parseInt(input, 10); // enforce base 10 - var p = arg.getPaddingLength(); - if (p) { return this.__pad(o.toString(), p, arg.getPaddingString(), 0); } - else { return o; } - }, - // Signed integer decimal. - i: function(input, args){ - return this.d(input, args); - }, - // Unsigned octal - o: function(input, arg){ - var o = input.toString(8); - if (arg.isAlternate()) { o = this.__pad(o, o.length+1, '0', 0); } - return this.__pad(o, arg.getPaddingLength(), arg.getPaddingString(), 0); - }, - // Unsigned decimal - u: function(input, args) { - return Math.abs(this.d(input, args)); - }, - // Unsigned hexadecimal (lowercase) - x: function(input, arg){ - var o = parseInt(input, 10).toString(16); - o = this.__pad(o, arg.getPaddingLength(), arg.getPaddingString(),0); - return arg.isAlternate() ? '0x'+o : o; - }, - // Unsigned hexadecimal (uppercase) - X: function(input, arg){ - return this.x(input, arg).toUpperCase(); - }, - // Floating point exponential format (lowercase) - e: function(input, arg){ - return parseFloat(input, 10).toExponential(arg.getPrecision()); - }, - // Floating point exponential format (uppercase) - E: function(input, arg){ - return this.e(input, arg).toUpperCase(); - }, - // Floating point decimal format - f: function(input, arg){ - return this.__pad(parseFloat(input, 10).toFixed(arg.getPrecision()), arg.getPaddingLength(), arg.getPaddingString(),0); - }, - // Floating point decimal format (alias) - F: function(input, args){ - return this.f(input, args); - }, - // Floating point format. Uses exponential format if exponent is greater than -4 or less than precision, decimal format otherwise - g: function(input, arg){ - var o = parseFloat(input, 10); - return (o.toString().length > 6) ? Math.round(o.toExponential(arg.getPrecision())): o; - }, - // Floating point format. Uses exponential format if exponent is greater than -4 or less than precision, decimal format otherwise - G: function(input, args){ - return this.g(input, args); - }, - // Single character (accepts integer or single character string). - c: function(input, args) { - var match = input.match(/\w|\d/); - return match && match[0] || ''; - }, - // String (converts any JavaScript object to anotated format) - r: function(input, args) { - return this.__repr(input); - }, - // String (converts any JavaScript object using object.toString()) - s: function(input, args) { - return input.toString && input.toString() || ''+input; - } - }, - - format: function(str, args) { - var end = 0; - var start = 0; - var match = false; - var buffer = []; - var token = ''; - var tmp = (str||'').split(''); - for(start=0; start < tmp.length; start++) { - if (tmp[start] == '{' && tmp[start+1] !='{') { - end = str.indexOf('}', start); - token = tmp.slice(start+1, end).join(''); - if (tmp[start-1] != '{' && tmp[end+1] != '}') { - var tokenArgs = (typeof arguments[1] != 'object')? arguments2Array(arguments, 2): args || []; - buffer.push(strings.strConversion.__formatToken(token, tokenArgs)); - } - else { - buffer.push(token); - } - } - else if (start > end || buffer.length < 1) { buffer.push(tmp[start]); } - } - return (buffer.length > 1)? buffer.join(''): buffer[0]; - }, - - calc: function(str, args) { - return eval(format(str, args)); - }, - - repeat: function(s, n) { - return new Array(n+1).join(s); - }, - - UTF8encode: function(s) { - return unescape(encodeURIComponent(s)); - }, - - UTF8decode: function(s) { - return decodeURIComponent(escape(s)); - }, - - tpl: function() { - var out = ''; - var render = true; - // Set - // $.tpl('ui.test', ['', helloWorld ,'']); - if (arguments.length == 2 && $.isArray(arguments[1])) { - this[arguments[0]] = arguments[1].join(''); - return $(this[arguments[0]]); - } - // $.tpl('ui.test', 'hello world'); - if (arguments.length == 2 && $.isString(arguments[1])) { - this[arguments[0]] = arguments[1]; - return $(this[arguments[0]]); - } - // Call - // $.tpl('ui.test'); - if (arguments.length == 1) { - return $(this[arguments[0]]); - } - // $.tpl('ui.test', false); - if (arguments.length == 2 && arguments[1] == false) { - return this[arguments[0]]; - } - // $.tpl('ui.test', {value:blah}); - if (arguments.length == 2 && $.isObject(arguments[1])) { - return $($.format(this[arguments[0]], arguments[1])); - } - // $.tpl('ui.test', {value:blah}, false); - if (arguments.length == 3 && $.isObject(arguments[1])) { - return (arguments[2] == true) - ? $.format(this[arguments[0]], arguments[1]) - : $($.format(this[arguments[0]], arguments[1])); - } - } - }; - - var Argument = function(arg, args) { - this.__arg = arg; - this.__args = args; - this.__max_precision = parseFloat('1.'+ (new Array(32)).join('1'), 10).toString().length-3; - this.__def_precision = 6; - this.getString = function(){ - return this.__arg; - }; - this.getKey = function(){ - return this.__arg.split(':')[0]; - }; - this.getFormat = function(){ - var match = this.getString().split(':'); - return (match && match[1])? match[1]: 's'; - }; - this.getPrecision = function(){ - var match = this.getFormat().match(/\.(\d+|\*)/g); - if (!match) { return this.__def_precision; } - else { - match = match[0].slice(1); - if (match != '*') { return parseInt(match, 10); } - else if(strings.strConversion.__getType(this.__args) == 'array') { - return this.__args[1] && this.__args[0] || this.__def_precision; - } - else if(strings.strConversion.__getType(this.__args) == 'object') { - return this.__args[this.getKey()] && this.__args[this.getKey()][0] || this.__def_precision; - } - else { return this.__def_precision; } - } - }; - this.getPaddingLength = function(){ - var match = false; - if (this.isAlternate()) { - match = this.getString().match(/0?#0?(\d+)/); - if (match && match[1]) { return parseInt(match[1], 10); } - } - match = this.getString().match(/(0|\.)(\d+|\*)/g); - return match && parseInt(match[0].slice(1), 10) || 0; - }; - this.getPaddingString = function(){ - var o = ''; - if (this.isAlternate()) { o = ' '; } - // 0 take precedence on alternate format - if (this.getFormat().match(/#0|0#|^0|\.\d+/)) { o = '0'; } - return o; - }; - this.getFlags = function(){ - var match = this.getString().matc(/^(0|\#|\-|\+|\s)+/); - return match && match[0].split('') || []; - }; - this.isAlternate = function() { - return !!this.getFormat().match(/^0?#/); - }; - }; - - var arguments2Array = function(args, shift) { - var o = []; - for (l=args.length, x=(shift || 0)-1; x - http://haineault.com - - MIT License (http://www.opensource.org/licenses/mit-license.php) - -*/ - -(function($){ - var hash = window.location.hash; - var handlers = []; - var opt = {}; - - $.extend({ - anchorHandler: { - apply: function() { - $.map(handlers, function(handler){ - var match = hash.match(handler.r) && hash.match(handler.r)[0] || false; - if (match) { handler.cb.apply($('a[href*='+match+']').get(0), [handler.r, hash || '']); } - }); - return $.anchorHandler; - }, - add: function(regexp, callback, options) { - var opt = $.extend({handleClick: true, preserveHash: true}, options); - if (opt.handleClick) { - $('a[href*=#]').each(function(i, a){ - if (a.href.match(regexp)) { - $(a).bind('click.anchorHandler', function(){ - if (opt.preserveHash) { window.location.hash = a.hash; } - return callback.apply(this, [regexp, a.href]); - }); - } - }); - } - handlers.push({r: regexp, cb: callback}); - $($.anchorHandler.apply); - return $.anchorHandler; - } - } - }); -})(jQuery); -/** - * Cookie plugin - * - * Copyright (c) 2006 Klaus Hartl (stilbuero.de) - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - */ - -/** - * Create a cookie with the given name and value and other optional parameters. - * - * @example $.cookie('the_cookie', 'the_value'); - * @desc Set the value of a cookie. - * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); - * @desc Create a cookie with all available options. - * @example $.cookie('the_cookie', 'the_value'); - * @desc Create a session cookie. - * @example $.cookie('the_cookie', null); - * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain - * used when the cookie was set. - * - * @param String name The name of the cookie. - * @param String value The value of the cookie. - * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. - * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. - * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. - * If set to null or omitted, the cookie will be a session cookie and will not be retained - * when the the browser exits. - * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). - * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). - * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will - * require a secure protocol (like HTTPS). - * @type undefined - * - * @name $.cookie - * @cat Plugins/Cookie - * @author Klaus Hartl/klaus.hartl@stilbuero.de - */ - -/** - * Get the value of a cookie with the given name. - * - * @example $.cookie('the_cookie'); - * @desc Get the value of a cookie. - * - * @param String name The name of the cookie. - * @return The value of the cookie. - * @type String - * - * @name $.cookie - * @cat Plugins/Cookie - * @author Klaus Hartl/klaus.hartl@stilbuero.de - */ -jQuery.cookie = function(name, value, options) { - if (typeof value != 'undefined') { // name and value given, set cookie - options = options || {}; - if (value === null) { - value = ''; - options.expires = -1; - } - var expires = ''; - if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { - var date; - if (typeof options.expires == 'number') { - date = new Date(); - date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); - } else { - date = options.expires; - } - expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE - } - // CAUTION: Needed to parenthesize options.path and options.domain - // in the following expressions, otherwise they evaluate to undefined - // in the packed version for some reason... - var path = options.path ? '; path=' + (options.path) : ''; - var domain = options.domain ? '; domain=' + (options.domain) : ''; - var secure = options.secure ? '; secure' : ''; - document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); - } else { // only name given, get cookie - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; - } -}; -/* - jQuery countdown - 0.2 - http://code.google.com/p/jquery-utils/ - - (c) Maxime Haineault - http://haineault.com - - MIT License (http://www.opensource.org/licenses/mit-license.php) - -*/ - -(function($) { - function countdown(el, options) { - var calc = function (target, current) { - /* Return true if the target date has arrived, - * an object of the time left otherwise. - */ - var current = current || new Date(); - if (current >= target) { return true; } - - var o = {}; - var remain = Math.floor((target.getTime() - current.getTime()) / 1000); - - o.days = Math.floor(remain / 86400); - remain %= 86400; - o.hours = Math.floor(remain / 3600); - remain %= 3600; - o.minutes = Math.floor(remain / 60); - remain %= 60; - o.seconds = remain; - o.years = Math.floor(o.days / 365); - o.months = Math.floor(o.days / 30); - o.weeks = Math.floor(o.days / 7); - - return o; - }; - - var getWeek = function(date) { - var onejan = new Date(date.getFullYear(),0,1); - return Math.ceil((((date - onejan) / 86400000) + onejan.getDay())/7); - }; - - var options = $.extend({ - date: new Date(), - modifiers: [], - interval: 1000, - msgFormat: '%d [day|days] %hh %mm %ss', - msgNow: 'Now !' - }, options); - - var tokens = { - y: new RegExp ('\\%y(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // years - M: new RegExp ('\\%M(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // months - w: new RegExp ('\\%w(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // weeks - d: new RegExp ('\\%d(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // days - h: new RegExp ('\\%h(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // hours - m: new RegExp ('\\%m(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // minutes - s: new RegExp ('\\%s(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g') // seconds - }; - - var formatToken = function(str, token, val) { - return (!tokens[token])? '': str.match(/\[|\]/g) - && (str.replace(tokens[token], val+'$1'+ ((parseInt(val, 10)<2)?'$2':'$3')) || '') - || str.replace('%'+token, val); - }; - - var format = function(str, obj) { - var o = str; - o = formatToken(o, 'y', obj.years); - o = formatToken(o, 'M', obj.months); - o = formatToken(o, 'w', obj.weeks); - o = formatToken(o, 'd', obj.days); - o = formatToken(o, 'h', obj.hours); - o = formatToken(o, 'm', obj.minutes); - o = formatToken(o, 's', obj.seconds); - return o; - }; - - var update = function() { - var date_obj = calc(cd.date); - if (date_obj === true) { - cd.stop(); clearInterval(cd.id); - $(cd.el).html(options.msgNow); - return true; - } - else { - $(cd.el).text(format(options.msgFormat, date_obj)); - } - }; - - var apply_modifiers = function (modifiers, date) { - if (modifiers.length === 0) { - return date; - } - - var modifier_re = /^([+-]\d+)([yMdhms])$/; - var conversions = { - s: 1000, - m: 60 * 1000, - h: 60 * 60 * 1000, - d: 24 * 60 * 60 * 1000, - M: 30 * 24 * 60 * 60 * 1000, - y: 365 * 24 * 60 * 60 * 1000 - }; - - var displacement = 0; - for (var i = 0, n = modifiers.length; i < n; ++i) { - var match = modifiers[i].match(modifier_re); - if (match !== null) { - displacement += parseInt(match[1], 10) * conversions[match[2]]; - } - } - return new Date(date.getTime() + displacement); - }; - - var cd = { - id : setInterval(update, options.interval), - el : el, - start : function(){ return new countdown($(this.el), options); }, - stop : function(){ return clearInterval(this.id); }, - date : apply_modifiers(options.modifiers, options.date) - }; - $(el).data('countdown', cd); - update(); - return $(el).data('countdown'); - } - $.fn.countdown = function(args) { if(this.get(0)) return new countdown(this.get(0), args); }; -})(jQuery); +/* + jQuery utils - 0.8.5 + http://code.google.com/p/jquery-utils/ + + (c) Maxime Haineault + http://haineault.com + + MIT License (http://www.opensource.org/licenses/mit-license.php + +*/ + +(function($){ + $.extend($.expr[':'], { + // case insensitive version of :contains + icontains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").toLowerCase().indexOf(m[3].toLowerCase())>=0;} + }); + + $.iterators = { + getText: function() { return $(this).text(); }, + parseInt: function(v){ return parseInt(v, 10); } + }; + + $.extend({ + + // Returns a range object + // Author: Matthias Miller + // Site: http://blog.outofhanwell.com/2006/03/29/javascript-range-function/ + range: function() { + if (!arguments.length) { return []; } + var min, max, step; + if (arguments.length == 1) { + min = 0; + max = arguments[0]-1; + step = 1; + } + else { + // default step to 1 if it's zero or undefined + min = arguments[0]; + max = arguments[1]-1; + step = arguments[2] || 1; + } + // convert negative steps to positive and reverse min/max + if (step < 0 && min >= max) { + step *= -1; + var tmp = min; + min = max; + max = tmp; + min += ((max-min) % step); + } + var a = []; + for (var i = min; i <= max; i += step) { a.push(i); } + return a; + }, + + // Taken from ui.core.js. + // Why are you keeping this gem for yourself guys ? :| + keyCode: { + BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, CONTROL: 17, DELETE: 46, DOWN: 40, + END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, + NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108, + NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, + PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38 + }, + + // Takes a keyboard event and return true if the keycode match the specified keycode + keyIs: function(k, e) { + return parseInt($.keyCode[k.toUpperCase()], 10) == parseInt((typeof(e) == 'number' )? e: e.keyCode, 10); + }, + + // Returns the key of an array + keys: function(arr) { + var o = []; + for (k in arr) { o.push(k); } + return o; + }, + + // Redirect to a specified url + redirect: function(url) { + window.location.href = url; + return url; + }, + + // Stop event shorthand + stop: function(e, preventDefault, stopPropagation) { + if (preventDefault) { e.preventDefault(); } + if (stopPropagation) { e.stopPropagation(); } + return preventDefault && false || true; + }, + + // Returns the basename of a path + basename: function(path) { + var t = path.split('/'); + return t[t.length] === '' && s || t.slice(0, t.length).join('/'); + }, + + // Returns the filename of a path + filename: function(path) { + return path.split('/').pop(); + }, + + // Returns a formated file size + filesizeformat: function(bytes, suffixes){ + var b = parseInt(bytes, 10); + var s = suffixes || ['byte', 'bytes', 'KB', 'MB', 'GB']; + if (isNaN(b) || b === 0) { return '0 ' + s[0]; } + if (b == 1) { return '1 ' + s[0]; } + if (b < 1024) { return b.toFixed(2) + ' ' + s[1]; } + if (b < 1048576) { return (b / 1024).toFixed(2) + ' ' + s[2]; } + if (b < 1073741824) { return (b / 1048576).toFixed(2) + ' '+ s[3]; } + else { return (b / 1073741824).toFixed(2) + ' '+ s[4]; } + }, + + fileExtension: function(s) { + var tokens = s.split('.'); + return tokens[tokens.length-1] || false; + }, + + // Returns true if an object is a String + isString: function(o) { + return typeof(o) == 'string' && true || false; + }, + + // Returns true if an object is a RegExp + isRegExp: function(o) { + return o && o.constructor.toString().indexOf('RegExp()') != -1 || false; + }, + + isObject: function(o) { + return (typeof(o) == 'object'); + }, + + // Convert input to currency (two decimal fixed number) + toCurrency: function(i) { + i = parseFloat(i, 10).toFixed(2); + return (i=='NaN') ? '0.00' : i; + }, + + /*-------------------------------------------------------------------- + * javascript method: "pxToEm" + * by: + Scott Jehl (scott@filamentgroup.com) + Maggie Wachs (maggie@filamentgroup.com) + http://www.filamentgroup.com + * + * Copyright (c) 2008 Filament Group + * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses. + * + * Description: pxToEm converts a pixel value to ems depending on inherited font size. + * Article: http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/ + * Demo: http://www.filamentgroup.com/examples/pxToEm/ + * + * Options: + scope: string or jQuery selector for font-size scoping + reverse: Boolean, true reverses the conversion to em-px + * Dependencies: jQuery library + * Usage Example: myPixelValue.pxToEm(); or myPixelValue.pxToEm({'scope':'#navigation', reverse: true}); + * + * Version: 2.1, 18.12.2008 + * Changelog: + * 08.02.2007 initial Version 1.0 + * 08.01.2008 - fixed font-size calculation for IE + * 18.12.2008 - removed native object prototyping to stay in jQuery's spirit, jsLinted (Maxime Haineault ) + --------------------------------------------------------------------*/ + + pxToEm: function(i, settings){ + //set defaults + settings = jQuery.extend({ + scope: 'body', + reverse: false + }, settings); + + var pxVal = (i === '') ? 0 : parseFloat(i); + var scopeVal; + var getWindowWidth = function(){ + var de = document.documentElement; + return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth; + }; + + /* When a percentage-based font-size is set on the body, IE returns that percent of the window width as the font-size. + For example, if the body font-size is 62.5% and the window width is 1000px, IE will return 625px as the font-size. + When this happens, we calculate the correct body font-size (%) and multiply it by 16 (the standard browser font size) + to get an accurate em value. */ + + if (settings.scope == 'body' && $.browser.msie && (parseFloat($('body').css('font-size')) / getWindowWidth()).toFixed(1) > 0.0) { + var calcFontSize = function(){ + return (parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(3) * 16; + }; + scopeVal = calcFontSize(); + } + else { scopeVal = parseFloat(jQuery(settings.scope).css("font-size")); } + + var result = (settings.reverse === true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em'; + return result; + } + }); + + $.extend($.fn, { + type: function() { + try { return $(this).get(0).nodeName.toLowerCase(); } + catch(e) { return false; } + }, + // Select a text range in a textarea + selectRange: function(start, end){ + // use only the first one since only one input can be focused + if ($(this).get(0).createTextRange) { + var range = $(this).get(0).createTextRange(); + range.collapse(true); + range.moveEnd('character', end); + range.moveStart('character', start); + range.select(); + } + else if ($(this).get(0).setSelectionRange) { + $(this).bind('focus', function(e){ + e.preventDefault(); + }).get(0).setSelectionRange(start, end); + } + return $(this); + }, + + /*-------------------------------------------------------------------- + * JQuery Plugin: "EqualHeights" + * by: Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com) + * + * Copyright (c) 2008 Filament Group + * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) + * + * Description: Compares the heights or widths of the top-level children of a provided element + and sets their min-height to the tallest height (or width to widest width). Sets in em units + by default if pxToEm() method is available. + * Dependencies: jQuery library, pxToEm method (article: + http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/) + * Usage Example: $(element).equalHeights(); + Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true); + * Version: 2.1, 18.12.2008 + * + * Note: Changed pxToEm call to call $.pxToEm instead, jsLinted (Maxime Haineault ) + --------------------------------------------------------------------*/ + + equalHeights: function(px){ + $(this).each(function(){ + var currentTallest = 0; + $(this).children().each(function(i){ + if ($(this).height() > currentTallest) { currentTallest = $(this).height(); } + }); + if (!px || !$.pxToEm) { currentTallest = $.pxToEm(currentTallest); } //use ems unless px is specified + // for ie6, set height since min-height isn't supported + if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); } + $(this).children().css({'min-height': currentTallest}); + }); + return this; + }, + + // Copyright (c) 2009 James Padolsey + // http://james.padolsey.com/javascript/jquery-delay-plugin/ + delay: function(time, callback){ + jQuery.fx.step.delay = function(){}; + return this.animate({delay:1}, time, callback); + } + }); +})(jQuery); +/* + jQuery strings - 0.3 + http://code.google.com/p/jquery-utils/ + + (c) Maxime Haineault + http://haineault.com + + MIT License (http://www.opensource.org/licenses/mit-license.php) + + Implementation of Python3K advanced string formatting + http://www.python.org/dev/peps/pep-3101/ + + Documentation: http://code.google.com/p/jquery-utils/wiki/StringFormat + +*/ +(function($){ + var strings = { + strConversion: { + // tries to translate any objects type into string gracefully + __repr: function(i){ + switch(this.__getType(i)) { + case 'array':case 'date':case 'number': + return i.toString(); + case 'object': + var o = []; + for (x=0; xon! Inserted a space. + // @ http://jsfromhell.com/string/pad [v1.0] + __pad: function(str, l, s, t){ + var p = s || ' '; + var o = str; + if (l - str.length > 0) { + o = new Array(Math.ceil(l / p.length)).join(p).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2)) + str + p.substr(0, l - t); + } + return o; + }, + __getInput: function(arg, args) { + var key = arg.getKey(); + switch(this.__getType(args)){ + case 'object': // Thanks to Jonathan Works for the patch + var keys = key.split('.'); + var obj = args; + for(var subkey = 0; subkey < keys.length; subkey++){ + obj = obj[keys[subkey]]; + } + if (typeof(obj) != 'undefined') { + if (strings.strConversion.__getType(obj) == 'array') { + return arg.getFormat().match(/\.\*/) && obj[1] || obj; + } + return obj; + } + else { + // TODO: try by numerical index + } + break; + case 'array': + key = parseInt(key, 10); + if (arg.getFormat().match(/\.\*/) && typeof args[key+1] != 'undefined') { return args[key+1]; } + else if (typeof args[key] != 'undefined') { return args[key]; } + else { return key; } + break; + } + return '{'+key+'}'; + }, + __formatToken: function(token, args) { + var arg = new Argument(token, args); + return strings.strConversion[arg.getFormat().slice(-1)](this.__getInput(arg, args), arg); + }, + + // Signed integer decimal. + d: function(input, arg){ + var o = parseInt(input, 10); // enforce base 10 + var p = arg.getPaddingLength(); + if (p) { return this.__pad(o.toString(), p, arg.getPaddingString(), 0); } + else { return o; } + }, + // Signed integer decimal. + i: function(input, args){ + return this.d(input, args); + }, + // Unsigned octal + o: function(input, arg){ + var o = input.toString(8); + if (arg.isAlternate()) { o = this.__pad(o, o.length+1, '0', 0); } + return this.__pad(o, arg.getPaddingLength(), arg.getPaddingString(), 0); + }, + // Unsigned decimal + u: function(input, args) { + return Math.abs(this.d(input, args)); + }, + // Unsigned hexadecimal (lowercase) + x: function(input, arg){ + var o = parseInt(input, 10).toString(16); + o = this.__pad(o, arg.getPaddingLength(), arg.getPaddingString(),0); + return arg.isAlternate() ? '0x'+o : o; + }, + // Unsigned hexadecimal (uppercase) + X: function(input, arg){ + return this.x(input, arg).toUpperCase(); + }, + // Floating point exponential format (lowercase) + e: function(input, arg){ + return parseFloat(input, 10).toExponential(arg.getPrecision()); + }, + // Floating point exponential format (uppercase) + E: function(input, arg){ + return this.e(input, arg).toUpperCase(); + }, + // Floating point decimal format + f: function(input, arg){ + return this.__pad(parseFloat(input, 10).toFixed(arg.getPrecision()), arg.getPaddingLength(), arg.getPaddingString(),0); + }, + // Floating point decimal format (alias) + F: function(input, args){ + return this.f(input, args); + }, + // Floating point format. Uses exponential format if exponent is greater than -4 or less than precision, decimal format otherwise + g: function(input, arg){ + var o = parseFloat(input, 10); + return (o.toString().length > 6) ? Math.round(o.toExponential(arg.getPrecision())): o; + }, + // Floating point format. Uses exponential format if exponent is greater than -4 or less than precision, decimal format otherwise + G: function(input, args){ + return this.g(input, args); + }, + // Single character (accepts integer or single character string). + c: function(input, args) { + var match = input.match(/\w|\d/); + return match && match[0] || ''; + }, + // String (converts any JavaScript object to anotated format) + r: function(input, args) { + return this.__repr(input); + }, + // String (converts any JavaScript object using object.toString()) + s: function(input, args) { + return input.toString && input.toString() || ''+input; + } + }, + + format: function(str, args) { + var end = 0; + var start = 0; + var match = false; + var buffer = []; + var token = ''; + var tmp = (str||'').split(''); + for(start=0; start < tmp.length; start++) { + if (tmp[start] == '{' && tmp[start+1] !='{') { + end = str.indexOf('}', start); + token = tmp.slice(start+1, end).join(''); + if (tmp[start-1] != '{' && tmp[end+1] != '}') { + var tokenArgs = (typeof arguments[1] != 'object')? arguments2Array(arguments, 2): args || []; + buffer.push(strings.strConversion.__formatToken(token, tokenArgs)); + } + else { + buffer.push(token); + } + } + else if (start > end || buffer.length < 1) { buffer.push(tmp[start]); } + } + return (buffer.length > 1)? buffer.join(''): buffer[0]; + }, + + calc: function(str, args) { + return eval(format(str, args)); + }, + + repeat: function(s, n) { + return new Array(n+1).join(s); + }, + + UTF8encode: function(s) { + return unescape(encodeURIComponent(s)); + }, + + UTF8decode: function(s) { + return decodeURIComponent(escape(s)); + }, + + tpl: function() { + var out = ''; + var render = true; + // Set + // $.tpl('ui.test', ['', helloWorld ,'']); + if (arguments.length == 2 && $.isArray(arguments[1])) { + this[arguments[0]] = arguments[1].join(''); + return $(this[arguments[0]]); + } + // $.tpl('ui.test', 'hello world'); + if (arguments.length == 2 && $.isString(arguments[1])) { + this[arguments[0]] = arguments[1]; + return $(this[arguments[0]]); + } + // Call + // $.tpl('ui.test'); + if (arguments.length == 1) { + return $(this[arguments[0]]); + } + // $.tpl('ui.test', false); + if (arguments.length == 2 && arguments[1] == false) { + return this[arguments[0]]; + } + // $.tpl('ui.test', {value:blah}); + if (arguments.length == 2 && $.isObject(arguments[1])) { + return $($.format(this[arguments[0]], arguments[1])); + } + // $.tpl('ui.test', {value:blah}, false); + if (arguments.length == 3 && $.isObject(arguments[1])) { + return (arguments[2] == true) + ? $.format(this[arguments[0]], arguments[1]) + : $($.format(this[arguments[0]], arguments[1])); + } + } + }; + + var Argument = function(arg, args) { + this.__arg = arg; + this.__args = args; + this.__max_precision = parseFloat('1.'+ (new Array(32)).join('1'), 10).toString().length-3; + this.__def_precision = 6; + this.getString = function(){ + return this.__arg; + }; + this.getKey = function(){ + return this.__arg.split(':')[0]; + }; + this.getFormat = function(){ + var match = this.getString().split(':'); + return (match && match[1])? match[1]: 's'; + }; + this.getPrecision = function(){ + var match = this.getFormat().match(/\.(\d+|\*)/g); + if (!match) { return this.__def_precision; } + else { + match = match[0].slice(1); + if (match != '*') { return parseInt(match, 10); } + else if(strings.strConversion.__getType(this.__args) == 'array') { + return this.__args[1] && this.__args[0] || this.__def_precision; + } + else if(strings.strConversion.__getType(this.__args) == 'object') { + return this.__args[this.getKey()] && this.__args[this.getKey()][0] || this.__def_precision; + } + else { return this.__def_precision; } + } + }; + this.getPaddingLength = function(){ + var match = false; + if (this.isAlternate()) { + match = this.getString().match(/0?#0?(\d+)/); + if (match && match[1]) { return parseInt(match[1], 10); } + } + match = this.getString().match(/(0|\.)(\d+|\*)/g); + return match && parseInt(match[0].slice(1), 10) || 0; + }; + this.getPaddingString = function(){ + var o = ''; + if (this.isAlternate()) { o = ' '; } + // 0 take precedence on alternate format + if (this.getFormat().match(/#0|0#|^0|\.\d+/)) { o = '0'; } + return o; + }; + this.getFlags = function(){ + var match = this.getString().matc(/^(0|\#|\-|\+|\s)+/); + return match && match[0].split('') || []; + }; + this.isAlternate = function() { + return !!this.getFormat().match(/^0?#/); + }; + }; + + var arguments2Array = function(args, shift) { + var o = []; + for (l=args.length, x=(shift || 0)-1; x + http://haineault.com + + MIT License (http://www.opensource.org/licenses/mit-license.php) + +*/ + +(function($){ + var hash = window.location.hash; + var handlers = []; + var opt = {}; + + $.extend({ + anchorHandler: { + apply: function() { + $.map(handlers, function(handler){ + var match = hash.match(handler.r) && hash.match(handler.r)[0] || false; + if (match) { handler.cb.apply($('a[href*='+match+']').get(0), [handler.r, hash || '']); } + }); + return $.anchorHandler; + }, + add: function(regexp, callback, options) { + var opt = $.extend({handleClick: true, preserveHash: true}, options); + if (opt.handleClick) { + $('a[href*=#]').each(function(i, a){ + if (a.href.match(regexp)) { + $(a).bind('click.anchorHandler', function(){ + if (opt.preserveHash) { window.location.hash = a.hash; } + return callback.apply(this, [regexp, a.href]); + }); + } + }); + } + handlers.push({r: regexp, cb: callback}); + $($.anchorHandler.apply); + return $.anchorHandler; + } + } + }); +})(jQuery); +/** + * Cookie plugin + * + * Copyright (c) 2006 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ + +/** + * Create a cookie with the given name and value and other optional parameters. + * + * @example $.cookie('the_cookie', 'the_value'); + * @desc Set the value of a cookie. + * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); + * @desc Create a cookie with all available options. + * @example $.cookie('the_cookie', 'the_value'); + * @desc Create a session cookie. + * @example $.cookie('the_cookie', null); + * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain + * used when the cookie was set. + * + * @param String name The name of the cookie. + * @param String value The value of the cookie. + * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. + * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. + * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. + * If set to null or omitted, the cookie will be a session cookie and will not be retained + * when the the browser exits. + * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). + * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). + * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will + * require a secure protocol (like HTTPS). + * @type undefined + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ + +/** + * Get the value of a cookie with the given name. + * + * @example $.cookie('the_cookie'); + * @desc Get the value of a cookie. + * + * @param String name The name of the cookie. + * @return The value of the cookie. + * @type String + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ +jQuery.cookie = function(name, value, options) { + if (typeof value != 'undefined') { // name and value given, set cookie + options = options || {}; + if (value === null) { + value = ''; + options.expires = -1; + } + var expires = ''; + if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { + var date; + if (typeof options.expires == 'number') { + date = new Date(); + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); + } else { + date = options.expires; + } + expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE + } + // CAUTION: Needed to parenthesize options.path and options.domain + // in the following expressions, otherwise they evaluate to undefined + // in the packed version for some reason... + var path = options.path ? '; path=' + (options.path) : ''; + var domain = options.domain ? '; domain=' + (options.domain) : ''; + var secure = options.secure ? '; secure' : ''; + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); + } else { // only name given, get cookie + var cookieValue = null; + if (document.cookie && document.cookie != '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) == (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; + } +}; +/* + jQuery countdown - 0.2 + http://code.google.com/p/jquery-utils/ + + (c) Maxime Haineault + http://haineault.com + + MIT License (http://www.opensource.org/licenses/mit-license.php) + +*/ + +(function($) { + function countdown(el, options) { + var calc = function (target, current) { + /* Return true if the target date has arrived, + * an object of the time left otherwise. + */ + var current = current || new Date(); + if (current >= target) { return true; } + + var o = {}; + var remain = Math.floor((target.getTime() - current.getTime()) / 1000); + + o.days = Math.floor(remain / 86400); + remain %= 86400; + o.hours = Math.floor(remain / 3600); + remain %= 3600; + o.minutes = Math.floor(remain / 60); + remain %= 60; + o.seconds = remain; + o.years = Math.floor(o.days / 365); + o.months = Math.floor(o.days / 30); + o.weeks = Math.floor(o.days / 7); + + return o; + }; + + var getWeek = function(date) { + var onejan = new Date(date.getFullYear(),0,1); + return Math.ceil((((date - onejan) / 86400000) + onejan.getDay())/7); + }; + + var options = $.extend({ + date: new Date(), + modifiers: [], + interval: 1000, + msgFormat: '%d [day|days] %hh %mm %ss', + msgNow: 'Now !' + }, options); + + var tokens = { + y: new RegExp ('\\%y(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // years + M: new RegExp ('\\%M(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // months + w: new RegExp ('\\%w(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // weeks + d: new RegExp ('\\%d(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // days + h: new RegExp ('\\%h(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // hours + m: new RegExp ('\\%m(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g'), // minutes + s: new RegExp ('\\%s(.+?)\\[(\\w+)\\|(\\w+)\\]', 'g') // seconds + }; + + var formatToken = function(str, token, val) { + return (!tokens[token])? '': str.match(/\[|\]/g) + && (str.replace(tokens[token], val+'$1'+ ((parseInt(val, 10)<2)?'$2':'$3')) || '') + || str.replace('%'+token, val); + }; + + var format = function(str, obj) { + var o = str; + o = formatToken(o, 'y', obj.years); + o = formatToken(o, 'M', obj.months); + o = formatToken(o, 'w', obj.weeks); + o = formatToken(o, 'd', obj.days); + o = formatToken(o, 'h', obj.hours); + o = formatToken(o, 'm', obj.minutes); + o = formatToken(o, 's', obj.seconds); + return o; + }; + + var update = function() { + var date_obj = calc(cd.date); + if (date_obj === true) { + cd.stop(); clearInterval(cd.id); + $(cd.el).html(options.msgNow); + return true; + } + else { + $(cd.el).text(format(options.msgFormat, date_obj)); + } + }; + + var apply_modifiers = function (modifiers, date) { + if (modifiers.length === 0) { + return date; + } + + var modifier_re = /^([+-]\d+)([yMdhms])$/; + var conversions = { + s: 1000, + m: 60 * 1000, + h: 60 * 60 * 1000, + d: 24 * 60 * 60 * 1000, + M: 30 * 24 * 60 * 60 * 1000, + y: 365 * 24 * 60 * 60 * 1000 + }; + + var displacement = 0; + for (var i = 0, n = modifiers.length; i < n; ++i) { + var match = modifiers[i].match(modifier_re); + if (match !== null) { + displacement += parseInt(match[1], 10) * conversions[match[2]]; + } + } + return new Date(date.getTime() + displacement); + }; + + var cd = { + id : setInterval(update, options.interval), + el : el, + start : function(){ return new countdown($(this.el), options); }, + stop : function(){ return clearInterval(this.id); }, + date : apply_modifiers(options.modifiers, options.date) + }; + $(el).data('countdown', cd); + update(); + return $(el).data('countdown'); + } + $.fn.countdown = function(args) { if(this.get(0)) return new countdown(this.get(0), args); }; +})(jQuery); /* * jQuery Cycle Plugin for light-weight slideshows * Examples and documentation at: http://malsup.com/jquery/cycle/ @@ -1709,718 +1709,718 @@ $.fn.cycle.transitions.wipe = function($cont, $slides, opts) { }; })(jQuery); -/* - jQuery delayed observer - 0.8 - http://code.google.com/p/jquery-utils/ - - (c) Maxime Haineault - http://haineault.com - - MIT License (http://www.opensource.org/licenses/mit-license.php) - -*/ - -(function($){ - $.extend($.fn, { - delayedObserver: function(callback, delay, options){ - return this.each(function(){ - var el = $(this); - var op = options || {}; - el.data('oldval', el.val()) - .data('delay', delay || 0.5) - .data('condition', op.condition || function() { return ($(this).data('oldval') == $(this).val()); }) - .data('callback', callback) - [(op.event||'keyup')](function(){ - if (el.data('condition').apply(el)) { return; } - else { - if (el.data('timer')) { clearTimeout(el.data('timer')); } - el.data('timer', setTimeout(function(){ - el.data('callback').apply(el); - }, el.data('delay') * 1000)); - el.data('oldval', el.val()); - } - }); - }); - } - }); -})(jQuery); -/** - * Flash (http://jquery.lukelutman.com/plugins/flash) - * A jQuery plugin for embedding Flash movies. - * - * Version 1.0 - * November 9th, 2006 - * - * Copyright (c) 2006 Luke Lutman (http://www.lukelutman.com) - * Dual licensed under the MIT and GPL licenses. - * http://www.opensource.org/licenses/mit-license.php - * http://www.opensource.org/licenses/gpl-license.php - * - * Inspired by: - * SWFObject (http://blog.deconcept.com/swfobject/) - * UFO (http://www.bobbyvandersluis.com/ufo/) - * sIFR (http://www.mikeindustries.com/sifr/) - * - * IMPORTANT: - * The packed version of jQuery breaks ActiveX control - * activation in Internet Explorer. Use JSMin to minifiy - * jQuery (see: http://jquery.lukelutman.com/plugins/flash#activex). - * - **/ -;(function(){ - -var $$; - -/** - * - * @desc Replace matching elements with a flash movie. - * @author Luke Lutman - * @version 1.0.1 - * - * @name flash - * @param Hash htmlOptions Options for the embed/object tag. - * @param Hash pluginOptions Options for detecting/updating the Flash plugin (optional). - * @param Function replace Custom block called for each matched element if flash is installed (optional). - * @param Function update Custom block called for each matched if flash isn't installed (optional). - * @type jQuery - * - * @cat plugins/flash - * - * @example $('#hello').flash({ src: 'hello.swf' }); - * @desc Embed a Flash movie. - * - * @example $('#hello').flash({ src: 'hello.swf' }, { version: 8 }); - * @desc Embed a Flash 8 movie. - * - * @example $('#hello').flash({ src: 'hello.swf' }, { expressInstall: true }); - * @desc Embed a Flash movie using Express Install if flash isn't installed. - * - * @example $('#hello').flash({ src: 'hello.swf' }, { update: false }); - * @desc Embed a Flash movie, don't show an update message if Flash isn't installed. - * -**/ -$$ = jQuery.fn.flash = function(htmlOptions, pluginOptions, replace, update) { - - // Set the default block. - var block = replace || $$.replace; - - // Merge the default and passed plugin options. - pluginOptions = $$.copy($$.pluginOptions, pluginOptions); - - // Detect Flash. - if(!$$.hasFlash(pluginOptions.version)) { - // Use Express Install (if specified and Flash plugin 6,0,65 or higher is installed). - if(pluginOptions.expressInstall && $$.hasFlash(6,0,65)) { - // Add the necessary flashvars (merged later). - var expressInstallOptions = { - flashvars: { - MMredirectURL: location, - MMplayerType: 'PlugIn', - MMdoctitle: jQuery('title').text() - } - }; - // Ask the user to update (if specified). - } else if (pluginOptions.update) { - // Change the block to insert the update message instead of the flash movie. - block = update || $$.update; - // Fail - } else { - // The required version of flash isn't installed. - // Express Install is turned off, or flash 6,0,65 isn't installed. - // Update is turned off. - // Return without doing anything. - return this; - } - } - - // Merge the default, express install and passed html options. - htmlOptions = $$.copy($$.htmlOptions, expressInstallOptions, htmlOptions); - - // Invoke $block (with a copy of the merged html options) for each element. - return this.each(function(){ - block.call(this, $$.copy(htmlOptions)); - }); - -}; -/** - * - * @name flash.copy - * @desc Copy an arbitrary number of objects into a new object. - * @type Object - * - * @example $$.copy({ foo: 1 }, { bar: 2 }); - * @result { foo: 1, bar: 2 }; - * -**/ -$$.copy = function() { - var options = {}, flashvars = {}; - for(var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if(arg == undefined) continue; - jQuery.extend(options, arg); - // don't clobber one flash vars object with another - // merge them instead - if(arg.flashvars == undefined) continue; - jQuery.extend(flashvars, arg.flashvars); - } - options.flashvars = flashvars; - return options; -}; -/* - * @name flash.hasFlash - * @desc Check if a specific version of the Flash plugin is installed - * @type Boolean - * -**/ -$$.hasFlash = function() { - // look for a flag in the query string to bypass flash detection - if(/hasFlash\=true/.test(location)) return true; - if(/hasFlash\=false/.test(location)) return false; - var pv = $$.hasFlash.playerVersion().match(/\d+/g); - var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($$.pluginOptions.version).match(/\d+/g); - for(var i = 0; i < 3; i++) { - pv[i] = parseInt(pv[i] || 0); - rv[i] = parseInt(rv[i] || 0); - // player is less than required - if(pv[i] < rv[i]) return false; - // player is greater than required - if(pv[i] > rv[i]) return true; - } - // major version, minor version and revision match exactly - return true; -}; -/** - * - * @name flash.hasFlash.playerVersion - * @desc Get the version of the installed Flash plugin. - * @type String - * -**/ -$$.hasFlash.playerVersion = function() { - // ie - try { - try { - // avoid fp6 minor version lookup issues - // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ - var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); - try { axo.AllowScriptAccess = 'always'; } - catch(e) { return '6,0,0'; } - } catch(e) {} - return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; - // other browsers - } catch(e) { - try { - if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ - return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; - } - } catch(e) {} - } - return '0,0,0'; -}; -/** - * - * @name flash.htmlOptions - * @desc The default set of options for the object or embed tag. - * -**/ -$$.htmlOptions = { - height: 240, - flashvars: {}, - pluginspage: 'http://www.adobe.com/go/getflashplayer', - src: '#', - type: 'application/x-shockwave-flash', - width: 320 -}; -/** - * - * @name flash.pluginOptions - * @desc The default set of options for checking/updating the flash Plugin. - * -**/ -$$.pluginOptions = { - expressInstall: false, - update: true, - version: '6.0.65' -}; -/** - * - * @name flash.replace - * @desc The default method for replacing an element with a Flash movie. - * -**/ -$$.replace = function(htmlOptions) { - this.innerHTML = '
    '+this.innerHTML+'
    '; - jQuery(this) - .addClass('flash-replaced') - .prepend($$.transform(htmlOptions)); -}; -/** - * - * @name flash.update - * @desc The default method for replacing an element with an update message. - * -**/ -$$.update = function(htmlOptions) { - var url = String(location).split('?'); - url.splice(1,0,'?hasFlash=true&'); - url = url.join(''); - var msg = '

    This content requires the Flash Player. Download Flash Player. Already have Flash Player? Click here.

    '; - this.innerHTML = ''+this.innerHTML+''; - jQuery(this) - .addClass('flash-update') - .prepend(msg); -}; -/** - * - * @desc Convert a hash of html options to a string of attributes, using Function.apply(). - * @example toAttributeString.apply(htmlOptions) - * @result foo="bar" foo="bar" - * -**/ -function toAttributeString() { - var s = ''; - for(var key in this) - if(typeof this[key] != 'function') - s += key+'="'+this[key]+'" '; - return s; -}; -/** - * - * @desc Convert a hash of flashvars to a url-encoded string, using Function.apply(). - * @example toFlashvarsString.apply(flashvarsObject) - * @result foo=bar&foo=bar - * -**/ -function toFlashvarsString() { - var s = ''; - for(var key in this) - if(typeof this[key] != 'function') - s += key+'='+encodeURIComponent(this[key])+'&'; - return s.replace(/&$/, ''); -}; -/** - * - * @name flash.transform - * @desc Transform a set of html options into an embed tag. - * @type String - * - * @example $$.transform(htmlOptions) - * @result - * - * Note: The embed tag is NOT standards-compliant, but it - * works in all current browsers. flash.transform can be - * overwritten with a custom function to generate more - * standards-compliant markup. - * -**/ -$$.transform = function(htmlOptions) { - htmlOptions.toString = toAttributeString; - if(htmlOptions.flashvars) htmlOptions.flashvars.toString = toFlashvarsString; - return ''; -}; - -/** - * - * Flash Player 9 Fix (http://blog.deconcept.com/2006/07/28/swfobject-143-released/) - * -**/ -if (window.attachEvent) { - window.attachEvent("onbeforeunload", function(){ - __flash_unloadHandler = function() {}; - __flash_savedUnloadHandler = function() {}; - }); -} - -})(); -(function($){ - $._i18n = { trans: {}, 'default': 'en', language: 'en' }; - $.i18n = function() { - var getTrans = function(ns, str) { - var trans = false; - // check if string exists in translation - if ($._i18n.trans[$._i18n.language] - && $._i18n.trans[$._i18n.language][ns] - && $._i18n.trans[$._i18n.language][ns][str]) { - trans = $._i18n.trans[$._i18n.language][ns][str]; - } - // or exists in default - else if ($._i18n.trans[$._i18n['default']] - && $._i18n.trans[$._i18n['default']][ns] - && $._i18n.trans[$._i18n['default']][ns][str]) { - trans = $._i18n.trans[$._i18n['default']][ns][str]; - } - // return trans or original string - return trans || str; - }; - // Set language (accepted formats: en or en-US) - if (arguments.length < 2) { - $._i18n.language = arguments[0]; - return $._i18n.language; - } - else { - // get translation - if (typeof(arguments[1]) == 'string') { - var trans = getTrans(arguments[0], arguments[1]); - // has variables for string formating - if (arguments[2] && typeof(arguments[2]) == 'object') { - return $.format(trans, arguments[2]); - } - else { - return trans; - } - } - // set translation - else { - var tmp = arguments[0].split('.'); - var lang = tmp[0]; - var ns = tmp[1] || 'jQuery'; - if (!$._i18n.trans[lang]) { - $._i18n.trans[lang] = {}; - $._i18n.trans[lang][ns] = arguments[1]; - } - else { - $.extend($._i18n.trans[lang][ns], arguments[1]); - } - } - } - }; -})(jQuery); -/* - * Copyright (c) 2007-2008 Josh Bush (digitalbush.com) - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Version: 1.1.3 - * Release: 2008-04-16 - */ -(function($) { - - //Helper Function for Caret positioning - $.fn.caret=function(begin,end){ - if(this.length==0) return; - if (typeof begin == 'number') { - end = (typeof end == 'number')?end:begin; - return this.each(function(){ - if(this.setSelectionRange){ - this.focus(); - this.setSelectionRange(begin,end); - }else if (this.createTextRange){ - var range = this.createTextRange(); - range.collapse(true); - range.moveEnd('character', end); - range.moveStart('character', begin); - range.select(); - } - }); - } else { - if (this[0].setSelectionRange){ - begin = this[0].selectionStart; - end = this[0].selectionEnd; - }else if (document.selection && document.selection.createRange){ - var range = document.selection.createRange(); - begin = 0 - range.duplicate().moveStart('character', -100000); - end = begin + range.text.length; - } - return {begin:begin,end:end}; - } - }; - - //Predefined character definitions - var charMap={ - '9':"[0-9]", - 'a':"[A-Za-z]", - '*':"[A-Za-z0-9]" - }; - - //Helper method to inject character definitions - $.mask={ - addPlaceholder : function(c,r){ - charMap[c]=r; - } - }; - - $.fn.unmask=function(){ - return this.trigger("unmask"); - }; - - //Main Method - $.fn.mask = function(mask,settings) { - settings = $.extend({ - placeholder: "_", - completed: null - }, settings); - - //Build Regex for format validation - var re = new RegExp("^"+ - $.map( mask.split(""), function(c,i){ - return charMap[c]||((/[A-Za-z0-9]/.test(c)?"":"\\")+c); - }).join('')+ - "$"); - - return this.each(function(){ - var input=$(this); - var buffer=new Array(mask.length); - var locked=new Array(mask.length); - var valid=false; - var ignore=false; //Variable for ignoring control keys - var firstNonMaskPos=null; - - //Build buffer layout from mask & determine the first non masked character - $.each( mask.split(""), function(i,c){ - locked[i]=(charMap[c]==null); - buffer[i]=locked[i]?c:settings.placeholder; - if(!locked[i] && firstNonMaskPos==null) - firstNonMaskPos=i; - }); - - function focusEvent(){ - checkVal(); - writeBuffer(); - setTimeout(function(){ - $(input[0]).caret(valid?mask.length:firstNonMaskPos); - },0); - }; - - function keydownEvent(e){ - var pos=$(this).caret(); - var k = e.keyCode; - ignore=(k < 16 || (k > 16 && k < 32 ) || (k > 32 && k < 41)); - - //delete selection before proceeding - if((pos.begin-pos.end)!=0 && (!ignore || k==8 || k==46)){ - clearBuffer(pos.begin,pos.end); - } - //backspace and delete get special treatment - if(k==8){//backspace - while(pos.begin-->=0){ - if(!locked[pos.begin]){ - buffer[pos.begin]=settings.placeholder; - if($.browser.opera){ - //Opera won't let you cancel the backspace, so we'll let it backspace over a dummy character. - s=writeBuffer(); - input.val(s.substring(0,pos.begin)+" "+s.substring(pos.begin)); - $(this).caret(pos.begin+1); - }else{ - writeBuffer(); - $(this).caret(Math.max(firstNonMaskPos,pos.begin)); - } - return false; - } - } - }else if(k==46){//delete - clearBuffer(pos.begin,pos.begin+1); - writeBuffer(); - $(this).caret(Math.max(firstNonMaskPos,pos.begin)); - return false; - }else if (k==27){//escape - clearBuffer(0,mask.length); - writeBuffer(); - $(this).caret(firstNonMaskPos); - return false; - } - }; - - function keypressEvent(e){ - if(ignore){ - ignore=false; - //Fixes Mac FF bug on backspace - return (e.keyCode == 8)? false: null; - } - e=e||window.event; - var k=e.charCode||e.keyCode||e.which; - var pos=$(this).caret(); - - if(e.ctrlKey || e.altKey){//Ignore - return true; - }else if ((k>=41 && k<=122) ||k==32 || k>186){//typeable characters - var p=seekNext(pos.begin-1); - if(p + http://haineault.com + + MIT License (http://www.opensource.org/licenses/mit-license.php) + +*/ + +(function($){ + $.extend($.fn, { + delayedObserver: function(callback, delay, options){ + return this.each(function(){ + var el = $(this); + var op = options || {}; + el.data('oldval', el.val()) + .data('delay', delay || 0.5) + .data('condition', op.condition || function() { return ($(this).data('oldval') == $(this).val()); }) + .data('callback', callback) + [(op.event||'keyup')](function(){ + if (el.data('condition').apply(el)) { return; } + else { + if (el.data('timer')) { clearTimeout(el.data('timer')); } + el.data('timer', setTimeout(function(){ + el.data('callback').apply(el); + }, el.data('delay') * 1000)); + el.data('oldval', el.val()); + } + }); + }); + } + }); +})(jQuery); +/** + * Flash (http://jquery.lukelutman.com/plugins/flash) + * A jQuery plugin for embedding Flash movies. + * + * Version 1.0 + * November 9th, 2006 + * + * Copyright (c) 2006 Luke Lutman (http://www.lukelutman.com) + * Dual licensed under the MIT and GPL licenses. + * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/gpl-license.php + * + * Inspired by: + * SWFObject (http://blog.deconcept.com/swfobject/) + * UFO (http://www.bobbyvandersluis.com/ufo/) + * sIFR (http://www.mikeindustries.com/sifr/) + * + * IMPORTANT: + * The packed version of jQuery breaks ActiveX control + * activation in Internet Explorer. Use JSMin to minifiy + * jQuery (see: http://jquery.lukelutman.com/plugins/flash#activex). + * + **/ +;(function(){ + +var $$; + +/** + * + * @desc Replace matching elements with a flash movie. + * @author Luke Lutman + * @version 1.0.1 + * + * @name flash + * @param Hash htmlOptions Options for the embed/object tag. + * @param Hash pluginOptions Options for detecting/updating the Flash plugin (optional). + * @param Function replace Custom block called for each matched element if flash is installed (optional). + * @param Function update Custom block called for each matched if flash isn't installed (optional). + * @type jQuery + * + * @cat plugins/flash + * + * @example $('#hello').flash({ src: 'hello.swf' }); + * @desc Embed a Flash movie. + * + * @example $('#hello').flash({ src: 'hello.swf' }, { version: 8 }); + * @desc Embed a Flash 8 movie. + * + * @example $('#hello').flash({ src: 'hello.swf' }, { expressInstall: true }); + * @desc Embed a Flash movie using Express Install if flash isn't installed. + * + * @example $('#hello').flash({ src: 'hello.swf' }, { update: false }); + * @desc Embed a Flash movie, don't show an update message if Flash isn't installed. + * +**/ +$$ = jQuery.fn.flash = function(htmlOptions, pluginOptions, replace, update) { + + // Set the default block. + var block = replace || $$.replace; + + // Merge the default and passed plugin options. + pluginOptions = $$.copy($$.pluginOptions, pluginOptions); + + // Detect Flash. + if(!$$.hasFlash(pluginOptions.version)) { + // Use Express Install (if specified and Flash plugin 6,0,65 or higher is installed). + if(pluginOptions.expressInstall && $$.hasFlash(6,0,65)) { + // Add the necessary flashvars (merged later). + var expressInstallOptions = { + flashvars: { + MMredirectURL: location, + MMplayerType: 'PlugIn', + MMdoctitle: jQuery('title').text() + } + }; + // Ask the user to update (if specified). + } else if (pluginOptions.update) { + // Change the block to insert the update message instead of the flash movie. + block = update || $$.update; + // Fail + } else { + // The required version of flash isn't installed. + // Express Install is turned off, or flash 6,0,65 isn't installed. + // Update is turned off. + // Return without doing anything. + return this; + } + } + + // Merge the default, express install and passed html options. + htmlOptions = $$.copy($$.htmlOptions, expressInstallOptions, htmlOptions); + + // Invoke $block (with a copy of the merged html options) for each element. + return this.each(function(){ + block.call(this, $$.copy(htmlOptions)); + }); + +}; +/** + * + * @name flash.copy + * @desc Copy an arbitrary number of objects into a new object. + * @type Object + * + * @example $$.copy({ foo: 1 }, { bar: 2 }); + * @result { foo: 1, bar: 2 }; + * +**/ +$$.copy = function() { + var options = {}, flashvars = {}; + for(var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + if(arg == undefined) continue; + jQuery.extend(options, arg); + // don't clobber one flash vars object with another + // merge them instead + if(arg.flashvars == undefined) continue; + jQuery.extend(flashvars, arg.flashvars); + } + options.flashvars = flashvars; + return options; +}; +/* + * @name flash.hasFlash + * @desc Check if a specific version of the Flash plugin is installed + * @type Boolean + * +**/ +$$.hasFlash = function() { + // look for a flag in the query string to bypass flash detection + if(/hasFlash\=true/.test(location)) return true; + if(/hasFlash\=false/.test(location)) return false; + var pv = $$.hasFlash.playerVersion().match(/\d+/g); + var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($$.pluginOptions.version).match(/\d+/g); + for(var i = 0; i < 3; i++) { + pv[i] = parseInt(pv[i] || 0); + rv[i] = parseInt(rv[i] || 0); + // player is less than required + if(pv[i] < rv[i]) return false; + // player is greater than required + if(pv[i] > rv[i]) return true; + } + // major version, minor version and revision match exactly + return true; +}; +/** + * + * @name flash.hasFlash.playerVersion + * @desc Get the version of the installed Flash plugin. + * @type String + * +**/ +$$.hasFlash.playerVersion = function() { + // ie + try { + try { + // avoid fp6 minor version lookup issues + // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ + var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); + try { axo.AllowScriptAccess = 'always'; } + catch(e) { return '6,0,0'; } + } catch(e) {} + return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; + // other browsers + } catch(e) { + try { + if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ + return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; + } + } catch(e) {} + } + return '0,0,0'; +}; +/** + * + * @name flash.htmlOptions + * @desc The default set of options for the object or embed tag. + * +**/ +$$.htmlOptions = { + height: 240, + flashvars: {}, + pluginspage: 'http://www.adobe.com/go/getflashplayer', + src: '#', + type: 'application/x-shockwave-flash', + width: 320 +}; +/** + * + * @name flash.pluginOptions + * @desc The default set of options for checking/updating the flash Plugin. + * +**/ +$$.pluginOptions = { + expressInstall: false, + update: true, + version: '6.0.65' +}; +/** + * + * @name flash.replace + * @desc The default method for replacing an element with a Flash movie. + * +**/ +$$.replace = function(htmlOptions) { + this.innerHTML = '
    '+this.innerHTML+'
    '; + jQuery(this) + .addClass('flash-replaced') + .prepend($$.transform(htmlOptions)); +}; +/** + * + * @name flash.update + * @desc The default method for replacing an element with an update message. + * +**/ +$$.update = function(htmlOptions) { + var url = String(location).split('?'); + url.splice(1,0,'?hasFlash=true&'); + url = url.join(''); + var msg = '

    This content requires the Flash Player. Download Flash Player. Already have Flash Player? Click here.

    '; + this.innerHTML = ''+this.innerHTML+''; + jQuery(this) + .addClass('flash-update') + .prepend(msg); +}; +/** + * + * @desc Convert a hash of html options to a string of attributes, using Function.apply(). + * @example toAttributeString.apply(htmlOptions) + * @result foo="bar" foo="bar" + * +**/ +function toAttributeString() { + var s = ''; + for(var key in this) + if(typeof this[key] != 'function') + s += key+'="'+this[key]+'" '; + return s; +}; +/** + * + * @desc Convert a hash of flashvars to a url-encoded string, using Function.apply(). + * @example toFlashvarsString.apply(flashvarsObject) + * @result foo=bar&foo=bar + * +**/ +function toFlashvarsString() { + var s = ''; + for(var key in this) + if(typeof this[key] != 'function') + s += key+'='+encodeURIComponent(this[key])+'&'; + return s.replace(/&$/, ''); +}; +/** + * + * @name flash.transform + * @desc Transform a set of html options into an embed tag. + * @type String + * + * @example $$.transform(htmlOptions) + * @result + * + * Note: The embed tag is NOT standards-compliant, but it + * works in all current browsers. flash.transform can be + * overwritten with a custom function to generate more + * standards-compliant markup. + * +**/ +$$.transform = function(htmlOptions) { + htmlOptions.toString = toAttributeString; + if(htmlOptions.flashvars) htmlOptions.flashvars.toString = toFlashvarsString; + return ''; +}; + +/** + * + * Flash Player 9 Fix (http://blog.deconcept.com/2006/07/28/swfobject-143-released/) + * +**/ +if (window.attachEvent) { + window.attachEvent("onbeforeunload", function(){ + __flash_unloadHandler = function() {}; + __flash_savedUnloadHandler = function() {}; + }); +} + +})(); +(function($){ + $._i18n = { trans: {}, 'default': 'en', language: 'en' }; + $.i18n = function() { + var getTrans = function(ns, str) { + var trans = false; + // check if string exists in translation + if ($._i18n.trans[$._i18n.language] + && $._i18n.trans[$._i18n.language][ns] + && $._i18n.trans[$._i18n.language][ns][str]) { + trans = $._i18n.trans[$._i18n.language][ns][str]; + } + // or exists in default + else if ($._i18n.trans[$._i18n['default']] + && $._i18n.trans[$._i18n['default']][ns] + && $._i18n.trans[$._i18n['default']][ns][str]) { + trans = $._i18n.trans[$._i18n['default']][ns][str]; + } + // return trans or original string + return trans || str; + }; + // Set language (accepted formats: en or en-US) + if (arguments.length < 2) { + $._i18n.language = arguments[0]; + return $._i18n.language; + } + else { + // get translation + if (typeof(arguments[1]) == 'string') { + var trans = getTrans(arguments[0], arguments[1]); + // has variables for string formating + if (arguments[2] && typeof(arguments[2]) == 'object') { + return $.format(trans, arguments[2]); + } + else { + return trans; + } + } + // set translation + else { + var tmp = arguments[0].split('.'); + var lang = tmp[0]; + var ns = tmp[1] || 'jQuery'; + if (!$._i18n.trans[lang]) { + $._i18n.trans[lang] = {}; + $._i18n.trans[lang][ns] = arguments[1]; + } + else { + $.extend($._i18n.trans[lang][ns], arguments[1]); + } + } + } + }; +})(jQuery); +/* + * Copyright (c) 2007-2008 Josh Bush (digitalbush.com) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Version: 1.1.3 + * Release: 2008-04-16 + */ +(function($) { + + //Helper Function for Caret positioning + $.fn.caret=function(begin,end){ + if(this.length==0) return; + if (typeof begin == 'number') { + end = (typeof end == 'number')?end:begin; + return this.each(function(){ + if(this.setSelectionRange){ + this.focus(); + this.setSelectionRange(begin,end); + }else if (this.createTextRange){ + var range = this.createTextRange(); + range.collapse(true); + range.moveEnd('character', end); + range.moveStart('character', begin); + range.select(); + } + }); + } else { + if (this[0].setSelectionRange){ + begin = this[0].selectionStart; + end = this[0].selectionEnd; + }else if (document.selection && document.selection.createRange){ + var range = document.selection.createRange(); + begin = 0 - range.duplicate().moveStart('character', -100000); + end = begin + range.text.length; + } + return {begin:begin,end:end}; + } + }; + + //Predefined character definitions + var charMap={ + '9':"[0-9]", + 'a':"[A-Za-z]", + '*':"[A-Za-z0-9]" + }; + + //Helper method to inject character definitions + $.mask={ + addPlaceholder : function(c,r){ + charMap[c]=r; + } + }; + + $.fn.unmask=function(){ + return this.trigger("unmask"); + }; + + //Main Method + $.fn.mask = function(mask,settings) { + settings = $.extend({ + placeholder: "_", + completed: null + }, settings); + + //Build Regex for format validation + var re = new RegExp("^"+ + $.map( mask.split(""), function(c,i){ + return charMap[c]||((/[A-Za-z0-9]/.test(c)?"":"\\")+c); + }).join('')+ + "$"); + + return this.each(function(){ + var input=$(this); + var buffer=new Array(mask.length); + var locked=new Array(mask.length); + var valid=false; + var ignore=false; //Variable for ignoring control keys + var firstNonMaskPos=null; + + //Build buffer layout from mask & determine the first non masked character + $.each( mask.split(""), function(i,c){ + locked[i]=(charMap[c]==null); + buffer[i]=locked[i]?c:settings.placeholder; + if(!locked[i] && firstNonMaskPos==null) + firstNonMaskPos=i; + }); + + function focusEvent(){ + checkVal(); + writeBuffer(); + setTimeout(function(){ + $(input[0]).caret(valid?mask.length:firstNonMaskPos); + },0); + }; + + function keydownEvent(e){ + var pos=$(this).caret(); + var k = e.keyCode; + ignore=(k < 16 || (k > 16 && k < 32 ) || (k > 32 && k < 41)); + + //delete selection before proceeding + if((pos.begin-pos.end)!=0 && (!ignore || k==8 || k==46)){ + clearBuffer(pos.begin,pos.end); + } + //backspace and delete get special treatment + if(k==8){//backspace + while(pos.begin-->=0){ + if(!locked[pos.begin]){ + buffer[pos.begin]=settings.placeholder; + if($.browser.opera){ + //Opera won't let you cancel the backspace, so we'll let it backspace over a dummy character. + s=writeBuffer(); + input.val(s.substring(0,pos.begin)+" "+s.substring(pos.begin)); + $(this).caret(pos.begin+1); + }else{ + writeBuffer(); + $(this).caret(Math.max(firstNonMaskPos,pos.begin)); + } + return false; + } + } + }else if(k==46){//delete + clearBuffer(pos.begin,pos.begin+1); + writeBuffer(); + $(this).caret(Math.max(firstNonMaskPos,pos.begin)); + return false; + }else if (k==27){//escape + clearBuffer(0,mask.length); + writeBuffer(); + $(this).caret(firstNonMaskPos); + return false; + } + }; + + function keypressEvent(e){ + if(ignore){ + ignore=false; + //Fixes Mac FF bug on backspace + return (e.keyCode == 8)? false: null; + } + e=e||window.event; + var k=e.charCode||e.keyCode||e.which; + var pos=$(this).caret(); + + if(e.ctrlKey || e.altKey){//Ignore + return true; + }else if ((k>=41 && k<=122) ||k==32 || k>186){//typeable characters + var p=seekNext(pos.begin-1); + if(p @@ -2658,121 +2658,121 @@ $.fn.extend({ } })(jQuery); -/* - * timeago: a jQuery plugin, version: 0.5.1 (08/20/2008) - * @requires jQuery v1.2 or later - * - * Timeago is a jQuery plugin that makes it easy to support automatically - * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). - * - * For usage and examples, visit: - * http://timeago.yarp.com/ - * - * Licensed under the MIT: - * http://www.opensource.org/licenses/mit-license.php - * - * Copyright (c) 2008, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org) - */ -(function($) { - $.timeago = function(timestamp) { - if (timestamp instanceof Date) return inWords(timestamp); - else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp)); - else return inWords($.timeago.parse($(timestamp).attr("title"))); - }; - var $t = $.timeago; - - $.extend($.timeago, { - settings: { - refreshMillis: 60000, - allowFuture: false, - strings: { - ago: "ago", - fromNow: "from now", - seconds: "less than a minute", - minute: "about a minute", - minutes: "%d minutes", - hour: "about an hour", - hours: "about %d hours", - day: "a day", - days: "%d days", - month: "about a month", - months: "%d months", - year: "about a year", - years: "%d years" - } - }, - inWords: function(distanceMillis) { - var $l = this.settings.strings; - var suffix = $l.ago; - if (this.settings.allowFuture) { - if (distanceMillis < 0) suffix = $l.fromNow; - distanceMillis = Math.abs(distanceMillis); - } - - var seconds = distanceMillis / 1000; - var minutes = seconds / 60; - var hours = minutes / 60; - var days = hours / 24; - var years = days / 365; - - var words = seconds < 45 && sprintf($l.seconds, Math.round(seconds)) || - seconds < 90 && $l.minute || - minutes < 45 && sprintf($l.minutes, Math.round(minutes)) || - minutes < 90 && $l.hour || - hours < 24 && sprintf($l.hours, Math.round(hours)) || - hours < 48 && $l.day || - days < 30 && sprintf($l.days, Math.floor(days)) || - days < 60 && $l.month || - days < 365 && sprintf($l.months, Math.floor(days / 30)) || - years < 2 && $l.year || - sprintf($l.years, Math.floor(years)); - - return words + " " + suffix; - }, - parse: function(iso8601) { - var s = $.trim(iso8601); - s = s.replace(/-/,"/").replace(/-/,"/"); - s = s.replace(/T/," ").replace(/Z/," UTC"); - s = s.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400 - return new Date(s); - } - }); - - $.fn.timeago = function() { - var self = this; - self.each(refresh); - - var $s = $t.settings; - if ($s.refreshMillis > 0) { - setInterval(function() { self.each(refresh); }, $s.refreshMillis); - } - return self; - }; - - function refresh() { - var date = $t.parse(this.title); - if (!isNaN(date)) { - $(this).text(inWords(date)); - } - return this; - } - - function inWords(date) { - return $t.inWords(distance(date)); - } - - function distance(date) { - return (new Date().getTime() - date.getTime()); - } - - // lame sprintf implementation - function sprintf(string, value) { - return string.replace(/%d/i, value); - } - - // fix for IE6 suckage - if ($.browser.msie && $.browser.version < 7.0) { - document.createElement('abbr'); - } -})(jQuery); - +/* + * timeago: a jQuery plugin, version: 0.5.1 (08/20/2008) + * @requires jQuery v1.2 or later + * + * Timeago is a jQuery plugin that makes it easy to support automatically + * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). + * + * For usage and examples, visit: + * http://timeago.yarp.com/ + * + * Licensed under the MIT: + * http://www.opensource.org/licenses/mit-license.php + * + * Copyright (c) 2008, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org) + */ +(function($) { + $.timeago = function(timestamp) { + if (timestamp instanceof Date) return inWords(timestamp); + else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp)); + else return inWords($.timeago.parse($(timestamp).attr("title"))); + }; + var $t = $.timeago; + + $.extend($.timeago, { + settings: { + refreshMillis: 60000, + allowFuture: false, + strings: { + ago: "ago", + fromNow: "from now", + seconds: "less than a minute", + minute: "about a minute", + minutes: "%d minutes", + hour: "about an hour", + hours: "about %d hours", + day: "a day", + days: "%d days", + month: "about a month", + months: "%d months", + year: "about a year", + years: "%d years" + } + }, + inWords: function(distanceMillis) { + var $l = this.settings.strings; + var suffix = $l.ago; + if (this.settings.allowFuture) { + if (distanceMillis < 0) suffix = $l.fromNow; + distanceMillis = Math.abs(distanceMillis); + } + + var seconds = distanceMillis / 1000; + var minutes = seconds / 60; + var hours = minutes / 60; + var days = hours / 24; + var years = days / 365; + + var words = seconds < 45 && sprintf($l.seconds, Math.round(seconds)) || + seconds < 90 && $l.minute || + minutes < 45 && sprintf($l.minutes, Math.round(minutes)) || + minutes < 90 && $l.hour || + hours < 24 && sprintf($l.hours, Math.round(hours)) || + hours < 48 && $l.day || + days < 30 && sprintf($l.days, Math.floor(days)) || + days < 60 && $l.month || + days < 365 && sprintf($l.months, Math.floor(days / 30)) || + years < 2 && $l.year || + sprintf($l.years, Math.floor(years)); + + return words + " " + suffix; + }, + parse: function(iso8601) { + var s = $.trim(iso8601); + s = s.replace(/-/,"/").replace(/-/,"/"); + s = s.replace(/T/," ").replace(/Z/," UTC"); + s = s.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400 + return new Date(s); + } + }); + + $.fn.timeago = function() { + var self = this; + self.each(refresh); + + var $s = $t.settings; + if ($s.refreshMillis > 0) { + setInterval(function() { self.each(refresh); }, $s.refreshMillis); + } + return self; + }; + + function refresh() { + var date = $t.parse(this.title); + if (!isNaN(date)) { + $(this).text(inWords(date)); + } + return this; + } + + function inWords(date) { + return $t.inWords(distance(date)); + } + + function distance(date) { + return (new Date().getTime() - date.getTime()); + } + + // lame sprintf implementation + function sprintf(string, value) { + return string.replace(/%d/i, value); + } + + // fix for IE6 suckage + if ($.browser.msie && $.browser.version < 7.0) { + document.createElement('abbr'); + } +})(jQuery); + diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css index 7c832c20d..c63b5fcd6 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css +++ b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css @@ -965,14 +965,14 @@ table.items td .add /* Pager ***************************************************************/ -.pager-footer { width: 500px; } +.pager-footer { } .page-size-options { float: left; padding-right: 40px; margin-left: auto; } html.dyn #submit-pager, html.dyn .apply-bulk-actions-auto { display:none; } -.pager { list-style: none; padding: 0; margin: 2px 0 0 0;} +.pager { list-style: none; padding: 0; margin: 2px 0 0 0; overflow: hidden; } .pager li { float: left; padding: 0 0 0 0; diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/Pager.cshtml b/src/Orchard.Web/Themes/TheAdmin/Views/Pager.cshtml index c798bc54b..54552a366 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Views/Pager.cshtml +++ b/src/Orchard.Web/Themes/TheAdmin/Views/Pager.cshtml @@ -1,7 +1,6 @@ @{ - var window = 7; // number of simultaneously displayed pages - var nextText = HasText(Model.NextText) ? Model.NextText : T(">").Text; - var previousText = HasText(Model.PreviousText) ? Model.PreviousText : T("<").Text; + Model.PreviousText = T("<"); + Model.NextText = T(">"); var routeData = new RouteValueDictionary(ViewContext.RouteData.Values); var queryString = ViewContext.HttpContext.Request.QueryString; @@ -19,11 +18,9 @@ } var totalPageCount = (int)Math.Ceiling((double)Model.TotalItemCount / Model.PageSize); - var firstPage = Math.Max(1, (int)Model.Page - (window / 2)); - var lastPage = Math.Min(totalPageCount, (int)Model.Page + (window / 2)); - Model.Classes.Add("pager"); - var pageTag = Tag(Model, "ul"); + Model.Metadata.Type = "Pager_Links"; + IHtmlString pagerLinks = Display(Model); Model.Classes.Add("selector"); var pageSizeTag = Tag(Model, "ul"); @@ -34,7 +31,7 @@ } } - var pageSizes = new List() { 10, 50, 100 }; + var pageSizes = new List { 10, 50, 100 }; var defaultPageSize = WorkContext.CurrentSite.PageSize; if (!pageSizes.Contains(defaultPageSize)) { pageSizes.Add(defaultPageSize); @@ -54,7 +51,7 @@ @if ((int)Model.PageSize == 0) {
  • @T("All").ToString()
  • } else { -
  • @Html.ActionLink(T("All").ToString(), (string)routeData["action"], (string)routeData["controller"], routeData, null)
  • +
  • @Display.ActionLink(Value: T("All"), Action: (string)routeData["action"], Controller: (string)routeData["controller"], RouteValues: routeData)
  • } @foreach (int size in pageSizes.OrderBy(p => p)) { @@ -63,7 +60,7 @@ if ((int)Model.PageSize == size) {
  • @size.ToString()
  • } else { -
  • @Html.ActionLink(size.ToString(), (string)routeData["action"], (string)routeData["controller"], routeData, null)
  • +
  • @Display.ActionLink(Value: size, Action: (string)routeData["action"], Controller: (string)routeData["controller"], RouteValues: routeData)
  • } } @@ -73,74 +70,7 @@ @T("Showing items {0} - {1} of {2}", (Model.Page - 1) * (int)Model.PageSize + 1, Model.PageSize == 0 ? Model.TotalItemCount : Math.Min(Model.TotalItemCount, (Model.Page) * (int)Model.PageSize), Model.TotalItemCount) - @if (totalPageCount > 1) { - routeData["pageSize"] = Model.PageSize; - @pageTag.StartElement - - // first - if (firstPage > 1) { - if (routeData.ContainsKey("page")) { - routeData.Remove("page"); - } - -
  • - @Html.ActionLink(T("<<").Text, (string)routeData["action"], (string)routeData["controller"], routeData, null) -
  • - } - - // previous page - if (Model.Page > 1) { - if (Model.Page == 2 && routeData.ContainsKey("page")) { - routeData.Remove("page"); - } - else { - routeData["page"] = Model.Page - 1; - } - -
  • - @Html.ActionLink((string)previousText, (string)routeData["action"], (string)routeData["controller"], routeData, null) -
  • - } - - // page numbers - for (var p = firstPage; p <= lastPage; p++) { -
  • - @if (p == Model.Page) { - @p - } - else { - if (p == 1) { - routeData.Remove("page"); - } - else { - routeData["page"] = p; - } - @Html.ActionLink(p.ToString(), (string)routeData["action"], (string)routeData["controller"], routeData, null) - } -
  • - } - - // next page - if (Model.Page < totalPageCount) { - routeData["page"] = Model.Page + 1; - -
  • - @Html.ActionLink((string)nextText, (string)routeData["action"], (string)routeData["controller"], routeData, null) -
  • - } - - // last page - if (lastPage < totalPageCount) { - routeData["page"] = totalPageCount; - -
  • - @Html.ActionLink(T(">>").Text, (string)routeData["action"], (string)routeData["controller"], routeData, null) -
  • - } - - @pageTag.EndElement - } - + @pagerLinks } @using (Script.Foot()) { diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Styles/Site.css b/src/Orchard.Web/Themes/TheThemeMachine/Styles/Site.css index b9ac5b6d8..6908f6548 100644 --- a/src/Orchard.Web/Themes/TheThemeMachine/Styles/Site.css +++ b/src/Orchard.Web/Themes/TheThemeMachine/Styles/Site.css @@ -299,21 +299,21 @@ nav ul .zone-header { padding: 30px 0 30px 12px; position: relative; } .zone-navigation { padding: 0; } .zone-featured {} -.zone-beforemain {} -.zone-asidefirst {} +.zone-before-main {} +.zone-aside-first {} .zone-messages {} -.zone-beforecontent {} +.zone-before-content {} .zone-content {} -.zone-aftercontent {} -.zone-asidesecond {} -.zone-aftermain {} -.zone-zone-tripelfirst {} -.zone-zone-tripelsecond {} -.zone-zone-tripelthird {} -.zone-footerquadfirst {} -.zone-footerquadsecond {} -.zone-footerquadthird {} -.zone-footerquadfourth {} +.zone-after-content {} +.zone-aside-second {} +.zone-after-main {} +.zone-tripel-first {} +.zone-tripel-second {} +.zone-tripel-third {} +.zone-footer-quad-first {} +.zone-footer-quad-second {} +.zone-footer-quad-third {} +.zone-footer-quad-fourth {} .zone-footer { color: #999999; } @@ -450,9 +450,9 @@ nav ul .pager { list-style: none; padding: 0; margin: 12px 0 0 0; } .pager li { float: left; padding: 0 12px 0 0; margin: 0; } -.pager a { font-size: 1.077em; display: block; background-color: #dbdbdb; padding: 6px 6px; color: #434343;} +.pager a, .pager span { font-size: 1.077em; display: block; background-color: #dbdbdb; padding: 6px 6px; color: #434343;} .pager a:hover { background-color: #434343; color: #fff; } - +.pager span { background-color:inherit; } /* Misc diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.First.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.First.cshtml new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.First.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.Last.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.Last.cshtml new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.Last.cshtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.cshtml new file mode 100644 index 000000000..dc7baca19 --- /dev/null +++ b/src/Orchard.Web/Themes/TheThemeMachine/Views/Pager.cshtml @@ -0,0 +1,9 @@ +@{ + Model.Quantity = 0; + Model.PreviousText = T("Newer"); + Model.NextText = T("Older"); + Model.Classes.Add("group"); + Model.Metadata.Alternates.Clear(); + Model.Metadata.Type = "Pager_Links"; +} +@Display(Model) \ No newline at end of file diff --git a/src/Orchard.Web/Themes/Themes.csproj b/src/Orchard.Web/Themes/Themes.csproj index 387c6a0f7..ec1643d53 100644 --- a/src/Orchard.Web/Themes/Themes.csproj +++ b/src/Orchard.Web/Themes/Themes.csproj @@ -146,6 +146,15 @@ True + + + + + + + + +