﻿/*
* jquery.RenderText.js
*
*
* 2010 Written and maintained by Highmore Hill (highmore@163.com)
*/

;(function($) {
	if (/1\.(0|1|2|3|4)\.(0|1)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
		alert("RenderText 需要 jQuery v1.4.2以上版本! 您使用的版本是 v" + $.fn.jquery);
		return;
	}

	$.fn.RenderText = function(options) {
		var $e, $r;

		return this.each(function(i, e) {
			$e = $(e);
			opts = $.extend({}, $.fn.RenderText.defaults, {text:$e.data("text"), bg_color:$e.data("bg_color"), font_size:$e.data("font_size"), font_color:"0x" + $e.data("font_color"), font_type:$e.data("font_type"), mode:$e.data("image_type")});

			var _text = (opts.escape) ? escape(opts.text) : opts.text;
			$r = $('<img class="unitPng" src="text.asp?fs=' + opts.font_size + '&bc=' + opts.bg_color + '&fc=' + opts.font_color + '&ft=' + opts.font_type + '&m=' + opts.mode + '&t=' + _text + '" alt="' + opts.text + '" />');

			$e.html($r);
		});
	}

	$.fn.RenderText.version = "0.0.01";

/*
********************************************************************************************************
*
* private function
*
********************************************************************************************************
*/
	function processRender($this, $target, renderSuccess) {}

/*
********************************************************************************************************
*
* rsuccess definitions - only fade is defined here, transition pack defines the rest
*
********************************************************************************************************
*/
	$.fn.RenderText.rsuccess = {
		replaceContainerHtml: function(html, $container) {
			$container.empty();
			$container.html(html);
		},

		insertContainerHtml: function(html, $container) {
			$container.append(html);
		}
	}

/*
********************************************************************************************************
*
* plugin options defaults
*
********************************************************************************************************
*/

	$.fn.RenderText.defaults = {
		font_size	: 24,
		font_color	: "000000",
		bg_color	: "FFFFFF",
		font_type	: "HSGBW3.otf",
		mode		: "jpg",
		escape		: true
	}

})(jQuery);


