//应用扩展 var TKJ = { config: { NOTICEFREQUENCY: 30 * 1000, AVATARSIZE: { "small": 30, "normal": 45, "big": 90 } }, common: { copy: function(obj, txt, success) { var self = this; $(obj).each(function() { var content = txt; if (typeof ZeroClipboard == "undefined") return false; this.clip = null; if ($.isFunction(txt)) { content = txt.call(this); } ZeroClipboard.setMoviePath(Cute.config.SCRIPTPATH + "ZeroClipboard.swf"); this.clip = new ZeroClipboard.Client(); this.clip.setHandCursor(true); this.clip.setText(content); this.clip.addEventListener('onComplete', success); $(window).resize(function() { this.clip.reposition(); }.bind(this)); this.clip.glue(this); return this.clip; }); }, //ajax加载ajax/write里的页面,一样的内容,只会加载一次 write: function(id, params, fn) { if (!id) return; if (arguments.length < 3) { cache = fn; fn = params; params = {}; } var cachekey = "write" + id; if (params.cachekey) cachekey = params.cachekey; //设置cache的key值,默认为write + 文件ID if (!$(document).data(cachekey)) { Cute.api.get("write", $.extend({ id: id }, params || {}), function(html) { if (html) { $(document).data(cachekey, html); fn(html); } }, false, true); } else { fn($(document).data(cachekey)); } }, bgcolorAnimation: function(obj, color) { Do('animatecolors', function() { obj = $(obj); obj.stop(false, true).focus(); var _o_bgcolor = obj.css("backgroundColor"); obj.css({ backgroundColor: color || "#FFC8C8" }).animate({ backgroundColor: _o_bgcolor }, 1000, function() { this.style.cssText = this.style.cssText.replace(/background\-color[^;]+;/i, ''); }); }); return false; }, showEmoji: function(obj, input, parentEl) { var obj = $(obj); if (obj[0].dialog) { obj[0].dialog.toggle(); } else { Cute.api.get('common/get_emoji', {}, function(json) { var html = ""; $.each(json.data, function(i, item) { html += ''; }); obj[0].dialog = new Cute.ui.dialog().tooltip("layer", "", { content: '
' + html + '
', className: "tooltip emoji_dialog", parentEl: parentEl, width: 326, pos: { "top": function() { return (parentEl ? obj.position().top : obj.offset().top) + obj.outerHeight() + 2; }, "left": function() { return (parentEl ? obj.position().left : obj.offset().left) - 1; } } }); var form = obj.closest("form"); $(".d_emoji a", obj[0].dialog.pannel).click(function(e) { var _this = $(this); Cute.common.insertSelection(form.find(input || "textarea[name=content]")[0], "[" + _this.attr("rel") + "]"); form.find(input || "textarea[name=content]").trigger("keyup").css("color", "#000").trigger("keyup"); obj[0].dialog.hide(); e.preventDefault(); e.stopPropagation(); }); form.out("click.emoji", function(e) { if (!obj[0].dialog.pannel) { form.unout("click.emoji"); return; } if ($(this).has(e.target).length == 0) { obj[0].dialog.hide(); } }, true); }); } return false; }, emoji: function(str) { if (window['jEmoji']) { if (!jEmoji.EXT_EMOJI_MAP) jEmoji.EXT_EMOJI_MAP = TKJ.config.EXT_EMOJI_MAP || {}; return jEmoji.unifiedToHTML(jEmoji.softbankToUnified(jEmoji.googleToUnified(str))); } else { return str; } }, blockSlide: function(options) { var self = this; var opt = $.extend(true, { width: 468, //宽度 height: null, //高度 data: [], //广告列表,例:[{url:"",image:"",title:"",target:""}], random: false, showpage: true, interval: 5, //轮播间隔 transition: 1000, style: '', styleurl: "" //特殊样式URL }, options); var iframe = $('