Tag: wordpress开发

  • 全面解析如何向 WooCommerce 产品添加自定义字段:方法与最佳实践

    全面解析如何向 WooCommerce 产品添加自定义字段:方法与最佳实践

    自定义字段不仅可以让你为产品提供更详细的规格和功能,还能显著改善客户的购物体验,甚至提升商店的转化率。那么,如何向 WooCommerce 产品添加自定义字段?以下是一篇详细的分步指南,适合初学者和有经验的用户。

    什么是 WooCommerce 自定义字段?

    图片[1]-361Sale WordPress Care

    自定义字段是为产品页面添加额外的输入区域或功能的工具。这些字段可以提供丰富的信息,比如产品的技术规格、额外选项或个性化信息,从而满足客户的个性化需求。

    示例:
    假设你销售T恤,可以创建一个自定义字段,让顾客选择他们喜欢的颜色,或者添加他们的名字以制作定制商品。

    图片[2]-361Sale WordPress Care

    WooCommerce 中的自定义字段类型

    WooCommerce 提供多种类型的自定义字段,每种字段类型都有其独特的用例。以下是常见的自定义字段类型:

    图片[3]-361Sale WordPress Care
    1. 时间选择器
      用于选择预约时间或送货时间。
    2. 日期选择器
      方便客户选择特定的订单日期。
    3. 下拉菜单
      提供多项选择以简化决策过程。
    4. 颜色选择器
      用于让客户选择产品的颜色。
    5. 关系字段
      用于链接产品与页面或文章,比如关联相关内容。
    6. 可重复字段
      允许添加多组相同类型的信息,比如产品规格列表。
    7. 产品字段
      可用于推荐其他相关产品,促进交叉销售或追加销售
    8. 数字字段
      用于输入数值,例如库存数量或尺寸。
    9. 单选按钮
      限定用户从选项中选择一个值。
    10. 文本字段
      用于客户填写定制信息,例如个性化留言。
    图片[4]-361Sale WordPress Care

    如何向 WooCommerce 产品添加自定义字段

    向 WooCommerce 添加自定义字段主要有两种方法:使用插件和通过编程实现。

    方法一:使用插件添加自定义字段

    对于大多数用户来说,使用插件(SCF、ACF)是最简单的方法。以下以 高级自定义字段(ACF)插件 为例,详细介绍步骤:

    1. 安装高级自定义字段插件

    图片[5]-361Sale WordPress Care

    2. 创建新的字段组

    • 在 WordPress 后台左侧菜单中找到 ACF > 字段组
    图片[6]-361Sale WordPress Care
    • 单击 添加字段组,为字段组命名,例如“产品规格”。
    图片[7]-361Sale WordPress Care

    3. 添加自定义字段

    • 在标签处填写字段的详细信息:
      • 字段类型:选择文本、复选框、下拉菜单等。
      • 字段标签:输入字段的名称,例如“颜色”。
      • 字段名称:系统会自动生成字段的标识符。
    图片[8]-361Sale WordPress Care

    4. 设置字段组的显示规则

    • 位置规则 中选择“文章类型 > 产品”,确保这些字段仅应用于 WooCommerce 产品

    5. 保存字段组

    • 确保字段组状态为“激活”,然后单击 保存更改

    6. 在产品页面中填写自定义字段

    • 打开任一产品页面,你会看到新添加的字段组,按照需要填写信息。

    7. 在前端显示自定义字段

    • 使用 [acf field="字段名称"] 短代码,将字段内容显示在前端。例如,将代码插入到产品描述区域。
    图片[9]-361Sale WordPress Care

    方法二:通过编程添加自定义字段

    图片[10]-361Sale WordPress Care

    如果你熟悉代码,可以通过编程实现自定义字段。确保你在主题的 functions.php 文件中添加代码,或者使用插件(如 Code Snippets)来避免直接修改主题核心文件。

    以下是实现步骤:

    1. 创建自定义元框

    • 使用 WordPress 的 add_meta_box 函数,为产品页面添加元框

    2. 保存字段数据

    • 使用 save_post 钩子,将字段值保存到数据库。

    3. 显示字段数据

    • 使用 get_post_meta 函数,在前端显示字段数据

    示例代码:

    // 添加自定义元框
    add_action('add_meta_boxes', 'add_custom_meta_box');
    function add_custom_meta_box() {
    add_meta_box('product_custom_fields', '产品自定义字段', 'custom_meta_box_callback', 'product');
    }

    function custom_meta_box_callback($post) {
    $custom_field_value = get_post_meta($post->ID, 'custom_field_key', true);
    echo '<label for="custom_field">字段名称:</label>';
    echo '<input type="text" id="custom_field" name="custom_field" value="' . esc_attr($custom_field_value) . '" />';
    }

    // 保存字段数据
    add_action('save_post', 'save_custom_meta_box_data');
    function save_custom_meta_box_data($post_id) {
    if (isset($_POST['custom_field'])) {
    update_post_meta($post_id, 'custom_field_key', sanitize_text_field($_POST['custom_field']));
    }
    }

    将上述代码添加到主题的 functions.php 文件或者在Code Snippets中。

    图片[11]-361Sale WordPress Care

    自定义字段与属性的区别

    图片[12]-361Sale WordPress Care
    特性 自定义字段 属性
    目的 提供额外信息,如颜色选择器、文本区域等 产品的标准特性,例如尺寸、颜色等
    灵活性 高度灵活,可添加独特的个性化信息 灵活性较低,仅限预定义选项
    成本 可能需要付费插件 无需额外费用
    示例 复选框、日期选择器、文本区域 材质、尺寸、颜色等

    最佳实践和技巧

    1. 规划字段用途
      在创建字段前,明确其目标和用途。
    2. 选择适当的字段类型
      根据所需数据选择合适的字段类型。
    3. 避免信息过载
      保持字段数量适中,提升用户体验。
    4. 测试字段功能
      确保字段在所有设备和浏览器中正常运行。
    5. 保持字段更新
      定期更新插件和字段内容,确保兼容性和安全性。

    常见问题 (FAQ)

    1. 高级自定义字段插件免费吗?
      是的,ACF 插件有免费版和付费版。免费版提供基本功能,付费版提供更多高级选项。
    2. 自定义字段是否影响页面性能?
      适当使用不会影响性能,但过多的字段可能会增加页面加载时间
  • 如何使用 WordPress get_post_meta 函数:完整指南与实用案例

    如何使用 WordPress get_post_meta 函数:完整指南与实用案例

    在 WordPress 中,get_post_meta 函数是一个极为强大的工具,它可以帮助开发者轻松检索与特定帖子相关的自定义字段数据。这种功能在定制网站功能和展示动态内容方面显得尤为重要。本文将详细介绍 get_post_meta 函数的工作原理、基本语法及参数,并提供实际的使用案例和最佳实践。

    图片[1]-361Sale WordPress Care

    什么是 WordPress 自定义字段?

    在 WordPress 中,自定义字段是为特定帖子或页面存储额外数据的一种方法。除了标准字段(如标题、内容、分类等),自定义字段可以保存额外的信息,例如电话号码、地址、价格等。使用 get_post_meta 函数,可以方便地从数据库中检索这些自定义字段的数据,并在前端页面上展示。

    get_post_meta 函数的工作原理

    图片[2]-361Sale WordPress Care
    1. 自定义字段
      • 自定义字段可以为帖子或页面附加额外的数据。
      • 这些字段通过 WordPress 后端的“自定义字段”功能或插件(如 ACF)创建。
    2. get_post_meta 函数
      • 通过提供帖子 ID 和自定义字段的键值(Meta Key),get_post_meta 函数从数据库中获取数据。
      • 函数可以选择返回单个值或值的数组,具体取决于参数设置。
    3. 检索数据
      • 通过调用函数,开发者可以将数据直接输出到页面模板中,帮助网站实现更多动态功能。

    get_post_meta 函数的基本语法

    图片[3]-361Sale WordPress Care

    语法结构

    get_post_meta( $post_id, $key, $single );

    参数详解

    1. $post_id
      • 要从中检索数据的帖子的 ID。
      • 例如,get_the_ID() 可以获取当前帖子的 ID。
    图片[4]-361Sale WordPress Care
    1. $key
      • 自定义字段的名称(Meta Key)。
      • 例如,'phone_number' 表示获取电话字段。
    2. $single
      • 布尔值,指定是否返回单个值。
        • true:返回单个值。
        • false:返回值的数组。

    get_post_meta 函数的使用示例

    以下代码演示如何在模板文件中使用 get_post_meta 函数:

    示例 1:获取单个值

    // 获取当前帖子的 ID
    $post_id = get_the_ID();

    // 获取自定义字段 'phone_number' 的值
    $phone_number = get_post_meta( $post_id, 'phone_number', true );

    // 显示电话号码
    if ( $phone_number ) {
    echo '

    Phone Number: ' . $phone_number . '

    ';
    }

    示例 2:获取数组值

    // 获取所有的自定义字段值
    $custom_fields = get_post_meta( $post_id, 'gallery_images', false );

    if ( !empty($custom_fields) ) {
    foreach ( $custom_fields as $field ) {
    echo '';
    }
    }

    示例 3:与 WordPress 循环结合使用





    如何使用 get_post_meta 自定义 WordPress 网站

    方法一:手动方式

    通过直接编辑主题文件,可以使用 get_post_meta 函数显示自定义字段的值。

    步骤:

    1. 登录到 WordPress 管理仪表板。

    2. 导航到 外观 > 主题文件编辑器

      图片[5]-361Sale WordPress Care

      3. 找到需要编辑的模板文件(例如 single.phppage.php)。

      图片[6]-361Sale WordPress Care

      4. 在模板文件中插入以下代码:

        echo get_post_meta( get_the_ID(), 'custom_field_key', true );

        5. 保存更改并刷新页面。

        假设你的文章有一个自定义字段,键名为 phone_number,值为 123-456-7890,你可以将代码替换为:

        echo get_post_meta( get_the_ID(), 'phone_number', true );

        在前端页面上,用户会看到以下内容:

        123-456-7890

          方法二:使用插件

          如果不熟悉编码,可以通过插件(如 Advanced Custom Fields,简称 ACF)来创建和显示自定义字段。

          步骤:
          1. 安装并激活 ACF 插件
          2. 转到 字段组 > 添加新字段组
          图片[7]-361Sale WordPress Care
          1. 设置字段组名称,并选择适用的帖子类型(如帖子或页面)。
          2. 创建字段(如文本、选择框或图像)。
          图片[8]-361Sale WordPress Care
          图片[9]-361Sale WordPress Care
          1. 使用 get_field() 函数显示字段值:
          $phone_number = get_field('phone_number');
          if ( $phone_number ) {
          echo '

          Phone Number: ' . $phone_number . '

          ';
          }

          通过这种方式,可以轻松管理和展示各种类型的自定义字段。

          使用 get_post_meta 的注意事项

          1. 性能优化
            • 避免在一个页面中多次调用 get_post_meta,建议结合缓存技术减少数据库查询。
          2. 数据验证与清理
            • 使用 sanitize_text_fieldesc_html 等函数对数据进行清理,确保安全性。
          3. 与自定义帖子类型配合
            • get_post_meta 函数完全支持自定义帖子类型,只需提供帖子 ID
          4. 兼容性
            • 确保在正确的上下文中使用(如 WordPress 循环内),避免调用未定义的帖子 ID。
          图片[10]-361Sale WordPress Care

          常见问题解答

          1. 我可以将 get_post_meta 与自定义帖子类型一起使用吗?

          是的,get_post_meta 可以与任何帖子类型一起使用。只需提供对应的帖子 ID。

          2. 使用 get_post_meta 是否会影响网站性能?

          频繁调用 get_post_meta 会增加数据库查询次数,可能影响性能。建议结合缓存技术优化。

          3. 可以在插件或自定义函数中使用 get_post_meta 吗?

          可以。get_post_meta 可在任何支持 $post_id 的上下文中使用,例如插件或自定义函数。

          结论

          get_post_meta 是 WordPress 开发者手中不可或缺的工具。通过合理使用此函数,可以增强网站功能,为用户提供更个性化的体验。如果希望进一步扩展 WordPress 网站功能,结合 ACF 插件等工具,让网站更具动态性和灵活性。

        1. WordPress源代码——jquery-ui(1.8.20——jquery.effects.fade.js)

          WordPress源代码——jquery-ui(1.8.20——jquery.effects.fade.js)

          1	/*!
          2	 * jQuery UI Effects Fade @VERSION
          3	 *
          4	 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
          5	 * Dual licensed under the MIT or GPL Version 2 licenses.
          6	 * http://jquery.org/license
          7	 *
          8	 * http://docs.jquery.com/UI/Effects/Fade
          9	 *
          10	 * Depends:
          11	 *      jquery.effects.core.js
          12	 */
          13	(function( $, undefined ) {
          14	
          15	$.effects.fade = function(o) {
          16	        return this.queue(function() {
          17	                var elem = $(this),
          18	                        mode = $.effects.setMode(elem, o.options.mode || 'hide');
          19	
          20	                elem.animate({ opacity: mode }, {
          21	                        queue: false,
          22	                        duration: o.duration,
          23	                        easing: o.options.easing,
          24	                        complete: function() {
          25	                                (o.callback && o.callback.apply(this, arguments));
          26	                                elem.dequeue();
          27	                        }
          28	                });
          29	        });
          30	};
          31	
          32	})(jQuery);
          
        2. WordPress源代码——jquery-ui(1.8.20——jquery.effects.core.js)

          WordPress源代码——jquery-ui(1.8.20——jquery.effects.core.js)

          1	/*!
          2	 * jQuery UI Effects @VERSION
          3	 *
          4	 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
          5	 * Dual licensed under the MIT or GPL Version 2 licenses.
          6	 * http://jquery.org/license
          7	 *
          8	 * http://docs.jquery.com/UI/Effects/
          9	 */
          10	;jQuery.effects || (function($, undefined) {
          11	
          12	$.effects = {};
          13	
          14	
          15	
          16	/******************************************************************************/
          17	/****************************** COLOR ANIMATIONS ******************************/
          18	/******************************************************************************/
          19	
          20	// override the animation for color styles
          21	$.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
          22	        'borderRightColor', 'borderTopColor', 'borderColor', 'color', 'outlineColor'],
          23	function(i, attr) {
          24	        $.fx.step[attr] = function(fx) {
          25	                if (!fx.colorInit) {
          26	                        fx.start = getColor(fx.elem, attr);
          27	                        fx.end = getRGB(fx.end);
          28	                        fx.colorInit = true;
          29	                }
          30	
          31	                fx.elem.style[attr] = 'rgb(' +
          32	                        Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
          33	                        Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
          34	                        Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
          35	        };
          36	});
          37	
          38	// Color Conversion functions from highlightFade
          39	// By Blair Mitchelmore
          40	// http://jquery.offput.ca/highlightFade/
          41	
          42	// Parse strings looking for color tuples [255,255,255]
          43	function getRGB(color) {
          44	                var result;
          45	
          46	                // Check if we're already dealing with an array of colors
          47	                if ( color && color.constructor == Array && color.length == 3 )
          48	                                return color;
          49	
          50	                // Look for rgb(num,num,num)
          51	                if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
          52	                                return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
          53	
          54	                // Look for rgb(num%,num%,num%)
          55	                if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
          56	                                return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
          57	
          58	                // Look for #a0b1c2
          59	                if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
          60	                                return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
          61	
          62	                // Look for #fff
          63	                if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
          64	                                return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
          65	
          66	                // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
          67	                if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
          68	                                return colors['transparent'];
          69	
          70	                // Otherwise, we're most likely dealing with a named color
          71	                return colors[$.trim(color).toLowerCase()];
          72	}
          73	
          74	function getColor(elem, attr) {
          75	                var color;
          76	
          77	                do {
          78	                                color = $.curCSS(elem, attr);
          79	
          80	                                // Keep going until we find an element that has color, or we hit the body
          81	                                if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
          82	                                                break;
          83	
          84	                                attr = "backgroundColor";
          85	                } while ( elem = elem.parentNode );
          86	
          87	                return getRGB(color);
          88	};
          89	
          90	// Some named colors to work with
          91	// From Interface by Stefan Petre
          92	// http://interface.eyecon.ro/
          93	
          94	var colors = {
          95	        aqua:[0,255,255],
          96	        azure:[240,255,255],
          97	        beige:[245,245,220],
          98	        black:[0,0,0],
          99	        blue:[0,0,255],
          100	        brown:[165,42,42],
          101	        cyan:[0,255,255],
          102	        darkblue:[0,0,139],
          103	        darkcyan:[0,139,139],
          104	        darkgrey:[169,169,169],
          105	        darkgreen:[0,100,0],
          106	        darkkhaki:[189,183,107],
          107	        darkmagenta:[139,0,139],
          108	        darkolivegreen:[85,107,47],
          109	        darkorange:[255,140,0],
          110	        darkorchid:[153,50,204],
          111	        darkred:[139,0,0],
          112	        darksalmon:[233,150,122],
          113	        darkviolet:[148,0,211],
          114	        fuchsia:[255,0,255],
          115	        gold:[255,215,0],
          116	        green:[0,128,0],
          117	        indigo:[75,0,130],
          118	        khaki:[240,230,140],
          119	        lightblue:[173,216,230],
          120	        lightcyan:[224,255,255],
          121	        lightgreen:[144,238,144],
          122	        lightgrey:[211,211,211],
          123	        lightpink:[255,182,193],
          124	        lightyellow:[255,255,224],
          125	        lime:[0,255,0],
          126	        magenta:[255,0,255],
          127	        maroon:[128,0,0],
          128	        navy:[0,0,128],
          129	        olive:[128,128,0],
          130	        orange:[255,165,0],
          131	        pink:[255,192,203],
          132	        purple:[128,0,128],
          133	        violet:[128,0,128],
          134	        red:[255,0,0],
          135	        silver:[192,192,192],
          136	        white:[255,255,255],
          137	        yellow:[255,255,0],
          138	        transparent: [255,255,255]
          139	};
          140	
          141	
          142	
          143	/******************************************************************************/
          144	/****************************** CLASS ANIMATIONS ******************************/
          145	/******************************************************************************/
          146	
          147	var classAnimationActions = ['add', 'remove', 'toggle'],
          148	        shorthandStyles = {
          149	                border: 1,
          150	                borderBottom: 1,
          151	                borderColor: 1,
          152	                borderLeft: 1,
          153	                borderRight: 1,
          154	                borderTop: 1,
          155	                borderWidth: 1,
          156	                margin: 1,
          157	                padding: 1
          158	        };
          159	
          160	function getElementStyles() {
          161	        var style = document.defaultView
          162	                        ? document.defaultView.getComputedStyle(this, null)
          163	                        : this.currentStyle,
          164	                newStyle = {},
          165	                key,
          166	                camelCase;
          167	
          168	        // webkit enumerates style porperties
          169	        if (style && style.length && style[0] && style[style[0]]) {
          170	                var len = style.length;
          171	                while (len--) {
          172	                        key = style[len];
          173	                        if (typeof style[key] == 'string') {
          174	                                camelCase = key.replace(/\-(\w)/g, function(all, letter){
          175	                                        return letter.toUpperCase();
          176	                                });
          177	                                newStyle[camelCase] = style[key];
          178	                        }
          179	                }
          180	        } else {
          181	                for (key in style) {
          182	                        if (typeof style[key] === 'string') {
          183	                                newStyle[key] = style[key];
          184	                        }
          185	                }
          186	        }
          187	       
          188	        return newStyle;
          189	}
          190	
          191	function filterStyles(styles) {
          192	        var name, value;
          193	        for (name in styles) {
          194	                value = styles[name];
          195	                if (
          196	                        // ignore null and undefined values
          197	                        value == null ||
          198	                        // ignore functions (when does this occur?)
          199	                        $.isFunction(value) ||
          200	                        // shorthand styles that need to be expanded
          201	                        name in shorthandStyles ||
          202	                        // ignore scrollbars (break in IE)
          203	                        (/scrollbar/).test(name) ||
          204	
          205	                        // only colors or values that can be converted to numbers
          206	                        (!(/color/i).test(name) && isNaN(parseFloat(value)))
          207	                ) {
          208	                        delete styles[name];
          209	                }
          210	        }
          211	       
          212	        return styles;
          213	}
          214	
          215	function styleDifference(oldStyle, newStyle) {
          216	        var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
          217	                name;
          218	
          219	        for (name in newStyle) {
          220	                if (oldStyle[name] != newStyle[name]) {
          221	                        diff[name] = newStyle[name];
          222	                }
          223	        }
          224	
          225	        return diff;
          226	}
          227	
          228	$.effects.animateClass = function(value, duration, easing, callback) {
          229	        if ($.isFunction(easing)) {
          230	                callback = easing;
          231	                easing = null;
          232	        }
          233	
          234	        return this.queue(function() {
          235	                var that = $(this),
          236	                        originalStyleAttr = that.attr('style') || ' ',
          237	                        originalStyle = filterStyles(getElementStyles.call(this)),
          238	                        newStyle,
          239	                        className = that.attr('class') || "";
          240	
          241	                $.each(classAnimationActions, function(i, action) {
          242	                        if (value[action]) {
          243	                                that[action + 'Class'](value[action]);
          244	                        }
          245	                });
          246	                newStyle = filterStyles(getElementStyles.call(this));
          247	                that.attr('class', className);
          248	
          249	                that.animate(styleDifference(originalStyle, newStyle), {
          250	                        queue: false,
          251	                        duration: duration,
          252	                        easing: easing,
          253	                        complete: function() {
          254	                                $.each(classAnimationActions, function(i, action) {
          255	                                        if (value[action]) { that[action + 'Class'](value[action]); }
          256	                                });
          257	                                // work around bug in IE by clearing the cssText before setting it
          258	                                if (typeof that.attr('style') == 'object') {
          259	                                        that.attr('style').cssText = '';
          260	                                        that.attr('style').cssText = originalStyleAttr;
          261	                                } else {
          262	                                        that.attr('style', originalStyleAttr);
          263	                                }
          264	                                if (callback) { callback.apply(this, arguments); }
          265	                                $.dequeue( this );
          266	                        }
          267	                });
          268	        });
          269	};
          270	
          271	$.fn.extend({
          272	        _addClass: $.fn.addClass,
          273	        addClass: function(classNames, speed, easing, callback) {
          274	                return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
          275	        },
          276	
          277	        _removeClass: $.fn.removeClass,
          278	        removeClass: function(classNames,speed,easing,callback) {
          279	                return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
          280	        },
          281	
          282	        _toggleClass: $.fn.toggleClass,
          283	        toggleClass: function(classNames, force, speed, easing, callback) {
          284	                if ( typeof force == "boolean" || force === undefined ) {
          285	                        if ( !speed ) {
          286	                                // without speed parameter;
          287	                                return this._toggleClass(classNames, force);
          288	                        } else {
          289	                                return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
          290	                        }
          291	                } else {
          292	                        // without switch parameter;
          293	                        return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
          294	                }
          295	        },
          296	
          297	        switchClass: function(remove,add,speed,easing,callback) {
          298	                return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
          299	        }
          300	});
          301	
          302	
          303	
          304	/******************************************************************************/
          305	/*********************************** EFFECTS **********************************/
          306	/******************************************************************************/
          307	
          308	$.extend($.effects, {
          309	        version: "@VERSION",
          310	
          311	        // Saves a set of properties in a data storage
          312	        save: function(element, set) {
          313	                for(var i=0; i < set.length; i++) {
          314	                        if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
          315	                }
          316	        },
          317	
          318	        // Restores a set of previously saved properties from a data storage
          319	        restore: function(element, set) {
          320	                for(var i=0; i < set.length; i++) {
          321	                        if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
          322	                }
          323	        },
          324	
          325	        setMode: function(el, mode) {
          326	                if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
          327	                return mode;
          328	        },
          329	
          330	        getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
          331	                // this should be a little more flexible in the future to handle a string & hash
          332	                var y, x;
          333	                switch (origin[0]) {
          334	                        case 'top': y = 0; break;
          335	                        case 'middle': y = 0.5; break;
          336	                        case 'bottom': y = 1; break;
          337	                        default: y = origin[0] / original.height;
          338	                };
          339	                switch (origin[1]) {
          340	                        case 'left': x = 0; break;
          341	                        case 'center': x = 0.5; break;
          342	                        case 'right': x = 1; break;
          343	                        default: x = origin[1] / original.width;
          344	                };
          345	                return {x: x, y: y};
          346	        },
          347	
          348	        // Wraps the element around a wrapper that copies position properties
          349	        createWrapper: function(element) {
          350	
          351	                // if the element is already wrapped, return it
          352	                if (element.parent().is('.ui-effects-wrapper')) {
          353	                        return element.parent();
          354	                }
          355	
          356	                // wrap the element
          357	                var props = {
          358	                                width: element.outerWidth(true),
          359	                                height: element.outerHeight(true),
          360	                                'float': element.css('float')
          361	                        },
          362	                        wrapper = $('<div></div>')
          363	                                .addClass('ui-effects-wrapper')
          364	                                .css({
          365	                                        fontSize: '100%',
          366	                                        background: 'transparent',
          367	                                        border: 'none',
          368	                                        margin: 0,
          369	                                        padding: 0
          370	                                }),
          371	                        active = document.activeElement;
          372	
          373	                element.wrap(wrapper);
          374	
          375	                // Fixes #7595 - Elements lose focus when wrapped.
          376	                if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
          377	                        $( active ).focus();
          378	                }
          379	               
          380	                wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
          381	
          382	                // transfer positioning properties to the wrapper
          383	                if (element.css('position') == 'static') {
          384	                        wrapper.css({ position: 'relative' });
          385	                        element.css({ position: 'relative' });
          386	                } else {
          387	                        $.extend(props, {
          388	                                position: element.css('position'),
          389	                                zIndex: element.css('z-index')
          390	                        });
          391	                        $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
          392	                                props[pos] = element.css(pos);
          393	                                if (isNaN(parseInt(props[pos], 10))) {
          394	                                        props[pos] = 'auto';
          395	                                }
          396	                        });
          397	                        element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' });
          398	                }
          399	
          400	                return wrapper.css(props).show();
          401	        },
          402	
          403	        removeWrapper: function(element) {
          404	                var parent,
          405	                        active = document.activeElement;
          406	               
          407	                if (element.parent().is('.ui-effects-wrapper')) {
          408	                        parent = element.parent().replaceWith(element);
          409	                        // Fixes #7595 - Elements lose focus when wrapped.
          410	                        if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
          411	                                $( active ).focus();
          412	                        }
          413	                        return parent;
          414	                }
          415	                       
          416	                return element;
          417	        },
          418	
          419	        setTransition: function(element, list, factor, value) {
          420	                value = value || {};
          421	                $.each(list, function(i, x){
          422	                        var unit = element.cssUnit(x);
          423	                        if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
          424	                });
          425	                return value;
          426	        }
          427	});
          428	
          429	
          430	function _normalizeArguments(effect, options, speed, callback) {
          431	        // shift params for method overloading
          432	        if (typeof effect == 'object') {
          433	                callback = options;
          434	                speed = null;
          435	                options = effect;
          436	                effect = options.effect;
          437	        }
          438	        if ($.isFunction(options)) {
          439	                callback = options;
          440	                speed = null;
          441	                options = {};
          442	        }
          443	        if (typeof options == 'number' || $.fx.speeds[options]) {
          444	                callback = speed;
          445	                speed = options;
          446	                options = {};
          447	        }
          448	        if ($.isFunction(speed)) {
          449	                callback = speed;
          450	                speed = null;
          451	        }
          452	
          453	        options = options || {};
          454	
          455	        speed = speed || options.duration;
          456	        speed = $.fx.off ? 0 : typeof speed == 'number'
          457	                ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
          458	
          459	        callback = callback || options.complete;
          460	
          461	        return [effect, options, speed, callback];
          462	}
          463	
          464	function standardSpeed( speed ) {
          465	        // valid standard speeds
          466	        if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
          467	                return true;
          468	        }
          469	       
          470	        // invalid strings - treat as "normal" speed
          471	        if ( typeof speed === "string" && !$.effects[ speed ] ) {
          472	                return true;
          473	        }
          474	       
          475	        return false;
          476	}
          477	
          478	$.fn.extend({
          479	        effect: function(effect, options, speed, callback) {
          480	                var args = _normalizeArguments.apply(this, arguments),
          481	                        // TODO: make effects take actual parameters instead of a hash
          482	                        args2 = {
          483	                                options: args[1],
          484	                                duration: args[2],
          485	                                callback: args[3]
          486	                        },
          487	                        mode = args2.options.mode,
          488	                        effectMethod = $.effects[effect];
          489	               
          490	                if ( $.fx.off || !effectMethod ) {
          491	                        // delegate to the original method (e.g., .show()) if possible
          492	                        if ( mode ) {
          493	                                return this[ mode ]( args2.duration, args2.callback );
          494	                        } else {
          495	                                return this.each(function() {
          496	                                        if ( args2.callback ) {
          497	                                                args2.callback.call( this );
          498	                                        }
          499	                                });
          500	                        }
          501	                }
          502	               
          503	                return effectMethod.call(this, args2);
          504	        },
          505	
          506	        _show: $.fn.show,
          507	        show: function(speed) {
          508	                if ( standardSpeed( speed ) ) {
          509	                        return this._show.apply(this, arguments);
          510	                } else {
          511	                        var args = _normalizeArguments.apply(this, arguments);
          512	                        args[1].mode = 'show';
          513	                        return this.effect.apply(this, args);
          514	                }
          515	        },
          516	
          517	        _hide: $.fn.hide,
          518	        hide: function(speed) {
          519	                if ( standardSpeed( speed ) ) {
          520	                        return this._hide.apply(this, arguments);
          521	                } else {
          522	                        var args = _normalizeArguments.apply(this, arguments);
          523	                        args[1].mode = 'hide';
          524	                        return this.effect.apply(this, args);
          525	                }
          526	        },
          527	
          528	        // jQuery core overloads toggle and creates _toggle
          529	        __toggle: $.fn.toggle,
          530	        toggle: function(speed) {
          531	                if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
          532	                        return this.__toggle.apply(this, arguments);
          533	                } else {
          534	                        var args = _normalizeArguments.apply(this, arguments);
          535	                        args[1].mode = 'toggle';
          536	                        return this.effect.apply(this, args);
          537	                }
          538	        },
          539	
          540	        // helper functions
          541	        cssUnit: function(key) {
          542	                var style = this.css(key), val = [];
          543	                $.each( ['em','px','%','pt'], function(i, unit){
          544	                        if(style.indexOf(unit) > 0)
          545	                                val = [parseFloat(style), unit];
          546	                });
          547	                return val;
          548	        }
          549	});
          550	
          551	
          552	
          553	/******************************************************************************/
          554	/*********************************** EASING ***********************************/
          555	/******************************************************************************/
          556	
          557	/*
          558	 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
          559	 *
          560	 * Uses the built in easing capabilities added In jQuery 1.1
          561	 * to offer multiple easing options
          562	 *
          563	 * TERMS OF USE - jQuery Easing
          564	 *
          565	 * Open source under the BSD License.
          566	 *
          567	 * Copyright 2008 George McGinley Smith
          568	 * All rights reserved.
          569	 *
          570	 * Redistribution and use in source and binary forms, with or without modification,
          571	 * are permitted provided that the following conditions are met:
          572	 *
          573	 * Redistributions of source code must retain the above copyright notice, this list of
          574	 * conditions and the following disclaimer.
          575	 * Redistributions in binary form must reproduce the above copyright notice, this list
          576	 * of conditions and the following disclaimer in the documentation and/or other materials
          577	 * provided with the distribution.
          578	 *
          579	 * Neither the name of the author nor the names of contributors may be used to endorse
          580	 * or promote products derived from this software without specific prior written permission.
          581	 *
          582	 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
          583	 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
          584	 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
          585	 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
          586	 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
          587	 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
          588	 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
          589	 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
          590	 * OF THE POSSIBILITY OF SUCH DAMAGE.
          591	 *
          592	*/
          593	
          594	// t: current time, b: begInnIng value, c: change In value, d: duration
          595	$.easing.jswing = $.easing.swing;
          596	
          597	$.extend($.easing,
          598	{
          599	        def: 'easeOutQuad',
          600	        swing: function (x, t, b, c, d) {
          601	                //alert($.easing.default);
          602	                return $.easing[$.easing.def](x, t, b, c, d);
          603	        },
          604	        easeInQuad: function (x, t, b, c, d) {
          605	                return c*(t/=d)*t + b;
          606	        },
          607	        easeOutQuad: function (x, t, b, c, d) {
          608	                return -c *(t/=d)*(t-2) + b;
          609	        },
          610	        easeInOutQuad: function (x, t, b, c, d) {
          611	                if ((t/=d/2) < 1) return c/2*t*t + b;
          612	                return -c/2 * ((--t)*(t-2) - 1) + b;
          613	        },
          614	        easeInCubic: function (x, t, b, c, d) {
          615	                return c*(t/=d)*t*t + b;
          616	        },
          617	        easeOutCubic: function (x, t, b, c, d) {
          618	                return c*((t=t/d-1)*t*t + 1) + b;
          619	        },
          620	        easeInOutCubic: function (x, t, b, c, d) {
          621	                if ((t/=d/2) < 1) return c/2*t*t*t + b;
          622	                return c/2*((t-=2)*t*t + 2) + b;
          623	        },
          624	        easeInQuart: function (x, t, b, c, d) {
          625	                return c*(t/=d)*t*t*t + b;
          626	        },
          627	        easeOutQuart: function (x, t, b, c, d) {
          628	                return -c * ((t=t/d-1)*t*t*t - 1) + b;
          629	        },
          630	        easeInOutQuart: function (x, t, b, c, d) {
          631	                if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
          632	                return -c/2 * ((t-=2)*t*t*t - 2) + b;
          633	        },
          634	        easeInQuint: function (x, t, b, c, d) {
          635	                return c*(t/=d)*t*t*t*t + b;
          636	        },
          637	        easeOutQuint: function (x, t, b, c, d) {
          638	                return c*((t=t/d-1)*t*t*t*t + 1) + b;
          639	        },
          640	        easeInOutQuint: function (x, t, b, c, d) {
          641	                if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
          642	                return c/2*((t-=2)*t*t*t*t + 2) + b;
          643	        },
          644	        easeInSine: function (x, t, b, c, d) {
          645	                return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
          646	        },
          647	        easeOutSine: function (x, t, b, c, d) {
          648	                return c * Math.sin(t/d * (Math.PI/2)) + b;
          649	        },
          650	        easeInOutSine: function (x, t, b, c, d) {
          651	                return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
          652	        },
          653	        easeInExpo: function (x, t, b, c, d) {
          654	                return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
          655	        },
          656	        easeOutExpo: function (x, t, b, c, d) {
          657	                return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
          658	        },
          659	        easeInOutExpo: function (x, t, b, c, d) {
          660	                if (t==0) return b;
          661	                if (t==d) return b+c;
          662	                if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
          663	                return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
          664	        },
          665	        easeInCirc: function (x, t, b, c, d) {
          666	                return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
          667	        },
          668	        easeOutCirc: function (x, t, b, c, d) {
          669	                return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
          670	        },
          671	        easeInOutCirc: function (x, t, b, c, d) {
          672	                if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
          673	                return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
          674	        },
          675	        easeInElastic: function (x, t, b, c, d) {
          676	                var s=1.70158;var p=0;var a=c;
          677	                if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
          678	                if (a < Math.abs(c)) { a=c; var s=p/4; }
          679	                else var s = p/(2*Math.PI) * Math.asin (c/a);
          680	                return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
          681	        },
          682	        easeOutElastic: function (x, t, b, c, d) {
          683	                var s=1.70158;var p=0;var a=c;
          684	                if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
          685	                if (a < Math.abs(c)) { a=c; var s=p/4; }
          686	                else var s = p/(2*Math.PI) * Math.asin (c/a);
          687	                return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
          688	        },
          689	        easeInOutElastic: function (x, t, b, c, d) {
          690	                var s=1.70158;var p=0;var a=c;
          691	                if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
          692	                if (a < Math.abs(c)) { a=c; var s=p/4; }
          693	                else var s = p/(2*Math.PI) * Math.asin (c/a);
          694	                if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
          695	                return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
          696	        },
          697	        easeInBack: function (x, t, b, c, d, s) {
          698	                if (s == undefined) s = 1.70158;
          699	                return c*(t/=d)*t*((s+1)*t - s) + b;
          700	        },
          701	        easeOutBack: function (x, t, b, c, d, s) {
          702	                if (s == undefined) s = 1.70158;
          703	                return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
          704	        },
          705	        easeInOutBack: function (x, t, b, c, d, s) {
          706	                if (s == undefined) s = 1.70158;
          707	                if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
          708	                return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
          709	        },
          710	        easeInBounce: function (x, t, b, c, d) {
          711	                return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
          712	        },
          713	        easeOutBounce: function (x, t, b, c, d) {
          714	                if ((t/=d) < (1/2.75)) {
          715	                        return c*(7.5625*t*t) + b;
          716	                } else if (t < (2/2.75)) {
          717	                        return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
          718	                } else if (t < (2.5/2.75)) {
          719	                        return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
          720	                } else {
          721	                        return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
          722	                }
          723	        },
          724	        easeInOutBounce: function (x, t, b, c, d) {
          725	                if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
          726	                return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
          727	        }
          728	});
          729	
          730	/*
          731	 *
          732	 * TERMS OF USE - EASING EQUATIONS
          733	 *
          734	 * Open source under the BSD License.
          735	 *
          736	 * Copyright 2001 Robert Penner
          737	 * All rights reserved.
          738	 *
          739	 * Redistribution and use in source and binary forms, with or without modification,
          740	 * are permitted provided that the following conditions are met:
          741	 *
          742	 * Redistributions of source code must retain the above copyright notice, this list of
          743	 * conditions and the following disclaimer.
          744	 * Redistributions in binary form must reproduce the above copyright notice, this list
          745	 * of conditions and the following disclaimer in the documentation and/or other materials
          746	 * provided with the distribution.
          747	 *
          748	 * Neither the name of the author nor the names of contributors may be used to endorse
          749	 * or promote products derived from this software without specific prior written permission.
          750	 *
          751	 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
          752	 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
          753	 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
          754	 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
          755	 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
          756	 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
          757	 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
          758	 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
          759	 * OF THE POSSIBILITY OF SUCH DAMAGE.
          760	 *
          761	 */
          762	
          763	})(jQuery);
        3. WordPress源代码——jquery-ui(1.8.20——jquery.effects.clip.js)

          WordPress源代码——jquery-ui(1.8.20——jquery.effects.clip.js)

          1	/*!
          2	 * jQuery UI Effects Clip @VERSION
          3	 *
          4	 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
          5	 * Dual licensed under the MIT or GPL Version 2 licenses.
          6	 * http://jquery.org/license
          7	 *
          8	 * http://docs.jquery.com/UI/Effects/Clip
          9	 *
          10	 * Depends:
          11	 *      jquery.effects.core.js
          12	 */
          13	(function( $, undefined ) {
          14	
          15	$.effects.clip = function(o) {
          16	
          17	        return this.queue(function() {
          18	
          19	                // Create element
          20	                var el = $(this), props = ['position','top','bottom','left','right','height','width'];
          21	
          22	                // Set options
          23	                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
          24	                var direction = o.options.direction || 'vertical'; // Default direction
          25	
          26	                // Adjust
          27	                $.effects.save(el, props); el.show(); // Save & Show
          28	                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
          29	                var animate = el[0].tagName == 'IMG' ? wrapper : el;
          30	                var ref = {
          31	                        size: (direction == 'vertical') ? 'height' : 'width',
          32	                        position: (direction == 'vertical') ? 'top' : 'left'
          33	                };
          34	                var distance = (direction == 'vertical') ? animate.height() : animate.width();
          35	                if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
          36	
          37	                // Animation
          38	                var animation = {};
          39	                animation[ref.size] = mode == 'show' ? distance : 0;
          40	                animation[ref.position] = mode == 'show' ? 0 : distance / 2;
          41	
          42	                // Animate
          43	                animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
          44	                        if(mode == 'hide') el.hide(); // Hide
          45	                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
          46	                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
          47	                        el.dequeue();
          48	                }});
          49	
          50	        });
          51	
          52	};
          53	
          54	})(jQuery);
        4. WordPress源代码——jquery-ui(1.8.20——jquery.effects.bounce.js)

          WordPress源代码——jquery-ui(1.8.20——jquery.effects.bounce.js)

          1	/*!
          2	 * jQuery UI Effects Bounce @VERSION
          3	 *
          4	 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
          5	 * Dual licensed under the MIT or GPL Version 2 licenses.
          6	 * http://jquery.org/license
          7	 *
          8	 * http://docs.jquery.com/UI/Effects/Bounce
          9	 *
          10	 * Depends:
          11	 *      jquery.effects.core.js
          12	 */
          13	(function( $, undefined ) {
          14	
          15	$.effects.bounce = function(o) {
          16	
          17	        return this.queue(function() {
          18	
          19	                // Create element
          20	                var el = $(this), props = ['position','top','bottom','left','right'];
          21	
          22	                // Set options
          23	                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
          24	                var direction = o.options.direction || 'up'; // Default direction
          25	                var distance = o.options.distance || 20; // Default distance
          26	                var times = o.options.times || 5; // Default # of times
          27	                var speed = o.duration || 250; // Default speed per bounce
          28	                if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
          29	
          30	                // Adjust
          31	                $.effects.save(el, props); el.show(); // Save & Show
          32	                $.effects.createWrapper(el); // Create Wrapper
          33	                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
          34	                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
          35	                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
          36	                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
          37	                if (mode == 'hide') distance = distance / (times * 2);
          38	                if (mode != 'hide') times--;
          39	
          40	                // Animate
          41	                if (mode == 'show') { // Show Bounce
          42	                        var animation = {opacity: 1};
          43	                        animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
          44	                        el.animate(animation, speed / 2, o.options.easing);
          45	                        distance = distance / 2;
          46	                        times--;
          47	                };
          48	                for (var i = 0; i < times; i++) { // Bounces
          49	                        var animation1 = {}, animation2 = {};
          50	                        animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
          51	                        animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
          52	                        el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
          53	                        distance = (mode == 'hide') ? distance * 2 : distance / 2;
          54	                };
          55	                if (mode == 'hide') { // Last Bounce
          56	                        var animation = {opacity: 0};
          57	                        animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
          58	                        el.animate(animation, speed / 2, o.options.easing, function(){
          59	                                el.hide(); // Hide
          60	                                $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
          61	                                if(o.callback) o.callback.apply(this, arguments); // Callback
          62	                        });
          63	                } else {
          64	                        var animation1 = {}, animation2 = {};
          65	                        animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
          66	                        animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
          67	                        el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
          68	                                $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
          69	                                if(o.callback) o.callback.apply(this, arguments); // Callback
          70	                        });
          71	                };
          72	                el.queue('fx', function() { el.dequeue(); });
          73	                el.dequeue();
          74	        });
          75	
          76	};
          77	
          78	})(jQuery);
          
        5. WordPress源代码——jquery-ui(1.8.20——jquery.effects.blind.js)

          WordPress源代码——jquery-ui(1.8.20——jquery.effects.blind.js)

          1	/*!
          2	 * jQuery UI Effects Blind @VERSION
          3	 *
          4	 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
          5	 * Dual licensed under the MIT or GPL Version 2 licenses.
          6	 * http://jquery.org/license
          7	 *
          8	 * http://docs.jquery.com/UI/Effects/Blind
          9	 *
          10	 * Depends:
          11	 *      jquery.effects.core.js
          12	 */
          13	(function( $, undefined ) {
          14	
          15	$.effects.blind = function(o) {
          16	
          17	        return this.queue(function() {
          18	
          19	                // Create element
          20	                var el = $(this), props = ['position','top','bottom','left','right'];
          21	
          22	                // Set options
          23	                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
          24	                var direction = o.options.direction || 'vertical'; // Default direction
          25	
          26	                // Adjust
          27	                $.effects.save(el, props); el.show(); // Save & Show
          28	                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
          29	                var ref = (direction == 'vertical') ? 'height' : 'width';
          30	                var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
          31	                if(mode == 'show') wrapper.css(ref, 0); // Shift
          32	
          33	                // Animation
          34	                var animation = {};
          35	                animation[ref] = mode == 'show' ? distance : 0;
          36	
          37	                // Animate
          38	                wrapper.animate(animation, o.duration, o.options.easing, function() {
          39	                        if(mode == 'hide') el.hide(); // Hide
          40	                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
          41	                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
          42	                        el.dequeue();
          43	                });
          44	
          45	        });
          46	
          47	};
          48	
          49	})(jQuery);
        6. WordPress源代码——jquery-plugins(jquery.ui.touch-punch.js)

          WordPress源代码——jquery-plugins(jquery.ui.touch-punch.js)

          1	/*!
          2	 * jQuery UI Touch Punch 0.2.2
          3	 *
          4	 * Copyright 2011, Dave Furfero
          5	 * Dual licensed under the MIT or GPL Version 2 licenses.
          6	 *
          7	 * Depends:
          8	 *  jquery.ui.widget.js
          9	 *  jquery.ui.mouse.js
          10	 */
          11	(function ($) {
          12	
          13	  // Detect touch support
          14	  $.support.touch = 'ontouchend' in document;
          15	
          16	  // Ignore browsers without touch support
          17	  if (!$.support.touch) {
          18	    return;
          19	  }
          20	
          21	  var mouseProto = $.ui.mouse.prototype,
          22	      _mouseInit = mouseProto._mouseInit,
          23	      touchHandled;
          24	
          25	  /**
          26	   * Simulate a mouse event based on a corresponding touch event
          27	   * @param {Object} event A touch event
          28	   * @param {String} simulatedType The corresponding mouse event
          29	   */
          30	  function simulateMouseEvent (event, simulatedType) {
          31	
          32	    // Ignore multi-touch events
          33	    if (event.originalEvent.touches.length > 1) {
          34	      return;
          35	    }
          36	
          37	    event.preventDefault();
          38	
          39	    var touch = event.originalEvent.changedTouches[0],
          40	        simulatedEvent = document.createEvent('MouseEvents');
          41	   
          42	    // Initialize the simulated mouse event using the touch event's coordinates
          43	    simulatedEvent.initMouseEvent(
          44	      simulatedType,    // type
          45	      true,             // bubbles                   
          46	      true,             // cancelable                 
          47	      window,           // view                       
          48	      1,                // detail                     
          49	      touch.screenX,    // screenX                   
          50	      touch.screenY,    // screenY                   
          51	      touch.clientX,    // clientX                   
          52	      touch.clientY,    // clientY                   
          53	      false,            // ctrlKey                   
          54	      false,            // altKey                     
          55	      false,            // shiftKey                   
          56	      false,            // metaKey                   
          57	      0,                // button                     
          58	      null              // relatedTarget             
          59	    );
          60	
          61	    // Dispatch the simulated event to the target element
          62	    event.target.dispatchEvent(simulatedEvent);
          63	  }
          64	
          65	  /**
          66	   * Handle the jQuery UI widget's touchstart events
          67	   * @param {Object} event The widget element's touchstart event
          68	   */
          69	  mouseProto._touchStart = function (event) {
          70	
          71	    var self = this;
          72	
          73	    // Ignore the event if another widget is already being handled
          74	    if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) {
          75	      return;
          76	    }
          77	
          78	    // Set the flag to prevent other widgets from inheriting the touch event
          79	    touchHandled = true;
          80	
          81	    // Track movement to determine if interaction was a click
          82	    self._touchMoved = false;
          83	
          84	    // Simulate the mouseover event
          85	    simulateMouseEvent(event, 'mouseover');
          86	
          87	    // Simulate the mousemove event
          88	    simulateMouseEvent(event, 'mousemove');
          89	
          90	    // Simulate the mousedown event
          91	    simulateMouseEvent(event, 'mousedown');
          92	  };
          93	
          94	  /**
          95	   * Handle the jQuery UI widget's touchmove events
          96	   * @param {Object} event The document's touchmove event
          97	   */
          98	  mouseProto._touchMove = function (event) {
          99	
          100	    // Ignore event if not handled
          101	    if (!touchHandled) {
          102	      return;
          103	    }
          104	
          105	    // Interaction was not a click
          106	    this._touchMoved = true;
          107	
          108	    // Simulate the mousemove event
          109	    simulateMouseEvent(event, 'mousemove');
          110	  };
          111	
          112	  /**
          113	   * Handle the jQuery UI widget's touchend events
          114	   * @param {Object} event The document's touchend event
          115	   */
          116	  mouseProto._touchEnd = function (event) {
          117	
          118	    // Ignore event if not handled
          119	    if (!touchHandled) {
          120	      return;
          121	    }
          122	
          123	    // Simulate the mouseup event
          124	    simulateMouseEvent(event, 'mouseup');
          125	
          126	    // Simulate the mouseout event
          127	    simulateMouseEvent(event, 'mouseout');
          128	
          129	    // If the touch interaction did not move, it should trigger a click
          130	    if (!this._touchMoved) {
          131	
          132	      // Simulate the click event
          133	      simulateMouseEvent(event, 'click');
          134	    }
          135	
          136	    // Unset the flag to allow other widgets to inherit the touch event
          137	    touchHandled = false;
          138	  };
          139	
          140	  /**
          141	   * A duck punch of the $.ui.mouse _mouseInit method to support touch events.
          142	   * This method extends the widget with bound touch event handlers that
          143	   * translate touch events to mouse events and pass them to the widget's
          144	   * original mouse event handling methods.
          145	   */
          146	  mouseProto._mouseInit = function () {
          147	   
          148	    var self = this;
          149	
          150	    // Delegate the touch handlers to the widget's element
          151	    self.element
          152	      .bind('touchstart', $.proxy(self, '_touchStart'))
          153	      .bind('touchmove', $.proxy(self, '_touchMove'))
          154	      .bind('touchend', $.proxy(self, '_touchEnd'));
          155	
          156	    // Call the original $.ui.mouse init method
          157	    _mouseInit.call(self);
          158	  };
          159	
          160	})(jQuery);
        7. WordPress源代码——jquery-plugins(jquery.schedule.js)

          WordPress源代码——jquery-plugins(jquery.schedule.js)

          1	/*
          2	**  jquery.schedule.js -- jQuery plugin for scheduled/deferred actions
          3	**  Copyright (c) 2007 Ralf S. Engelschall <rse@engelschall.com>
          4	**  Licensed under GPL <http://www.gnu.org/licenses/gpl.txt>
          5	**
          6	**  $LastChangedDate$
          7	**  $LastChangedRevision$
          8	*/
          9	
          10	/*
          11	 *  <div id="button">TEST BUTTON</div>
          12	 *  <div id="test"></div>
          13	 *
          14	 *  <script type="text/javascript">
          15	 *     $(document).ready(
          16	 *     function(){
          17	 *         $('#button').click(function () {
          18	 *             $(this).css("color", "blue").schedule(2000, function (x) {
          19	 *                 $(this).css("color", "red");
          20	 *                 $("#test").html("test: x = " + x);
          21	 *             }, 42);
          22	 *         });
          23	 *     });
          24	 *  </script>
          25	 */
          26	
          27	(function($) {
          28	
          29	    /*  object constructor  */
          30	    $.scheduler = function () {
          31	        this.bucket = {};
          32	        return;
          33	    };
          34	
          35	    /*  object methods  */
          36	    $.scheduler.prototype = {
          37	        /*  schedule a task  */
          38	        schedule: function () {
          39	            /*  schedule context with default parameters */
          40	            var ctx = {
          41	                "id":         null,         /* unique identifier of high-level schedule */
          42	                "time":       1000,         /* time in milliseconds after which the task is run */
          43	                "repeat":     false,        /* whether schedule should be automatically repeated */
          44	                "protect":    false,        /* whether schedule should be protected from double scheduling */
          45	                "obj":        null,         /* function context object ("this") */
          46	                "func":       function(){}, /* function to call */
          47	                "args":       []            /* function arguments to pass */
          48	            };
          49	
          50	            /*  helper function: portable checking whether something is a function  */
          51	            function _isfn (fn) {
          52	                return (
          53	                       !!fn
          54	                    && typeof fn != "string"
          55	                    && typeof fn[0] == "undefined"
          56	                    && RegExp("function", "i").test(fn + "")
          57	                );
          58	            };
          59	           
          60	            /*  parse arguments into context parameters (part 1/4):
          61	                detect an override object (special case to support jQuery method) */
          62	            var i = 0;
          63	            var override = false;
          64	            if (typeof arguments[i] == "object" && arguments.length > 1) {
          65	                override = true;
          66	                i++;
          67	            }
          68	
          69	            /*  parse arguments into context parameters (part 2/4):
          70	                support the flexible way of an associated array */
          71	            if (typeof arguments[i] == "object") {
          72	                for (var option in arguments[i])
          73	                    if (typeof ctx[option] != "undefined")
          74	                        ctx[option] = arguments[i][option];
          75	                i++;
          76	            }
          77	
          78	            /*  parse arguments into context parameters (part 3/4):
          79	                support: schedule([time [, repeat], ]{{obj, methodname} | func}[, arg, ...]); */
          80	            if (   typeof arguments[i] == "number"
          81	                || (   typeof arguments[i] == "string" 
          82	                    && arguments[i].match(RegExp("^[0-9]+[smhdw]$"))))
          83	                ctx["time"] = arguments[i++];
          84	            if (typeof arguments[i] == "boolean")
          85	                ctx["repeat"] = arguments[i++];
          86	            if (typeof arguments[i] == "boolean")
          87	                ctx["protect"] = arguments[i++];
          88	            if (   typeof arguments[i] == "object"
          89	                && typeof arguments[i+1] == "string"
          90	                && _isfn(arguments[i][arguments[i+1]])) {
          91	                ctx["obj"] = arguments[i++];
          92	                ctx["func"] = arguments[i++];
          93	            }
          94	            else if (   typeof arguments[i] != "undefined"
          95	                     && (   _isfn(arguments[i]) 
          96	                         || typeof arguments[i] == "string"))
          97	                ctx["func"] = arguments[i++];
          98	            while (typeof arguments[i] != "undefined")
          99	                ctx["args"].push(arguments[i++]);
          100	
          101	            /*  parse arguments into context parameters (part 4/4):
          102	                apply parameters from override object */
          103	            if (override) {
          104	                if (typeof arguments[1] == "object") {
          105	                    for (var option in arguments[0])
          106	                        if (   typeof ctx[option] != "undefined"
          107	                            && typeof arguments[1][option] == "undefined")
          108	                            ctx[option] = arguments[0][option];
          109	                }
          110	                else {
          111	                    for (var option in arguments[0])
          112	                        if (typeof ctx[option] != "undefined")
          113	                            ctx[option] = arguments[0][option];
          114	                }
          115	                i++;
          116	            }
          117	
          118	            /*  annotate context with internals */
          119	            ctx["_scheduler"] = this; /* internal: back-reference to scheduler object */
          120	            ctx["_handle"]    = null; /* internal: unique handle of low-level task */
          121	
          122	            /*  determine time value in milliseconds */
          123	            var match = String(ctx["time"]).match(RegExp("^([0-9]+)([smhdw])$"));
          124	            if (match && match[0] != "undefined" && match[1] != "undefined")
          125	                ctx["time"] = String(parseInt(match[1]) *
          126	                    { s: 1000, m: 1000*60, h: 1000*60*60,
          127	                      d: 1000*60*60*24, w: 1000*60*60*24*7 }[match[2]]);
          128	
          129	            /*  determine unique identifier of task  */
          130	            if (ctx["id"] == null)
          131	                ctx["id"] = (  String(ctx["repeat"])  + ":"
          132	                             + String(ctx["protect"]) + ":"
          133	                             + String(ctx["time"])    + ":"
          134	                             + String(ctx["obj"])     + ":"
          135	                             + String(ctx["func"])    + ":"
          136	                             + String(ctx["args"])         );
          137	
          138	            /*  optionally protect from duplicate calls  */
          139	            if (ctx["protect"])
          140	                if (typeof this.bucket[ctx["id"]] != "undefined")
          141	                    return this.bucket[ctx["id"]];
          142	
          143	            /*  support execution of methods by name and arbitrary scripts  */
          144	            if (!_isfn(ctx["func"])) {
          145	                if (   ctx["obj"] != null
          146	                    && typeof ctx["obj"] == "object"
          147	                    && typeof ctx["func"] == "string"
          148	                    && _isfn(ctx["obj"][ctx["func"]]))
          149	                    /*  method by name  */
          150	                    ctx["func"] = ctx["obj"][ctx["func"]];
          151	                else
          152	                    /*  arbitrary script  */
          153	                    ctx["func"] = eval("function () { " + ctx["func"] + " }");
          154	            }
          155	
          156	            /*  pass-through to internal scheduling operation  */
          157	            ctx["_handle"] = this._schedule(ctx);
          158	
          159	            /*  store context into bucket of scheduler object  */
          160	            this.bucket[ctx["id"]] = ctx;
          161	
          162	            /*  return context  */
          163	            return ctx;
          164	        },
          165	
          166	        /*  re-schedule a task  */
          167	        reschedule: function (ctx) {
          168	            if (typeof ctx == "string")
          169	                ctx = this.bucket[ctx];
          170	
          171	            /*  pass-through to internal scheduling operation  */
          172	            ctx["_handle"] = this._schedule(ctx);
          173	
          174	            /*  return context  */
          175	            return ctx;
          176	        },
          177	
          178	        /*  internal scheduling operation  */
          179	        _schedule: function (ctx) {
          180	            /*  closure to act as the call trampoline function  */
          181	            var trampoline = function () {
          182	                /*  jump into function  */
          183	                var obj = (ctx["obj"] != null ? ctx["obj"] : ctx);
          184	                (ctx["func"]).apply(obj, ctx["args"]);
          185	
          186	                /*  either repeat scheduling and keep in bucket or
          187	                    just stop scheduling and delete from scheduler bucket  */
          188	                if (   /* not cancelled from inside... */
          189	                       typeof (ctx["_scheduler"]).bucket[ctx["id"]] != "undefined"
          190	                    && /* ...and repeating requested */
          191	                       ctx["repeat"])
          192	                    (ctx["_scheduler"])._schedule(ctx);
          193	                else
          194	                    delete (ctx["_scheduler"]).bucket[ctx["id"]];
          195	            };
          196	
          197	            /*  schedule task and return handle  */
          198	            return setTimeout(trampoline, ctx["time"]);
          199	        },
          200	
          201	        /*  cancel a scheduled task  */
          202	        cancel: function (ctx) {
          203	            if (typeof ctx == "string")
          204	                ctx = this.bucket[ctx];
          205	
          206	            /*  cancel scheduled task  */
          207	            if (typeof ctx == "object") {
          208	                clearTimeout(ctx["_handle"]);
          209	                delete this.bucket[ctx["id"]];
          210	            }
          211	        }
          212	    };
          213	
          214	    /* integrate a global instance of the scheduler into the global jQuery object */
          215	    $.extend({
          216	        scheduler$: new $.scheduler(),
          217	        schedule:   function () { return $.scheduler$.schedule.apply  ($.scheduler$, arguments) },
          218	        reschedule: function () { return $.scheduler$.reschedule.apply($.scheduler$, arguments) },
          219	        cancel:     function () { return $.scheduler$.cancel.apply    ($.scheduler$, arguments) }
          220	    });
          221	
          222	    /* integrate scheduling convinience method into all jQuery objects */
          223	    $.fn.extend({
          224	        schedule: function () {
          225	            var a = [ {} ];
          226	            for (var i = 0; i < arguments.length; i++)
          227	                a.push(arguments[i]);
          228	            return this.each(function () {
          229	                a[0] = { "id": this, "obj": this };
          230	                return $.schedule.apply($, a);
          231	            });
          232	        }
          233	    });
          234	
          235	})(jQuery);
          236	
          237	/*
          238	**  jquery.schedule.js -- jQuery plugin for scheduled/deferred actions
          239	**  Copyright (c) 2007 Ralf S. Engelschall <rse@engelschall.com>
          240	**  Licensed under GPL <http://www.gnu.org/licenses/gpl.txt>
          241	**
          242	**  $LastChangedDate$
          243	**  $LastChangedRevision$
          244	*/
          245	
          246	/*
          247	 *  <div id="button">TEST BUTTON</div>
          248	 *  <div id="test"></div>
          249	 *
          250	 *  <script type="text/javascript">
          251	 *     $(document).ready(
          252	 *     function(){
          253	 *         $('#button').click(function () {
          254	 *             $(this).css("color", "blue").schedule(2000, function (x) {
          255	 *                 $(this).css("color", "red");
          256	 *                 $("#test").html("test: x = " + x);
          257	 *             }, 42);
          258	 *         });
          259	 *     });
          260	 *  </script>
          261	 */
          262	
          263	(function($) {
          264	
          265	    /*  object constructor  */
          266	    $.scheduler = function () {
          267	        this.bucket = {};
          268	        return;
          269	    };
          270	
          271	    /*  object methods  */
          272	    $.scheduler.prototype = {
          273	        /*  schedule a task  */
          274	        schedule: function () {
          275	            /*  schedule context with default parameters */
          276	            var ctx = {
          277	                "id":         null,         /* unique identifier of high-level schedule */
          278	                "time":       1000,         /* time in milliseconds after which the task is run */
          279	                "repeat":     false,        /* whether schedule should be automatically repeated */
          280	                "protect":    false,        /* whether schedule should be protected from double scheduling */
          281	                "obj":        null,         /* function context object ("this") */
          282	                "func":       function(){}, /* function to call */
          283	                "args":       []            /* function arguments to pass */
          284	            };
          285	
          286	            /*  helper function: portable checking whether something is a function  */
          287	            function _isfn (fn) {
          288	                return (
          289	                       !!fn
          290	                    && typeof fn != "string"
          291	                    && typeof fn[0] == "undefined"
          292	                    && RegExp("function", "i").test(fn + "")
          293	                );
          294	            };
          295	           
          296	            /*  parse arguments into context parameters (part 1/4):
          297	                detect an override object (special case to support jQuery method) */
          298	            var i = 0;
          299	            var override = false;
          300	            if (typeof arguments[i] == "object" && arguments.length > 1) {
          301	                override = true;
          302	                i++;
          303	            }
          304	
          305	            /*  parse arguments into context parameters (part 2/4):
          306	                support the flexible way of an associated array */
          307	            if (typeof arguments[i] == "object") {
          308	                for (var option in arguments[i])
          309	                    if (typeof ctx[option] != "undefined")
          310	                        ctx[option] = arguments[i][option];
          311	                i++;
          312	            }
          313	
          314	            /*  parse arguments into context parameters (part 3/4):
          315	                support: schedule([time [, repeat], ]{{obj, methodname} | func}[, arg, ...]); */
          316	            if (   typeof arguments[i] == "number"
          317	                || (   typeof arguments[i] == "string" 
          318	                    && arguments[i].match(RegExp("^[0-9]+[smhdw]$"))))
          319	                ctx["time"] = arguments[i++];
          320	            if (typeof arguments[i] == "boolean")
          321	                ctx["repeat"] = arguments[i++];
          322	            if (typeof arguments[i] == "boolean")
          323	                ctx["protect"] = arguments[i++];
          324	            if (   typeof arguments[i] == "object"
          325	                && typeof arguments[i+1] == "string"
          326	                && _isfn(arguments[i][arguments[i+1]])) {
          327	                ctx["obj"] = arguments[i++];
          328	                ctx["func"] = arguments[i++];
          329	            }
          330	            else if (   typeof arguments[i] != "undefined"
          331	                     && (   _isfn(arguments[i]) 
          332	                         || typeof arguments[i] == "string"))
          333	                ctx["func"] = arguments[i++];
          334	            while (typeof arguments[i] != "undefined")
          335	                ctx["args"].push(arguments[i++]);
          336	
          337	            /*  parse arguments into context parameters (part 4/4):
          338	                apply parameters from override object */
          339	            if (override) {
          340	                if (typeof arguments[1] == "object") {
          341	                    for (var option in arguments[0])
          342	                        if (   typeof ctx[option] != "undefined"
          343	                            && typeof arguments[1][option] == "undefined")
          344	                            ctx[option] = arguments[0][option];
          345	                }
          346	                else {
          347	                    for (var option in arguments[0])
          348	                        if (typeof ctx[option] != "undefined")
          349	                            ctx[option] = arguments[0][option];
          350	                }
          351	                i++;
          352	            }
          353	
          354	            /*  annotate context with internals */
          355	            ctx["_scheduler"] = this; /* internal: back-reference to scheduler object */
          356	            ctx["_handle"]    = null; /* internal: unique handle of low-level task */
          357	
          358	            /*  determine time value in milliseconds */
          359	            var match = String(ctx["time"]).match(RegExp("^([0-9]+)([smhdw])$"));
          360	            if (match && match[0] != "undefined" && match[1] != "undefined")
          361	                ctx["time"] = String(parseInt(match[1]) *
          362	                    { s: 1000, m: 1000*60, h: 1000*60*60,
          363	                      d: 1000*60*60*24, w: 1000*60*60*24*7 }[match[2]]);
          364	
          365	            /*  determine unique identifier of task  */
          366	            if (ctx["id"] == null)
          367	                ctx["id"] = (  String(ctx["repeat"])  + ":"
          368	                             + String(ctx["protect"]) + ":"
          369	                             + String(ctx["time"])    + ":"
          370	                             + String(ctx["obj"])     + ":"
          371	                             + String(ctx["func"])    + ":"
          372	                             + String(ctx["args"])         );
          373	
          374	            /*  optionally protect from duplicate calls  */
          375	            if (ctx["protect"])
          376	                if (typeof this.bucket[ctx["id"]] != "undefined")
          377	                    return this.bucket[ctx["id"]];
          378	
          379	            /*  support execution of methods by name and arbitrary scripts  */
          380	            if (!_isfn(ctx["func"])) {
          381	                if (   ctx["obj"] != null
          382	                    && typeof ctx["obj"] == "object"
          383	                    && typeof ctx["func"] == "string"
          384	                    && _isfn(ctx["obj"][ctx["func"]]))
          385	                    /*  method by name  */
          386	                    ctx["func"] = ctx["obj"][ctx["func"]];
          387	                else
          388	                    /*  arbitrary script  */
          389	                    ctx["func"] = eval("function () { " + ctx["func"] + " }");
          390	            }
          391	
          392	            /*  pass-through to internal scheduling operation  */
          393	            ctx["_handle"] = this._schedule(ctx);
          394	
          395	            /*  store context into bucket of scheduler object  */
          396	            this.bucket[ctx["id"]] = ctx;
          397	
          398	            /*  return context  */
          399	            return ctx;
          400	        },
          401	
          402	        /*  re-schedule a task  */
          403	        reschedule: function (ctx) {
          404	            if (typeof ctx == "string")
          405	                ctx = this.bucket[ctx];
          406	
          407	            /*  pass-through to internal scheduling operation  */
          408	            ctx["_handle"] = this._schedule(ctx);
          409	
          410	            /*  return context  */
          411	            return ctx;
          412	        },
          413	
          414	        /*  internal scheduling operation  */
          415	        _schedule: function (ctx) {
          416	            /*  closure to act as the call trampoline function  */
          417	            var trampoline = function () {
          418	                /*  jump into function  */
          419	                var obj = (ctx["obj"] != null ? ctx["obj"] : ctx);
          420	                (ctx["func"]).apply(obj, ctx["args"]);
          421	
          422	                /*  either repeat scheduling and keep in bucket or
          423	                    just stop scheduling and delete from scheduler bucket  */
          424	                if (   /* not cancelled from inside... */
          425	                       typeof (ctx["_scheduler"]).bucket[ctx["id"]] != "undefined"
          426	                    && /* ...and repeating requested */
          427	                       ctx["repeat"])
          428	                    (ctx["_scheduler"])._schedule(ctx);
          429	                else
          430	                    delete (ctx["_scheduler"]).bucket[ctx["id"]];
          431	            };
          432	
          433	            /*  schedule task and return handle  */
          434	            return setTimeout(trampoline, ctx["time"]);
          435	        },
          436	
          437	        /*  cancel a scheduled task  */
          438	        cancel: function (ctx) {
          439	            if (typeof ctx == "string")
          440	                ctx = this.bucket[ctx];
          441	
          442	            /*  cancel scheduled task  */
          443	            if (typeof ctx == "object") {
          444	                clearTimeout(ctx["_handle"]);
          445	                delete this.bucket[ctx["id"]];
          446	            }
          447	        }
          448	    };
          449	
          450	    /* integrate a global instance of the scheduler into the global jQuery object */
          451	    $.extend({
          452	        scheduler$: new $.scheduler(),
          453	        schedule:   function () { return $.scheduler$.schedule.apply  ($.scheduler$, arguments) },
          454	        reschedule: function () { return $.scheduler$.reschedule.apply($.scheduler$, arguments) },
          455	        cancel:     function () { return $.scheduler$.cancel.apply    ($.scheduler$, arguments) }
          456	    });
          457	
          458	    /* integrate scheduling convinience method into all jQuery objects */
          459	    $.fn.extend({
          460	        schedule: function () {
          461	            var a = [ {} ];
          462	            for (var i = 0; i < arguments.length; i++)
          463	                a.push(arguments[i]);
          464	            return this.each(function () {
          465	                a[0] = { "id": this, "obj": this };
          466	                return $.schedule.apply($, a);
          467	            });
          468	        }
          469	    });
          470	
          471	})(jQuery);
          472	
          473	/*
          474	**  jquery.schedule.js -- jQuery plugin for scheduled/deferred actions
          475	**  Copyright (c) 2007 Ralf S. Engelschall <rse@engelschall.com>
          476	**  Licensed under GPL <http://www.gnu.org/licenses/gpl.txt>
          477	**
          478	**  $LastChangedDate$
          479	**  $LastChangedRevision$
          480	*/
          481	
          482	/*
          483	 *  <div id="button">TEST BUTTON</div>
          484	 *  <div id="test"></div>
          485	 *
          486	 *  <script type="text/javascript">
          487	 *     $(document).ready(
          488	 *     function(){
          489	 *         $('#button').click(function () {
          490	 *             $(this).css("color", "blue").schedule(2000, function (x) {
          491	 *                 $(this).css("color", "red");
          492	 *                 $("#test").html("test: x = " + x);
          493	 *             }, 42);
          494	 *         });
          495	 *     });
          496	 *  </script>
          497	 */
          498	
          499	(function($) {
          500	
          501	    /*  object constructor  */
          502	    $.scheduler = function () {
          503	        this.bucket = {};
          504	        return;
          505	    };
          506	
          507	    /*  object methods  */
          508	    $.scheduler.prototype = {
          509	        /*  schedule a task  */
          510	        schedule: function () {
          511	            /*  schedule context with default parameters */
          512	            var ctx = {
          513	                "id":         null,         /* unique identifier of high-level schedule */
          514	                "time":       1000,         /* time in milliseconds after which the task is run */
          515	                "repeat":     false,        /* whether schedule should be automatically repeated */
          516	                "protect":    false,        /* whether schedule should be protected from double scheduling */
          517	                "obj":        null,         /* function context object ("this") */
          518	                "func":       function(){}, /* function to call */
          519	                "args":       []            /* function arguments to pass */
          520	            };
          521	
          522	            /*  helper function: portable checking whether something is a function  */
          523	            function _isfn (fn) {
          524	                return (
          525	                       !!fn
          526	                    && typeof fn != "string"
          527	                    && typeof fn[0] == "undefined"
          528	                    && RegExp("function", "i").test(fn + "")
          529	                );
          530	            };
          531	           
          532	            /*  parse arguments into context parameters (part 1/4):
          533	                detect an override object (special case to support jQuery method) */
          534	            var i = 0;
          535	            var override = false;
          536	            if (typeof arguments[i] == "object" && arguments.length > 1) {
          537	                override = true;
          538	                i++;
          539	            }
          540	
          541	            /*  parse arguments into context parameters (part 2/4):
          542	                support the flexible way of an associated array */
          543	            if (typeof arguments[i] == "object") {
          544	                for (var option in arguments[i])
          545	                    if (typeof ctx[option] != "undefined")
          546	                        ctx[option] = arguments[i][option];
          547	                i++;
          548	            }
          549	
          550	            /*  parse arguments into context parameters (part 3/4):
          551	                support: schedule([time [, repeat], ]{{obj, methodname} | func}[, arg, ...]); */
          552	            if (   typeof arguments[i] == "number"
          553	                || (   typeof arguments[i] == "string" 
          554	                    && arguments[i].match(RegExp("^[0-9]+[smhdw]$"))))
          555	                ctx["time"] = arguments[i++];
          556	            if (typeof arguments[i] == "boolean")
          557	                ctx["repeat"] = arguments[i++];
          558	            if (typeof arguments[i] == "boolean")
          559	                ctx["protect"] = arguments[i++];
          560	            if (   typeof arguments[i] == "object"
          561	                && typeof arguments[i+1] == "string"
          562	                && _isfn(arguments[i][arguments[i+1]])) {
          563	                ctx["obj"] = arguments[i++];
          564	                ctx["func"] = arguments[i++];
          565	            }
          566	            else if (   typeof arguments[i] != "undefined"
          567	                     && (   _isfn(arguments[i]) 
          568	                         || typeof arguments[i] == "string"))
          569	                ctx["func"] = arguments[i++];
          570	            while (typeof arguments[i] != "undefined")
          571	                ctx["args"].push(arguments[i++]);
          572	
          573	            /*  parse arguments into context parameters (part 4/4):
          574	                apply parameters from override object */
          575	            if (override) {
          576	                if (typeof arguments[1] == "object") {
          577	                    for (var option in arguments[0])
          578	                        if (   typeof ctx[option] != "undefined"
          579	                            && typeof arguments[1][option] == "undefined")
          580	                            ctx[option] = arguments[0][option];
          581	                }
          582	                else {
          583	                    for (var option in arguments[0])
          584	                        if (typeof ctx[option] != "undefined")
          585	                            ctx[option] = arguments[0][option];
          586	                }
          587	                i++;
          588	            }
          589	
          590	            /*  annotate context with internals */
          591	            ctx["_scheduler"] = this; /* internal: back-reference to scheduler object */
          592	            ctx["_handle"]    = null; /* internal: unique handle of low-level task */
          593	
          594	            /*  determine time value in milliseconds */
          595	            var match = String(ctx["time"]).match(RegExp("^([0-9]+)([smhdw])$"));
          596	            if (match && match[0] != "undefined" && match[1] != "undefined")
          597	                ctx["time"] = String(parseInt(match[1]) *
          598	                    { s: 1000, m: 1000*60, h: 1000*60*60,
          599	                      d: 1000*60*60*24, w: 1000*60*60*24*7 }[match[2]]);
          600	
          601	            /*  determine unique identifier of task  */
          602	            if (ctx["id"] == null)
          603	                ctx["id"] = (  String(ctx["repeat"])  + ":"
          604	                             + String(ctx["protect"]) + ":"
          605	                             + String(ctx["time"])    + ":"
          606	                             + String(ctx["obj"])     + ":"
          607	                             + String(ctx["func"])    + ":"
          608	                             + String(ctx["args"])         );
          609	
          610	            /*  optionally protect from duplicate calls  */
          611	            if (ctx["protect"])
          612	                if (typeof this.bucket[ctx["id"]] != "undefined")
          613	                    return this.bucket[ctx["id"]];
          614	
          615	            /*  support execution of methods by name and arbitrary scripts  */
          616	            if (!_isfn(ctx["func"])) {
          617	                if (   ctx["obj"] != null
          618	                    && typeof ctx["obj"] == "object"
          619	                    && typeof ctx["func"] == "string"
          620	                    && _isfn(ctx["obj"][ctx["func"]]))
          621	                    /*  method by name  */
          622	                    ctx["func"] = ctx["obj"][ctx["func"]];
          623	                else
          624	                    /*  arbitrary script  */
          625	                    ctx["func"] = eval("function () { " + ctx["func"] + " }");
          626	            }
          627	
          628	            /*  pass-through to internal scheduling operation  */
          629	            ctx["_handle"] = this._schedule(ctx);
          630	
          631	            /*  store context into bucket of scheduler object  */
          632	            this.bucket[ctx["id"]] = ctx;
          633	
          634	            /*  return context  */
          635	            return ctx;
          636	        },
          637	
          638	        /*  re-schedule a task  */
          639	        reschedule: function (ctx) {
          640	            if (typeof ctx == "string")
          641	                ctx = this.bucket[ctx];
          642	
          643	            /*  pass-through to internal scheduling operation  */
          644	            ctx["_handle"] = this._schedule(ctx);
          645	
          646	            /*  return context  */
          647	            return ctx;
          648	        },
          649	
          650	        /*  internal scheduling operation  */
          651	        _schedule: function (ctx) {
          652	            /*  closure to act as the call trampoline function  */
          653	            var trampoline = function () {
          654	                /*  jump into function  */
          655	                var obj = (ctx["obj"] != null ? ctx["obj"] : ctx);
          656	                (ctx["func"]).apply(obj, ctx["args"]);
          657	
          658	                /*  either repeat scheduling and keep in bucket or
          659	                    just stop scheduling and delete from scheduler bucket  */
          660	                if (   /* not cancelled from inside... */
          661	                       typeof (ctx["_scheduler"]).bucket[ctx["id"]] != "undefined"
          662	                    && /* ...and repeating requested */
          663	                       ctx["repeat"])
          664	                    (ctx["_scheduler"])._schedule(ctx);
          665	                else
          666	                    delete (ctx["_scheduler"]).bucket[ctx["id"]];
          667	            };
          668	
          669	            /*  schedule task and return handle  */
          670	            return setTimeout(trampoline, ctx["time"]);
          671	        },
          672	
          673	        /*  cancel a scheduled task  */
          674	        cancel: function (ctx) {
          675	            if (typeof ctx == "string")
          676	                ctx = this.bucket[ctx];
          677	
          678	            /*  cancel scheduled task  */
          679	            if (typeof ctx == "object") {
          680	                clearTimeout(ctx["_handle"]);
          681	                delete this.bucket[ctx["id"]];
          682	            }
          683	        }
          684	    };
          685	
          686	    /* integrate a global instance of the scheduler into the global jQuery object */
          687	    $.extend({
          688	        scheduler$: new $.scheduler(),
          689	        schedule:   function () { return $.scheduler$.schedule.apply  ($.scheduler$, arguments) },
          690	        reschedule: function () { return $.scheduler$.reschedule.apply($.scheduler$, arguments) },
          691	        cancel:     function () { return $.scheduler$.cancel.apply    ($.scheduler$, arguments) }
          692	    });
          693	
          694	    /* integrate scheduling convinience method into all jQuery objects */
          695	    $.fn.extend({
          696	        schedule: function () {
          697	            var a = [ {} ];
          698	            for (var i = 0; i < arguments.length; i++)
          699	                a.push(arguments[i]);
          700	            return this.each(function () {
          701	                a[0] = { "id": this, "obj": this };
          702	                return $.schedule.apply($, a);
          703	            });
          704	        }
          705	    });
          706	
          707	})(jQuery);
          708	
        8. WordPress源代码——jquery-plugins(jquery.color-2.1.0.js)

          WordPress源代码——jquery-plugins(jquery.color-2.1.0.js)

          1	/*!
          2	 * jQuery Color Animations v2.1.0
          3	 * http://jquery.com/
          4	 *
          5	 * Copyright 2012 jQuery Foundation and other contributors
          6	 * Released under the MIT license.
          7	 * http://jquery.org/license
          8	 *
          9	 * Date: Fri Aug 24 12:02:24 2012 -0500
          10	 */
          11	(function( jQuery, undefined ) {
          12	
          13	        var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
          14	
          15	        // plusequals test for += 100 -= 100
          16	        rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
          17	        // a set of RE's that can match strings and generate color tuples.
          18	        stringParsers = [{
          19	                        re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
          20	                        parse: function( execResult ) {
          21	                                return [
          22	                                        execResult[ 1 ],
          23	                                        execResult[ 2 ],
          24	                                        execResult[ 3 ],
          25	                                        execResult[ 4 ]
          26	                                ];
          27	                        }
          28	                }, {
          29	                        re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
          30	                        parse: function( execResult ) {
          31	                                return [
          32	                                        execResult[ 1 ] * 2.55,
          33	                                        execResult[ 2 ] * 2.55,
          34	                                        execResult[ 3 ] * 2.55,
          35	                                        execResult[ 4 ]
          36	                                ];
          37	                        }
          38	                }, {
          39	                        // this regex ignores A-F because it's compared against an already lowercased string
          40	                        re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
          41	                        parse: function( execResult ) {
          42	                                return [
          43	                                        parseInt( execResult[ 1 ], 16 ),
          44	                                        parseInt( execResult[ 2 ], 16 ),
          45	                                        parseInt( execResult[ 3 ], 16 )
          46	                                ];
          47	                        }
          48	                }, {
          49	                        // this regex ignores A-F because it's compared against an already lowercased string
          50	                        re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
          51	                        parse: function( execResult ) {
          52	                                return [
          53	                                        parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
          54	                                        parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
          55	                                        parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
          56	                                ];
          57	                        }
          58	                }, {
          59	                        re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
          60	                        space: "hsla",
          61	                        parse: function( execResult ) {
          62	                                return [
          63	                                        execResult[ 1 ],
          64	                                        execResult[ 2 ] / 100,
          65	                                        execResult[ 3 ] / 100,
          66	                                        execResult[ 4 ]
          67	                                ];
          68	                        }
          69	                }],
          70	
          71	        // jQuery.Color( )
          72	        color = jQuery.Color = function( color, green, blue, alpha ) {
          73	                return new jQuery.Color.fn.parse( color, green, blue, alpha );
          74	        },
          75	        spaces = {
          76	                rgba: {
          77	                        props: {
          78	                                red: {
          79	                                        idx: 0,
          80	                                        type: "byte"
          81	                                },
          82	                                green: {
          83	                                        idx: 1,
          84	                                        type: "byte"
          85	                                },
          86	                                blue: {
          87	                                        idx: 2,
          88	                                        type: "byte"
          89	                                }
          90	                        }
          91	                },
          92	
          93	                hsla: {
          94	                        props: {
          95	                                hue: {
          96	                                        idx: 0,
          97	                                        type: "degrees"
          98	                                },
          99	                                saturation: {
          100	                                        idx: 1,
          101	                                        type: "percent"
          102	                                },
          103	                                lightness: {
          104	                                        idx: 2,
          105	                                        type: "percent"
          106	                                }
          107	                        }
          108	                }
          109	        },
          110	        propTypes = {
          111	                "byte": {
          112	                        floor: true,
          113	                        max: 255
          114	                },
          115	                "percent": {
          116	                        max: 1
          117	                },
          118	                "degrees": {
          119	                        mod: 360,
          120	                        floor: true
          121	                }
          122	        },
          123	        support = color.support = {},
          124	
          125	        // element for support tests
          126	        supportElem = jQuery( "<p>" )[ 0 ],
          127	
          128	        // colors = jQuery.Color.names
          129	        colors,
          130	
          131	        // local aliases of functions called often
          132	        each = jQuery.each;
          133	
          134	// determine rgba support immediately
          135	supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
          136	support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
          137	
          138	// define cache name and alpha properties
          139	// for rgba and hsla spaces
          140	each( spaces, function( spaceName, space ) {
          141	        space.cache = "_" + spaceName;
          142	        space.props.alpha = {
          143	                idx: 3,
          144	                type: "percent",
          145	                def: 1
          146	        };
          147	});
          148	
          149	function clamp( value, prop, allowEmpty ) {
          150	        var type = propTypes[ prop.type ] || {};
          151	
          152	        if ( value == null ) {
          153	                return (allowEmpty || !prop.def) ? null : prop.def;
          154	        }
          155	
          156	        // ~~ is an short way of doing floor for positive numbers
          157	        value = type.floor ? ~~value : parseFloat( value );
          158	
          159	        // IE will pass in empty strings as value for alpha,
          160	        // which will hit this case
          161	        if ( isNaN( value ) ) {
          162	                return prop.def;
          163	        }
          164	
          165	        if ( type.mod ) {
          166	                // we add mod before modding to make sure that negatives values
          167	                // get converted properly: -10 -> 350
          168	                return (value + type.mod) % type.mod;
          169	        }
          170	
          171	        // for now all property types without mod have min and max
          172	        return 0 > value ? 0 : type.max < value ? type.max : value;
          173	}
          174	
          175	function stringParse( string ) {
          176	        var inst = color(),
          177	                rgba = inst._rgba = [];
          178	
          179	        string = string.toLowerCase();
          180	
          181	        each( stringParsers, function( i, parser ) {
          182	                var parsed,
          183	                        match = parser.re.exec( string ),
          184	                        values = match && parser.parse( match ),
          185	                        spaceName = parser.space || "rgba";
          186	
          187	                if ( values ) {
          188	                        parsed = inst[ spaceName ]( values );
          189	
          190	                        // if this was an rgba parse the assignment might happen twice
          191	                        // oh well....
          192	                        inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
          193	                        rgba = inst._rgba = parsed._rgba;
          194	
          195	                        // exit each( stringParsers ) here because we matched
          196	                        return false;
          197	                }
          198	        });
          199	
          200	        // Found a stringParser that handled it
          201	        if ( rgba.length ) {
          202	
          203	                // if this came from a parsed string, force "transparent" when alpha is 0
          204	                // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
          205	                if ( rgba.join() === "0,0,0,0" ) {
          206	                        jQuery.extend( rgba, colors.transparent );
          207	                }
          208	                return inst;
          209	        }
          210	
          211	        // named colors
          212	        return colors[ string ];
          213	}
          214	
          215	color.fn = jQuery.extend( color.prototype, {
          216	        parse: function( red, green, blue, alpha ) {
          217	                if ( red === undefined ) {
          218	                        this._rgba = [ null, null, null, null ];
          219	                        return this;
          220	                }
          221	                if ( red.jquery || red.nodeType ) {
          222	                        red = jQuery( red ).css( green );
          223	                        green = undefined;
          224	                }
          225	
          226	                var inst = this,
          227	                        type = jQuery.type( red ),
          228	                        rgba = this._rgba = [],
          229	                        source;
          230	
          231	                // more than 1 argument specified - assume ( red, green, blue, alpha )
          232	                if ( green !== undefined ) {
          233	                        red = [ red, green, blue, alpha ];
          234	                        type = "array";
          235	                }
          236	
          237	                if ( type === "string" ) {
          238	                        return this.parse( stringParse( red ) || colors._default );
          239	                }
          240	
          241	                if ( type === "array" ) {
          242	                        each( spaces.rgba.props, function( key, prop ) {
          243	                                rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
          244	                        });
          245	                        return this;
          246	                }
          247	
          248	                if ( type === "object" ) {
          249	                        if ( red instanceof color ) {
          250	                                each( spaces, function( spaceName, space ) {
          251	                                        if ( red[ space.cache ] ) {
          252	                                                inst[ space.cache ] = red[ space.cache ].slice();
          253	                                        }
          254	                                });
          255	                        } else {
          256	                                each( spaces, function( spaceName, space ) {
          257	                                        var cache = space.cache;
          258	                                        each( space.props, function( key, prop ) {
          259	
          260	                                                // if the cache doesn't exist, and we know how to convert
          261	                                                if ( !inst[ cache ] && space.to ) {
          262	
          263	                                                        // if the value was null, we don't need to copy it
          264	                                                        // if the key was alpha, we don't need to copy it either
          265	                                                        if ( key === "alpha" || red[ key ] == null ) {
          266	                                                                return;
          267	                                                        }
          268	                                                        inst[ cache ] = space.to( inst._rgba );
          269	                                                }
          270	
          271	                                                // this is the only case where we allow nulls for ALL properties.
          272	                                                // call clamp with alwaysAllowEmpty
          273	                                                inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
          274	                                        });
          275	
          276	                                        // everything defined but alpha?
          277	                                        if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
          278	                                                // use the default of 1
          279	                                                inst[ cache ][ 3 ] = 1;
          280	                                                if ( space.from ) {
          281	                                                        inst._rgba = space.from( inst[ cache ] );
          282	                                                }
          283	                                        }
          284	                                });
          285	                        }
          286	                        return this;
          287	                }
          288	        },
          289	        is: function( compare ) {
          290	                var is = color( compare ),
          291	                        same = true,
          292	                        inst = this;
          293	
          294	                each( spaces, function( _, space ) {
          295	                        var localCache,
          296	                                isCache = is[ space.cache ];
          297	                        if (isCache) {
          298	                                localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
          299	                                each( space.props, function( _, prop ) {
          300	                                        if ( isCache[ prop.idx ] != null ) {
          301	                                                same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
          302	                                                return same;
          303	                                        }
          304	                                });
          305	                        }
          306	                        return same;
          307	                });
          308	                return same;
          309	        },
          310	        _space: function() {
          311	                var used = [],
          312	                        inst = this;
          313	                each( spaces, function( spaceName, space ) {
          314	                        if ( inst[ space.cache ] ) {
          315	                                used.push( spaceName );
          316	                        }
          317	                });
          318	                return used.pop();
          319	        },
          320	        transition: function( other, distance ) {
          321	                var end = color( other ),
          322	                        spaceName = end._space(),
          323	                        space = spaces[ spaceName ],
          324	                        startColor = this.alpha() === 0 ? color( "transparent" ) : this,
          325	                        start = startColor[ space.cache ] || space.to( startColor._rgba ),
          326	                        result = start.slice();
          327	
          328	                end = end[ space.cache ];
          329	                each( space.props, function( key, prop ) {
          330	                        var index = prop.idx,
          331	                                startValue = start[ index ],
          332	                                endValue = end[ index ],
          333	                                type = propTypes[ prop.type ] || {};
          334	
          335	                        // if null, don't override start value
          336	                        if ( endValue === null ) {
          337	                                return;
          338	                        }
          339	                        // if null - use end
          340	                        if ( startValue === null ) {
          341	                                result[ index ] = endValue;
          342	                        } else {
          343	                                if ( type.mod ) {
          344	                                        if ( endValue - startValue > type.mod / 2 ) {
          345	                                                startValue += type.mod;
          346	                                        } else if ( startValue - endValue > type.mod / 2 ) {
          347	                                                startValue -= type.mod;
          348	                                        }
          349	                                }
          350	                                result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
          351	                        }
          352	                });
          353	                return this[ spaceName ]( result );
          354	        },
          355	        blend: function( opaque ) {
          356	                // if we are already opaque - return ourself
          357	                if ( this._rgba[ 3 ] === 1 ) {
          358	                        return this;
          359	                }
          360	
          361	                var rgb = this._rgba.slice(),
          362	                        a = rgb.pop(),
          363	                        blend = color( opaque )._rgba;
          364	
          365	                return color( jQuery.map( rgb, function( v, i ) {
          366	                        return ( 1 - a ) * blend[ i ] + a * v;
          367	                }));
          368	        },
          369	        toRgbaString: function() {
          370	                var prefix = "rgba(",
          371	                        rgba = jQuery.map( this._rgba, function( v, i ) {
          372	                                return v == null ? ( i > 2 ? 1 : 0 ) : v;
          373	                        });
          374	
          375	                if ( rgba[ 3 ] === 1 ) {
          376	                        rgba.pop();
          377	                        prefix = "rgb(";
          378	                }
          379	
          380	                return prefix + rgba.join() + ")";
          381	        },
          382	        toHslaString: function() {
          383	                var prefix = "hsla(",
          384	                        hsla = jQuery.map( this.hsla(), function( v, i ) {
          385	                                if ( v == null ) {
          386	                                        v = i > 2 ? 1 : 0;
          387	                                }
          388	
          389	                                // catch 1 and 2
          390	                                if ( i && i < 3 ) {
          391	                                        v = Math.round( v * 100 ) + "%";
          392	                                }
          393	                                return v;
          394	                        });
          395	
          396	                if ( hsla[ 3 ] === 1 ) {
          397	                        hsla.pop();
          398	                        prefix = "hsl(";
          399	                }
          400	                return prefix + hsla.join() + ")";
          401	        },
          402	        toHexString: function( includeAlpha ) {
          403	                var rgba = this._rgba.slice(),
          404	                        alpha = rgba.pop();
          405	
          406	                if ( includeAlpha ) {
          407	                        rgba.push( ~~( alpha * 255 ) );
          408	                }
          409	
          410	                return "#" + jQuery.map( rgba, function( v, i ) {
          411	
          412	                        // default to 0 when nulls exist
          413	                        v = ( v || 0 ).toString( 16 );
          414	                        return v.length === 1 ? "0" + v : v;
          415	                }).join("");
          416	        },
          417	        toString: function() {
          418	                return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
          419	        }
          420	});
          421	color.fn.parse.prototype = color.fn;
          422	
          423	// hsla conversions adapted from:
          424	// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
          425	
          426	function hue2rgb( p, q, h ) {
          427	        h = ( h + 1 ) % 1;
          428	        if ( h * 6 < 1 ) {
          429	                return p + (q - p) * h * 6;
          430	        }
          431	        if ( h * 2 < 1) {
          432	                return q;
          433	        }
          434	        if ( h * 3 < 2 ) {
          435	                return p + (q - p) * ((2/3) - h) * 6;
          436	        }
          437	        return p;
          438	}
          439	
          440	spaces.hsla.to = function ( rgba ) {
          441	        if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
          442	                return [ null, null, null, rgba[ 3 ] ];
          443	        }
          444	        var r = rgba[ 0 ] / 255,
          445	                g = rgba[ 1 ] / 255,
          446	                b = rgba[ 2 ] / 255,
          447	                a = rgba[ 3 ],
          448	                max = Math.max( r, g, b ),
          449	                min = Math.min( r, g, b ),
          450	                diff = max - min,
          451	                add = max + min,
          452	                l = add * 0.5,
          453	                h, s;
          454	
          455	        if ( min === max ) {
          456	                h = 0;
          457	        } else if ( r === max ) {
          458	                h = ( 60 * ( g - b ) / diff ) + 360;
          459	        } else if ( g === max ) {
          460	                h = ( 60 * ( b - r ) / diff ) + 120;
          461	        } else {
          462	                h = ( 60 * ( r - g ) / diff ) + 240;
          463	        }
          464	
          465	        if ( l === 0 || l === 1 ) {
          466	                s = l;
          467	        } else if ( l <= 0.5 ) {
          468	                s = diff / add;
          469	        } else {
          470	                s = diff / ( 2 - add );
          471	        }
          472	        return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
          473	};
          474	
          475	spaces.hsla.from = function ( hsla ) {
          476	        if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
          477	                return [ null, null, null, hsla[ 3 ] ];
          478	        }
          479	        var h = hsla[ 0 ] / 360,
          480	                s = hsla[ 1 ],
          481	                l = hsla[ 2 ],
          482	                a = hsla[ 3 ],
          483	                q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
          484	                p = 2 * l - q,
          485	                r, g, b;
          486	
          487	        return [
          488	                Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
          489	                Math.round( hue2rgb( p, q, h ) * 255 ),
          490	                Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
          491	                a
          492	        ];
          493	};
          494	
          495	
          496	each( spaces, function( spaceName, space ) {
          497	        var props = space.props,
          498	                cache = space.cache,
          499	                to = space.to,
          500	                from = space.from;
          501	
          502	        // makes rgba() and hsla()
          503	        color.fn[ spaceName ] = function( value ) {
          504	
          505	                // generate a cache for this space if it doesn't exist
          506	                if ( to && !this[ cache ] ) {
          507	                        this[ cache ] = to( this._rgba );
          508	                }
          509	                if ( value === undefined ) {
          510	                        return this[ cache ].slice();
          511	                }
          512	
          513	                var ret,
          514	                        type = jQuery.type( value ),
          515	                        arr = ( type === "array" || type === "object" ) ? value : arguments,
          516	                        local = this[ cache ].slice();
          517	
          518	                each( props, function( key, prop ) {
          519	                        var val = arr[ type === "object" ? key : prop.idx ];
          520	                        if ( val == null ) {
          521	                                val = local[ prop.idx ];
          522	                        }
          523	                        local[ prop.idx ] = clamp( val, prop );
          524	                });
          525	
          526	                if ( from ) {
          527	                        ret = color( from( local ) );
          528	                        ret[ cache ] = local;
          529	                        return ret;
          530	                } else {
          531	                        return color( local );
          532	                }
          533	        };
          534	
          535	        // makes red() green() blue() alpha() hue() saturation() lightness()
          536	        each( props, function( key, prop ) {
          537	                // alpha is included in more than one space
          538	                if ( color.fn[ key ] ) {
          539	                        return;
          540	                }
          541	                color.fn[ key ] = function( value ) {
          542	                        var vtype = jQuery.type( value ),
          543	                                fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
          544	                                local = this[ fn ](),
          545	                                cur = local[ prop.idx ],
          546	                                match;
          547	
          548	                        if ( vtype === "undefined" ) {
          549	                                return cur;
          550	                        }
          551	
          552	                        if ( vtype === "function" ) {
          553	                                value = value.call( this, cur );
          554	                                vtype = jQuery.type( value );
          555	                        }
          556	                        if ( value == null && prop.empty ) {
          557	                                return this;
          558	                        }
          559	                        if ( vtype === "string" ) {
          560	                                match = rplusequals.exec( value );
          561	                                if ( match ) {
          562	                                        value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
          563	                                }
          564	                        }
          565	                        local[ prop.idx ] = value;
          566	                        return this[ fn ]( local );
          567	                };
          568	        });
          569	});
          570	
          571	// add cssHook and .fx.step function for each named hook.
          572	// accept a space separated string of properties
          573	color.hook = function( hook ) {
          574	        var hooks = hook.split( " " );
          575	        each( hooks, function( i, hook ) {
          576	                jQuery.cssHooks[ hook ] = {
          577	                        set: function( elem, value ) {
          578	                                var parsed, curElem,
          579	                                        backgroundColor = "";
          580	
          581	                                if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
          582	                                        value = color( parsed || value );
          583	                                        if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
          584	                                                curElem = hook === "backgroundColor" ? elem.parentNode : elem;
          585	                                                while (
          586	                                                        (backgroundColor === "" || backgroundColor === "transparent") &&
          587	                                                        curElem && curElem.style
          588	                                                ) {
          589	                                                        try {
          590	                                                                backgroundColor = jQuery.css( curElem, "backgroundColor" );
          591	                                                                curElem = curElem.parentNode;
          592	                                                        } catch ( e ) {
          593	                                                        }
          594	                                                }
          595	
          596	                                                value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
          597	                                                        backgroundColor :
          598	                                                        "_default" );
          599	                                        }
          600	
          601	                                        value = value.toRgbaString();
          602	                                }
          603	                                try {
          604	                                        elem.style[ hook ] = value;
          605	                                } catch( value ) {
          606	                                        // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
          607	                                }
          608	                        }
          609	                };
          610	                jQuery.fx.step[ hook ] = function( fx ) {
          611	                        if ( !fx.colorInit ) {
          612	                                fx.start = color( fx.elem, hook );
          613	                                fx.end = color( fx.end );
          614	                                fx.colorInit = true;
          615	                        }
          616	                        jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
          617	                };
          618	        });
          619	
          620	};
          621	
          622	color.hook( stepHooks );
          623	
          624	jQuery.cssHooks.borderColor = {
          625	        expand: function( value ) {
          626	                var expanded = {};
          627	
          628	                each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
          629	                        expanded[ "border" + part + "Color" ] = value;
          630	                });
          631	                return expanded;
          632	        }
          633	};
          634	
          635	// Basic color names only.
          636	// Usage of any of the other color names requires adding yourself or including
          637	// jquery.color.svg-names.js.
          638	colors = jQuery.Color.names = {
          639	        // 4.1. Basic color keywords
          640	        aqua: "#00ffff",
          641	        black: "#000000",
          642	        blue: "#0000ff",
          643	        fuchsia: "#ff00ff",
          644	        gray: "#808080",
          645	        green: "#008000",
          646	        lime: "#00ff00",
          647	        maroon: "#800000",
          648	        navy: "#000080",
          649	        olive: "#808000",
          650	        purple: "#800080",
          651	        red: "#ff0000",
          652	        silver: "#c0c0c0",
          653	        teal: "#008080",
          654	        white: "#ffffff",
          655	        yellow: "#ffff00",
          656	
          657	        // 4.2.3. ‘transparent’ color keyword
          658	        transparent: [ null, null, null, 0 ],
          659	
          660	        _default: "#ffffff"
          661	};
          662	
          663	})( jQuery );
          664	
          665	/*!
          666	 * jQuery Color Animations v2.1.0 - SVG Color Names
          667	 * http://jquery.org/
          668	 *
          669	 * Remaining HTML/CSS color names per W3C's CSS Color Module Level 3.
          670	 * http://www.w3.org/TR/css3-color/#svg-color
          671	 *
          672	 * Copyright 2012 jQuery Foundation and other contributors
          673	 * Released under the MIT license.
          674	 * http://jquery.org/license
          675	 *
          676	 * Date: Fri Aug 24 12:02:24 2012 -0500
          677	 */
          678	jQuery.extend( jQuery.Color.names, {
          679	        // 4.3. Extended color keywords (minus the basic ones in core color plugin)
          680	        aliceblue: "#f0f8ff",
          681	        antiquewhite: "#faebd7",
          682	        aquamarine: "#7fffd4",
          683	        azure: "#f0ffff",
          684	        beige: "#f5f5dc",
          685	        bisque: "#ffe4c4",
          686	        blanchedalmond: "#ffebcd",
          687	        blueviolet: "#8a2be2",
          688	        brown: "#a52a2a",
          689	        burlywood: "#deb887",
          690	        cadetblue: "#5f9ea0",
          691	        chartreuse: "#7fff00",
          692	        chocolate: "#d2691e",
          693	        coral: "#ff7f50",
          694	        cornflowerblue: "#6495ed",
          695	        cornsilk: "#fff8dc",
          696	        crimson: "#dc143c",
          697	        cyan: "#00ffff",
          698	        darkblue: "#00008b",
          699	        darkcyan: "#008b8b",
          700	        darkgoldenrod: "#b8860b",
          701	        darkgray: "#a9a9a9",
          702	        darkgreen: "#006400",
          703	        darkgrey: "#a9a9a9",
          704	        darkkhaki: "#bdb76b",
          705	        darkmagenta: "#8b008b",
          706	        darkolivegreen: "#556b2f",
          707	        darkorange: "#ff8c00",
          708	        darkorchid: "#9932cc",
          709	        darkred: "#8b0000",
          710	        darksalmon: "#e9967a",
          711	        darkseagreen: "#8fbc8f",
          712	        darkslateblue: "#483d8b",
          713	        darkslategray: "#2f4f4f",
          714	        darkslategrey: "#2f4f4f",
          715	        darkturquoise: "#00ced1",
          716	        darkviolet: "#9400d3",
          717	        deeppink: "#ff1493",
          718	        deepskyblue: "#00bfff",
          719	        dimgray: "#696969",
          720	        dimgrey: "#696969",
          721	        dodgerblue: "#1e90ff",
          722	        firebrick: "#b22222",
          723	        floralwhite: "#fffaf0",
          724	        forestgreen: "#228b22",
          725	        gainsboro: "#dcdcdc",
          726	        ghostwhite: "#f8f8ff",
          727	        gold: "#ffd700",
          728	        goldenrod: "#daa520",
          729	        greenyellow: "#adff2f",
          730	        grey: "#808080",
          731	        honeydew: "#f0fff0",
          732	        hotpink: "#ff69b4",
          733	        indianred: "#cd5c5c",
          734	        indigo: "#4b0082",
          735	        ivory: "#fffff0",
          736	        khaki: "#f0e68c",
          737	        lavender: "#e6e6fa",
          738	        lavenderblush: "#fff0f5",
          739	        lawngreen: "#7cfc00",
          740	        lemonchiffon: "#fffacd",
          741	        lightblue: "#add8e6",
          742	        lightcoral: "#f08080",
          743	        lightcyan: "#e0ffff",
          744	        lightgoldenrodyellow: "#fafad2",
          745	        lightgray: "#d3d3d3",
          746	        lightgreen: "#90ee90",
          747	        lightgrey: "#d3d3d3",
          748	        lightpink: "#ffb6c1",
          749	        lightsalmon: "#ffa07a",
          750	        lightseagreen: "#20b2aa",
          751	        lightskyblue: "#87cefa",
          752	        lightslategray: "#778899",
          753	        lightslategrey: "#778899",
          754	        lightsteelblue: "#b0c4de",
          755	        lightyellow: "#ffffe0",
          756	        limegreen: "#32cd32",
          757	        linen: "#faf0e6",
          758	        mediumaquamarine: "#66cdaa",
          759	        mediumblue: "#0000cd",
          760	        mediumorchid: "#ba55d3",
          761	        mediumpurple: "#9370db",
          762	        mediumseagreen: "#3cb371",
          763	        mediumslateblue: "#7b68ee",
          764	        mediumspringgreen: "#00fa9a",
          765	        mediumturquoise: "#48d1cc",
          766	        mediumvioletred: "#c71585",
          767	        midnightblue: "#191970",
          768	        mintcream: "#f5fffa",
          769	        mistyrose: "#ffe4e1",
          770	        moccasin: "#ffe4b5",
          771	        navajowhite: "#ffdead",
          772	        oldlace: "#fdf5e6",
          773	        olivedrab: "#6b8e23",
          774	        orange: "#ffa500",
          775	        orangered: "#ff4500",
          776	        orchid: "#da70d6",
          777	        palegoldenrod: "#eee8aa",
          778	        palegreen: "#98fb98",
          779	        paleturquoise: "#afeeee",
          780	        palevioletred: "#db7093",
          781	        papayawhip: "#ffefd5",
          782	        peachpuff: "#ffdab9",
          783	        peru: "#cd853f",
          784	        pink: "#ffc0cb",
          785	        plum: "#dda0dd",
          786	        powderblue: "#b0e0e6",
          787	        rosybrown: "#bc8f8f",
          788	        royalblue: "#4169e1",
          789	        saddlebrown: "#8b4513",
          790	        salmon: "#fa8072",
          791	        sandybrown: "#f4a460",
          792	        seagreen: "#2e8b57",
          793	        seashell: "#fff5ee",
          794	        sienna: "#a0522d",
          795	        skyblue: "#87ceeb",
          796	        slateblue: "#6a5acd",
          797	        slategray: "#708090",
          798	        slategrey: "#708090",
          799	        snow: "#fffafa",
          800	        springgreen: "#00ff7f",
          801	        steelblue: "#4682b4",
          802	        tan: "#d2b48c",
          803	        thistle: "#d8bfd8",
          804	        tomato: "#ff6347",
          805	        turquoise: "#40e0d0",
          806	        violet: "#ee82ee",
          807	        wheat: "#f5deb3",
          808	        whitesmoke: "#f5f5f5",
          809	        yellowgreen: "#9acd32",
          810	});