jquery.sudy.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /*
  2. ** sudyTpl for javascript template
  3. */
  4. !function(a){a.fn.sudyTpl=function(b){var c={p:null,json:null,callback:function(){}},d=a.extend(!0,{},c,b);return this.each(function(){var b=a(this),c=a('[type="text/template"]',b),e=[];if(null!==d.json?e=d.json:null!==d.p&&(e=getImgJson(d.p)),e.length>0){var f=c.get(0).text,g=f.match(/<!--LoopBegin-->[\s\S]*?<!--LoopEnd-->/gi),h=[];return a.each(g,function(b,c){c=c.replace(/<!--[\s\S]*?-->/g,""),h[b]="",a.each(e,function(){h[b]+=c.replace(/\[%title%\]/g,this.title).replace(/(\/page\/main\d+\/|\/_upload[\s\S]*?\/template\d+\/)?\[%url%\]/g,this.url).replace(/(\/page\/main\d+\/|\/_upload[\s\S]*?\/template\d+\/)?\[%src%\]/g,this.src).replace(/\[%text%\]/g,this.text)}),f=f.replace(/<!--LoopBegin-->[\s\S]*?<!--LoopEnd-->/i,h[b])}),f=a.trim(f.replace(/(\n[\s|\t]*\r*\n)/g,"\n")),b.html(f),d.callback(b)}})}}(jQuery);
  5. /*
  6. sudyTouch for support touch
  7. */
  8. !function(a){a.fn.sudyTouch=function(b){return this.each(function(){a(this).width(),a(this).height(),a(this).on("touchstart",function(c){var d=c.originalEvent.touches[0],e=Number(new Date),f=a(this).position();return a.data(this,"touchstart",{posX:d.pageX,posY:d.pageY,timer:e,startX:f.left,startY:f.top}),b.swipeStart&&b.swipeStart.call(this,f.left,f.top),c.stopPropagation()}).on("touchmove",function(c){var d=c.originalEvent.touches[0],e=Number(new Date),f=d.pageX-a.data(this,"touchstart").posX,g=d.pageY-a.data(this,"touchstart").posY;return deltaT=e-a.data(this,"touchstart").timer,a.data(this,"touchmove",{posX:d.pageX,posY:d.pageY,timer:e}),b.swipeMove&&(c.preventDefault(),b.swipeMove.call(this,f,g,deltaT)),(b.swipeRight||b.swipeLeft)&&Math.abs(f)>Math.abs(g)&&c.preventDefault(),(b.swipeTop||b.swipeBottom)&&Math.abs(g)>Math.abs(f)&&c.preventDefault(),c.stopPropagation()}).on("touchend",function(){var c=Number(new Date),d=a.data(this,"touchmove").posX-a.data(this,"touchstart").posX,f=a.data(this,"touchmove").posY-a.data(this,"touchstart").posY,g=c-a.data(this,"touchstart").timer;a.data(this,"touchend",{posX:a.data(this,"touchmove").posX,posY:a.data(this,"touchmove").posY,timer:c});var h=Math.atan2(-f,d);return(Math.abs(d)>30||Math.abs(f)>30)&&200>g&&(Math.abs(h)<Math.PI/4&&b.swipeRight&&b.swipeRight.call(this,d,f,g),Math.abs(h)>3*Math.PI/4&&b.swipeLeft&&b.swipeLeft.call(this,d,f,g),Math.PI/4<h&&h<3*Math.PI/4&&b.swipeTop&&b.swipeTop.call(this,d,f,g),3*-Math.PI/4<h&&h<-Math.PI/4&&b.swipeBottom&&b.swipeBottom.call(this,d,f,g)),b.swipeEnd&&b.swipeEnd.call(this,d,f,g),e.stopPropagation()})})}}(jQuery);
  9. /*
  10. ** sudyfocus
  11. */
  12. ;
  13. (function($) {
  14. $.fn.sudyfocus = function(opts) {
  15. var defaults = {
  16. p: null, // 窗口号或频道号
  17. json: [], // 文章的json数据
  18. title: {
  19. active: true, // 是否显示标题
  20. isAutoWidth: false, // 标题背景自动宽度
  21. href: false // 标题是否加文章链接
  22. },
  23. text: {
  24. active: false, // 是否显示文章简介
  25. isAutoHeight: false, // 简介背景自动高度
  26. href: false // 简介是否加文章链接
  27. },
  28. href: true, // 图片是否加链接
  29. zWidth: 420, // 窗口宽度
  30. zHeight: 270, // 窗口高度
  31. response: true, // 是否自适应缩放
  32. navigation: true, // 是否显示按钮,上一张、下一张
  33. isNavHover: true, // 导航按钮是否默认隐藏,鼠标经过时再显示
  34. pagination: false, // 是否显示按钮,1、2、3、4...
  35. thumbnail: false, // 是否显示缩略图
  36. effect: 'slide', // slide(滑动),fade(淡入),show(即显)
  37. speed: 500, // 切换速度
  38. crossfade: true, // 是否交叉淡入淡出
  39. start: 1, // 默认从第一个开始切换
  40. autoPlay: true, // 是否自动播放
  41. interval: 5000, // 自动播放时间间隔
  42. trigger:"click",
  43. bgColor:"#919191",
  44. zoom:false,
  45. callback: function(){},
  46. isMobile:false
  47. };
  48. var o = $.extend(true, {}, defaults, opts),
  49. zW = o.zWidth,
  50. zH = o.zHeight,
  51. r = zW / zH;
  52. if (o.p !== null && eval('typeof getImgJson') == "function")
  53. o.json = getImgJson(o.p).concat(o.json);
  54. function setfoucs(objs){
  55. $.each(objs, function(i, e) {
  56. // 若定义焦点信息,进行焦点定位计算
  57. if ("img_meta" in o.json[i] && !$.isEmptyObject(o.json[i].img_meta)) {
  58. var g = $(e).find("img").eq(0),
  59. fW = o.json[i].img_meta.focusWidth,
  60. fH = o.json[i].img_meta.focusHeight,
  61. fr = fW / fH,
  62. rW = o.json[i].img_meta.realWidth,
  63. rH = o.json[i].img_meta.realHeight,
  64. rr = rW / rH,
  65. pos = {
  66. 'X': o.json[i].img_meta.left,
  67. 'Y': o.json[i].img_meta.top
  68. };
  69. var temX = pos.X,
  70. temY = pos.Y;
  71. pos.X = 2 * temX + fW < rW ? 0 : 2 * temX + fW - rW;
  72. pos.Y = 2 * temY + fH < rH ? 0 : 2 * temY + fH - rH;
  73. fW = pos.X == 0 ? fW + 2 * temX : rW - pos.X;
  74. fH = pos.Y == 0 ? fH + 2 * temY : rH - pos.Y;
  75. fr = fW / fH;
  76. var zoom, center = {};
  77. if (fr < r) {
  78. zoom = zW / fW;
  79. rW = zoom * rW;
  80. rH = rW / rr;
  81. fW = zW;
  82. fH = fW / fr;
  83. center.X = zoom * pos.X + fW / 2;
  84. center.Y = zoom * pos.Y + fH / 2;
  85. } else {
  86. zoom = zH / fH;
  87. rH = zoom * rH;
  88. rW = rH * rr;
  89. fH = zH;
  90. fW = fH * fr;
  91. center.X = zoom * pos.X + fW / 2;
  92. center.Y = zoom * pos.Y + fH / 2;
  93. }
  94. g.css({
  95. "display": "block",
  96. "width": rW + 'px',
  97. "height": rH + 'px',
  98. "position": "absolute",
  99. "left": zW / 2 - center.X + "px",
  100. "top": zH / 2 - center.Y + 'px'
  101. });
  102. }
  103. });
  104. };
  105. return this.each(function() {
  106. // 构建初始化HTML元素
  107. var c = $(this),
  108. pre = c.children(),
  109. preJSON = [];
  110. $.each(pre, function(i, e) {
  111. var preData = {};
  112. preData.title = $(e).attr("data-focus-title") || '';
  113. preData.url = $(e).attr("data-focus-url") || '';
  114. preData.text = $(e).attr("data-focus-text") || '';
  115. preData.original = $(e).attr("original-src") || e.src;
  116. preData.src = e.src;
  117. preData.width = e.width;
  118. preData.height = e.height;
  119. preJSON.push(preData);
  120. });
  121. o.json = preJSON.concat(o.json);
  122. c.html(function(index, html) {
  123. var html = "";
  124. $.each(o.json, function() {
  125. var zoom = "";
  126. if(o.zoom){
  127. if(e.width/e.height > r){
  128. zoom = 'style="width:100%; height:auto;"';
  129. }else{
  130. zoom = 'style="width:auto; height:100%;"';
  131. }
  132. }
  133. html += '<img src="' + (this.original&&!o.isMobile?this.original:this.src) + '"'+ zoom +'>';
  134. });
  135. return html;
  136. });
  137. if (o.json.length < 1)
  138. return c.html('\u7a97\u53e3\u672a\u7ed1\u5b9a\u6216\u65e0\u6587\u7ae0');
  139. c.children().wrap('<div class="focus-item" />').end().wrapInner('<div class="focus-container'+ (o.zoom?' focus-zoom':'') +'"'+ (o.zoom?' style="background-color:'+o.bgColor+';"':'') +' />');
  140. var u = $(".focus-container", c),
  141. l = $(".focus-item", u).hide(),
  142. len = l.length;
  143. if (o.title.active)
  144. $('<div class="focus-title-bar"><div class="focus-title-bg"></div><h2 class="focus-title"></h2></div>').appendTo(c);
  145. if (o.text.active)
  146. $('<div class="focus-text-box"><div class="focus-text-bg"></div><div class="focus-text-inner"><p class="focus-text"></p></div></div>').appendTo(c);
  147. if (o.navigation && len >1 )
  148. $('<a class="focus-navigation focus-prev">&lt;</a><a class="focus-navigation focus-next">&gt;</a>').appendTo(c);
  149. if (o.pagination && len >1 ) {
  150. c.append(function(){
  151. var j, k, p = $('<div class="focus-pagination"></div>');
  152. for (j = 0; j < len; j++) {
  153. k = j + 1;
  154. p.append('<a class="focus-page focus-page-' + k + '"><span>' + k + '</span></a>');
  155. }
  156. return p;
  157. });
  158. }
  159. if (o.thumbnail && len >1 ) {
  160. c.append(function(){
  161. var j, k, p = $('<div class="focus-thumbnail"></div>');
  162. for (j = 0; j < len; j++) {
  163. k = j + 1;
  164. p.append('<a class="focus-thumb focus-thumb-' + k + '"><span><img src="' + o.json[j].src + '" /></span></a>');
  165. }
  166. return p;
  167. });
  168. }
  169. var $title = $(".focus-title-bar", c),
  170. $text = $(".focus-text-box", c),
  171. $nav = $(".focus-navigation", c),
  172. $pagi = $(".focus-pagination", c),
  173. $thumb = $(".focus-thumbnail", c),
  174. pages = $('.focus-page', $pagi),
  175. title = $('.focus-title', $title),
  176. thumbs = $('.focus-thumb', $thumb),
  177. text = $(".focus-text", $text);
  178. if (o.isNavHover) {
  179. $nav.hide();
  180. c.hover(function() {
  181. $nav.show();
  182. }, function() {
  183. $nav.hide();
  184. });
  185. }
  186. function resizeFocus(){
  187. c.css({
  188. width: zW + 'px',
  189. height: zH + 'px'
  190. }).addClass('focus-box');
  191. u.css({
  192. width: zW + 'px',
  193. height: zH + 'px',
  194. visibility: 'visible'
  195. });
  196. }
  197. //自适应处理
  198. if(o.response){
  199. var W = c.parent().width();
  200. zW = W;
  201. zH = zW / r;
  202. $(window).resize(function(event) {
  203. W = c.parent().width();
  204. zW = W;
  205. zH = zW / r;
  206. resizeFocus()
  207. // 图片焦点计算
  208. setfoucs(l);
  209. });
  210. }
  211. resizeFocus();
  212. // 图片焦点计算
  213. setfoucs(l);
  214. var index = o.start > len ? len - 1 : o.start - 1,
  215. current = index;
  216. // 切换效果函数
  217. var play = {
  218. show: function() { // 即显效果
  219. l.eq(current).hide().end().eq(index).show();
  220. },
  221. slide: function() { // 滑动切换效果
  222. l.eq(current).show().end().eq(index).show();
  223. if (len > 1) {
  224. function slideNext() {
  225. l.eq(index).css({
  226. left: "100%"
  227. });
  228. l.eq(current).stop(true,true).animate({
  229. left: "-100%"
  230. }, o.speed);
  231. l.eq(index).stop(true, false).animate({
  232. left: "0%"
  233. }, o.speed);
  234. }
  235. function slidePrev() {
  236. l.eq(index).css({
  237. left: "-100%"
  238. });
  239. l.eq(current).stop(true,true).animate({
  240. left: "100%"
  241. }, o.speed);
  242. l.eq(index).stop(true, false).animate({
  243. left: "0%"
  244. }, o.speed);
  245. }
  246. if ((current == 0 && index == len - 1) || (current == len - 1 && index == 0)) {
  247. if (current == 0 && index == len - 1)
  248. slidePrev();
  249. if (current == len - 1 && index == 0)
  250. slideNext();
  251. } else {
  252. if (index > current)
  253. slideNext();
  254. if (index < current)
  255. slidePrev();
  256. }
  257. }
  258. },
  259. fade: function() { // 淡入淡出效果
  260. if (o.crossfade) { // 是否交叉过渡
  261. l.eq(current).stop(true,true).fadeOut(o.speed).end().eq(index).fadeIn(o.speed);
  262. } else {
  263. l.eq(current).stop(true,true).hide().end().eq(index).fadeIn(o.speed);
  264. }
  265. }
  266. };
  267. // 内容显示函数
  268. function showIndex() {
  269. $title.hide();
  270. $text.hide();
  271. if (o.effect == 'slide') {
  272. play.slide();
  273. } else if (o.effect == 'fade') {
  274. play.fade();
  275. } else {
  276. play.show();
  277. }
  278. pages.removeClass('focus-page-active').eq(index).addClass('focus-page-active');
  279. thumbs.removeClass('focus-thumb-active').eq(index).addClass('focus-thumb-active');
  280. var $titleHtml = $.trim(o.json[index].title || ""),
  281. $textHtml = $.trim(o.json[index].text || "");
  282. $url = $.trim(o.json[index].url || "");
  283. // 是否显示链接
  284. if ($url !== '' && $url !== '#') {
  285. var $href = $('<a href="' + $url + '" target="_blank"></a>');
  286. if (o.href && l.eq(index).find("a").length < 1)
  287. l.eq(index).wrapInner($href);
  288. if (o.title.href && $titleHtml !== "")
  289. $titleHtml = $href.clone().html($titleHtml);
  290. if (o.text.href && $textHtml !== "")
  291. $textHtml = $href.clone().html($textHtml);
  292. }
  293. if ($titleHtml !== '') {
  294. $title.show();
  295. title.html($titleHtml);
  296. }
  297. if ($textHtml !== '') {
  298. $text.show();
  299. text.html($textHtml);
  300. }
  301. // 标题背景自动宽度
  302. if (o.title.isAutoWidth)
  303. title.parent().css("width", title.outerWidth());
  304. // 内容背景自动高度
  305. if (o.text.isAutoHeight)
  306. text.parent().parent().css("height", text.outerHeight());
  307. current = index;
  308. if(typeof o.callback === "function"){
  309. o.callback.call(this, index, o);
  310. }
  311. }
  312. // 递增索引函数
  313. function playNext() {
  314. index++;
  315. if (index > len - 1) {
  316. index = 0;
  317. }
  318. showIndex();
  319. }
  320. // 递减索引函数
  321. function playPrev() {
  322. index--;
  323. if (index < 0) {
  324. index = len - 1;
  325. }
  326. showIndex();
  327. }
  328. // 自动播放
  329. function autoPlay() {
  330. var timer;
  331. c.hover(function() {
  332. clearInterval(timer);
  333. }, function() {
  334. timer = setInterval(function() {
  335. playNext();
  336. }, o.interval);
  337. }).trigger("mouseleave");
  338. }
  339. // 监视页面标签页是否处于激活状态
  340. /*window.addEventListener('visibilitychange',function(){
  341. if (document.visibilityState === 'visible') {
  342. var timer;
  343. c.hover(function() {
  344. clearInterval(timer);
  345. }, function() {
  346. timer = setInterval(function() {
  347. playNext();
  348. }, o.interval);
  349. }).trigger("mouseleave");
  350. console.log('前台')
  351. } else if (document.visibilityState === 'hidden') {
  352. console.log('后台')
  353. }
  354. })*/
  355. if (o.autoPlay)
  356. autoPlay();
  357. var prev = $('.focus-prev', c),
  358. next = $('.focus-next', c);
  359. // 上一个
  360. prev.click(function() {
  361. playPrev();
  362. });
  363. //下一个
  364. next.click(function() {
  365. playNext();
  366. });
  367. // 直接索引号
  368. pages.on(o.trigger,function() {
  369. index = $(this).index();
  370. showIndex();
  371. });
  372. // 缩略图索引
  373. thumbs.on(o.trigger,function() {
  374. index = $(this).index();
  375. showIndex();
  376. });
  377. // 是否支持触屏
  378. if($.fn.sudyTouch){
  379. u.sudyTouch({
  380. "swipeStart": function(){
  381. c.trigger('mouseenter');
  382. },
  383. "swipeLeft": function(){
  384. playNext();
  385. },
  386. "swipeRight": function(){
  387. playPrev();
  388. },
  389. "swipeEnd": function(){
  390. c.trigger('mouseleave');
  391. }
  392. });
  393. }
  394. //初始化
  395. showIndex();
  396. });
  397. };
  398. })(jQuery);
  399. /*
  400. ** other extends
  401. */
  402. !function(a){a.fn.sudySelect=function(b){var c={handle:".select-name",selects:".select-list",trigger:"click",effect:"slide",speed:100,dir:"down",autoWidth:!0},d=a.extend(!0,{},c,b);return this.each(function(){function g(){"slide"==d.effect?e.stop(!0,!0).slideDown(d.speed):"fade"==d.effect?e.stop(!0,!0).fadeIn(d.speed):$vp.show()}function h(){"slide"==d.effect?e.stop(!0,!1).slideUp(d.speed):"fade"==d.effect?e.stop(!0,!1).fadeOut(d.speed):e.hide()}var b=a(this),c=a(this).find(d.handle),e=a(this).find(d.selects),f=c.outerHeight();d.autoWidth&&e.children().css({"padding-left":c.css("padding-left"),"padding-right":c.css("padding-right")}),"down"==d.dir?(b.addClass("select-down"),e.css({top:f+"px",bottom:"auto"})):"up"==d.dir&&(b.addClass("select-up"),e.css({bottom:f+"px",top:"auto"})),c.on(d.trigger,function(){"click"==d.trigger?(c.toggleClass("select-open"),c.hasClass("select-open")?g():h()):(c.addClass("select-open"),g()),e.children().removeClass("hover")}),b.on("mouseleave",function(){c.removeClass("select-open"),h()}),e.children().mouseenter(function(){a(this).addClass("hover").siblings().removeClass("hover")}),e.children().on("click",function(){c.text(a(this).text()),a(this).addClass("selected").siblings().removeClass("selected"),c.removeClass("select-open"),h()}).eq(0).trigger("click")})},a.fn.sudyPubdate=function(b){function e(a){var b=a;switch(a){case 1:b="\u4e00\u6708";break;case 2:b="\u4e8c\u6708";break;case 3:b="\u4e09\u6708";break;case 4:b="\u56db\u6708";break;case 5:b="\u4e94\u6708";break;case 6:b="\u516d\u6708";break;case 7:b="\u4e03\u6708";break;case 8:b="\u516b\u6708";break;case 9:b="\u4e5d\u6708";break;case 10:b="\u5341\u6708";break;case 11:b="\u5341\u4e00\u6708";break;case 12:b="\u5341\u4e8c\u6708"}return b}function f(a){var b=a;switch(a){case 1:b="Jan";break;case 2:b="Feb";break;case 3:b="Mar";break;case 4:b="Apr";break;case 5:b="May";break;case 6:b="Jun";break;case 7:b="Jul";break;case 8:b="Aug";break;case 9:b="Sep";break;case 10:b="Oct";case 11:b="Nov";break;case 12:b="Dec"}return b}var c={target:".pubdate",lang:"num",separator:"-",format:"\u5e74\u6708\u65e5",prefix_0:!0,tpl:'<div class="sudy-pubdate"><span class="pubdate-month">%m%\u6708</span><span class="pubdate-day">%d%</span></div>'},d=a.extend(!0,{},c,b);return this.each(function(){var c=(a(this),a(this).find(d.target)),g=a.trim(c.text()).split(d.separator),h=parseInt(g[d.format.indexOf("\u5e74")],10),i=parseInt(g[d.format.indexOf("\u6708")],10),j=parseInt(g[d.format.indexOf("\u65e5")],10);"en"==d.lang&&(i=f(i)),"cn"==d.lang&&(i=e(i)),"num"==d.lang&&d.prefix_0&&(i=10>i?"0"+i:i,j=10>j?"0"+j:j);var k=d.tpl.replace("%Y%",h).replace("%m%",i).replace("%d%",j);c.html(k)})},a.fn.sudyTab=function(b){var c={handle:".tab-menu > li",content:".tab-list > li,.tab-more > li",trigger:"mouseenter",start:1,autoPlay:{active:!1,interval:4e3,pauseHover:!0}},d=a.extend(!0,{},c,b);return this.each(function(){var b=a(this),c=a(this).find(d.handle),e=d.content.split(","),f=d.start-1,g=c.length,h=f;if(a.each(c,function(f,g){a(g).on(d.trigger,function(){h=f,c.removeClass("selected"),a(this).addClass("selected"),a.each(e,function(c,d){a(d,b).removeClass("active").hide(),a(d,b).eq(f).addClass("active").show()})})}),d.autoPlay.active){var i,h,j=function(a){c.eq(a).trigger(d.trigger),i=setTimeout(function(){a++,a>g-1&&(a=0),j(a)},d.autoPlay.interval)};j(f),b.hover(function(){clearTimeout(i)},function(){j(h)})}else c.eq(f).trigger(d.trigger)})},a.fn.sudyInput=function(b){var c={tip:".tip"},d=a.extend(!0,{},c,b);return this.each(function(){function f(){var a=e.val();a!==c.text()&&""!==a?c.hide():(c.show(),e.val(""))}var b=a(this),c=a(this).find(d.tip),e=a(this).find("input,textarea");b.click(function(){e.trigger("focus")}),e.focus(function(){c.hide()}),e.blur(function(){f()})})},a.fn.sudyClock=function(b){var c={format:"%Y%\u5e74%M%\u6708%D%\u65e5 %N% %H%:%m%:%s% %W% \u8ddd\u79bb100\u5468\u5e74\u56fd\u5e86\u8fd8\u6709 %CD% \u5929",hour12:!1,noon:"cn",week:"cn",countDown:"2049/10/1"},d=a.extend(!0,{},c,b),e=function(a){var b=parseInt(a);return 10>b&&(b="0"+b),b},f=function(){var a=new Date,b=a.getFullYear(),c=a.getMonth()+1,f=a.getDate(),g=a.getHours(),h=a.getMinutes(),i=a.getSeconds(),j="cn"==d.week?["\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94","\u661f\u671f\u516d"][a.getDay()]:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][a.getDay()],k="cn"==d.noon?["\u4e0a\u5348","\u4e0b\u5348"][12>g?0:1]:["AM","PM"][12>g?0:1],l=0;return g=d.hour12&&g>12?g-12:g,l=Math.ceil((Date.parse(d.countDown)-a.getTime())/864e5),{Y:b,M:e(c),D:e(f),H:e(g),m:e(h),s:e(i),W:j,N:k,C:l}};return this.each(function(){function e(){c=d.format.replace("%Y%",f().Y).replace("%M%",f().M).replace("%D%",f().D).replace("%H%",f().H).replace("%m%",f().m).replace("%s%",f().s).replace("%W%",f().W).replace("%N%",f().N).replace("%CD%",f().C),b.html(c),setTimeout(function(){e()},500)}var c,b=a(this);e()})},a.fn.sudyLinks=function(b){var c={handle:".links-name",wrap:".links-wrap",trigger:"mouseenter",effect:"show",speed:300,hidePause:0,type:"elink",width:"block",position:!0},d=a.extend(!0,{},c,b);return this.each(function(){var h,b=a(this),c=a(this).find(d.handle),e=a(this).find(d.wrap),f=c.outerHeight(),i=e.outerHeight(),f=e.css("bottom");"block"==d.width&&(b.css("display","block"),c.css("display","block")),/\d+/.test(d.width)&&(b.css("width",d.width),c.css("display","block")),"elink"==d.type&&e.css("width",b.width()-2),b.on(d.trigger,function(){var g=b.offset().top,j=a(window).scrollTop(),k=g-j;i>k?e.css({bottom:"auto",top:f}):e.css({top:"auto",bottom:f}),clearTimeout(h),d.position&&b.css("position","relative"),c.addClass("wrap-open"),"slide"==d.effect?e.stop(!0,!0).hide().slideDown(d.speed):"fade"==d.effect?e.stop(!0,!0).hide().fadeIn(d.speed):e.show()}),b.mouseleave(function(){h=setTimeout(function(){d.position&&b.css("position","static"),c.removeClass("wrap-open"),"slide"==d.effect?e.stop(!0,!0).slideUp(d.speed):"fade"==d.effect?e.stop(!0,!0).fadeOut(d.speed):e.hide()},d.hidePause)})})},a.fn.sudyScroll=function(b){var c={width:200,height:100,display:2,step:2,dir:"y",auto:!0,speed:500,hoverPause:5e3,navigation:!0,navTrigger:"click",pagination:!0,pagTrigger:"mouseenter"},d=a.extend(!0,{},c,b);return this.each(function(){function n(){a(".page-index",l).eq(i).addClass("active").siblings().removeClass("active")}function o(){"x"==d.dir?(j=-i*d.step*d.width,b.stop().animate({left:j+"px"},d.speed)):(k=-i*d.step*d.height,b.stop().animate({top:k+"px"},d.speed)),n()}function p(){i++,i>h-1&&(i=0),o(i)}function q(){i--,0>i&&(i=h-1),o(i)}a(this).wrap('<div class="sudy-scroll-wrap">');var b=a(this),c=a(this).children(),e=c.length,f=a(this).parent(),g="scroll-"+Number(new Date),h=Math.ceil(e/d.step),i=0,j=0,k=0;d.step=d.step>d.display?d.display:d.step,f.wrap('<div class="sudy-scroll" id="'+g+'">');var l=a(this).parent().parent();if("x"==d.dir?(l.css({width:d.width*d.display+"px",height:d.height+"px"}),f.css({width:d.width*d.display+"px",height:d.height+"px"}),b.css({width:d.width*e+"px",height:d.height+"px",position:"absolute",left:"0px",top:"0px"}),c.css({width:d.width+"px",height:d.height+"px","float":"left",display:"inline-block"})):(l.css({width:d.width+"px",height:d.height*d.display+"px"}),f.css({width:d.width+"px",height:d.height*d.display+"px"}),b.css({width:d.width+"px",position:"absolute",left:"0px",top:"0px"}),c.css({width:d.width+"px",height:d.height+"px"})),d.navigation&&l.append('<div class="sudy-scroll-nav"><a href="javascript:;" class="nav-prev">&lt;</a><a href="javascript:;" class="nav-next">&gt;</a></div>'),d.pagination){var m='<div class="sudy-scroll-page">';a.each(new Array(h),function(a){m=m+'<a class="page-index page-'+a+'" href="javascript:;"><span>'+a+"</span></a>"}),l.append(m)}if(o(i),d.auto){var r;l.hover(function(){clearTimeout(r)},function(){r=setTimeout(function(){p(),l.trigger("mouseleave")},d.hoverPause)}).trigger("mouseleave")}a(".nav-next",l).on(d.navTrigger,function(){p()}),a(".nav-prev",l).on(d.navTrigger,function(){q()}),a(".page-index",l).on(d.pagTrigger,function(){i=a(this).index(),o(i)})})}}(jQuery);