script.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  1. ;(function ($) {
  2. var config = {};
  3. $(window).bind('load', function () {
  4. reset();
  5. });
  6. $(window).bind('resize', function () {
  7. reset();
  8. $('.works').each(function () {
  9. $(this).find('img').attr('width', '').attr('height', '');
  10. });
  11. });
  12. function reset() {
  13. config.w = $(window).width();
  14. config.h = $(window).height();
  15. $('#menu').height(config.h);
  16. config.ww = $('.website').width();
  17. $('.website li,.website').width(config.ww);
  18. config.wl = $('.website li').length;
  19. $('.website ul').width(config.wl * config.ww);
  20. $('.ct').height(config.h - 60);
  21. if ($('.title_d').width() - $('.title').width() > 0) {
  22. $('.title_d').addClass('round');
  23. } else {
  24. $('.title_d').removeClass('round');
  25. }
  26. ;
  27. if (document.getElementById('newwrap_t')) {
  28. $('#newwrap_t,#newwrap').width(config.w);
  29. }
  30. $('#myfavorites li').width(($('#myfavorites ul').width() - 10) / 2);
  31. $('#myfavorites li span').width(($('#myfavorites li').width() - 20) / 3);
  32. }
  33. var touchEnd;
  34. var dd = 0;
  35. function tcst() {
  36. $('#list li').bind('touchstart touchmove touchend', function (e) {
  37. if (e.type == 'touchstart') {
  38. $(this).addClass('touch');
  39. } else if (e.type == 'touchend') {
  40. $(this).removeClass('touch');
  41. } else {
  42. var _this = $(this);
  43. clearTimeout(touchEnd);
  44. touchEnd = setTimeout(function () {
  45. _this.removeClass('touch');
  46. }, 100);
  47. }
  48. });
  49. $('#ListHalf li').bind('touchstart touchmove touchend', function (e) {
  50. if (e.type == 'touchstart') {
  51. $(this).addClass('touch');
  52. } else if (e.type == 'touchend') {
  53. $(this).removeClass('touch');
  54. } else {
  55. var _this = $(this);
  56. clearTimeout(touchEnd);
  57. touchEnd = setTimeout(function () {
  58. _this.removeClass('touch');
  59. }, 100);
  60. }
  61. });
  62. }
  63. tcst();
  64. $('.post_comment').bind('touchstart touchend', function (e) {
  65. if (e.type == 'touchstart') {
  66. $(this).find('a').addClass('ton');
  67. } else {
  68. $(this).find('a').removeClass('ton');
  69. }
  70. });
  71. $('#header i').bind('touchstart touchmove touchend', function (e) {
  72. if (e.type == 'touchstart') {
  73. $(this).addClass('ton');
  74. } else if (e.type == 'touchmove') {
  75. $(this).removeClass('ton');
  76. } else {
  77. $(this).removeClass('ton');
  78. }
  79. });
  80. /*var reply_lock = false;
  81. $('#content').bind('touchstart touchmove touchend', function (e) {
  82. if ($('#container').hasClass('push') == false && $('#container').hasClass('pull') == false) {
  83. var t = event.touches[0];
  84. if (e.type == 'touchstart') {
  85. config.touchY = t.pageY;
  86. } else if (e.type == 'touchmove') {
  87. config.touchEY = t.pageY - config.touchY;
  88. if (config.touchEY > 0) {
  89. $('#header,#us_panel,#us_panel2').removeClass('hide');
  90. $('.post_comment_content textarea').blur();
  91. $('.post_comment_content,#send_msg').removeClass('show');
  92. $('#us_panel').css({'position': 'fixed', 'bottom': '0'});
  93. reply_lock = false;
  94. } else if (config.touchEY < 0) {
  95. $('#header,#us_panel,#us_panel2').addClass('hide');
  96. $('.post_comment_content textarea').blur();
  97. $('#us_panel').css({'position': 'fixed', 'bottom': '0'});
  98. $('.post_comment_content,#send_msg').removeClass('show');
  99. reply_lock = false;
  100. }
  101. } else {
  102. }
  103. }
  104. });*/
  105. $('.menu_open').bind('click', function (e) {
  106. if ($('#container').hasClass('pull') == false) {
  107. if (dd == 0) {
  108. $('#container,#menu,#header,#us_panel').addClass('push');
  109. dd = 1;
  110. $(window).bind('touchmove', function (e) {
  111. e.preventDefault();
  112. e.stopImmediatePropagation();
  113. });
  114. $('#us_panel').addClass('hide');
  115. } else {
  116. $('#container,#menu,#header,#us_panel').removeClass('push');
  117. dd = 0;
  118. $(window).unbind('touchmove');
  119. }
  120. ;
  121. }
  122. return false;
  123. });
  124. $('.search_open').bind('click', function (e) {
  125. if ($('#container').hasClass('push') == false) {
  126. if (dd == 0) {
  127. $('#container,#user,#header,#us_panel').addClass('pull');
  128. dd = 1;
  129. $(window).bind('touchmove', function (e) {
  130. e.preventDefault();
  131. e.stopImmediatePropagation();
  132. });
  133. $('#us_panel').addClass('hide');
  134. } else {
  135. $('#container,#user,#header,#us_panel').removeClass('pull');
  136. dd = 0;
  137. $(window).unbind('touchmove');
  138. }
  139. }
  140. return false;
  141. });
  142. $('.push_msk').bind('touchmove', function (e) {
  143. if ($('#container').hasClass('pull')) {
  144. $('.search_open').trigger('click');
  145. } else if ($('#container').hasClass('push')) {
  146. $('.menu_open').trigger('click');
  147. }
  148. return false;
  149. });
  150. $('.hd .fr,.ct_submit,.user_logout,.comment_reply_submit,.more_comment,.visit_site a,.sort_b,.cancel_share a,.message_system li,.delete_check_sure,.delete_check_cancel,#choose_album li a').bind('touchstart touchend', function (e) {
  151. if (e.type == 'touchstart') {
  152. $(this).addClass('ton');
  153. } else {
  154. $(this).removeClass('ton');
  155. }
  156. });
  157. $('.search_input').bind('input', function () {
  158. if ($('.search_input').val().length > 0) {
  159. $('.reset_input').show();
  160. } else {
  161. $('.reset_input').hide();
  162. }
  163. });
  164. $('.reset_input').bind('touchstart touchend', function (e) {
  165. if (e.type == 'touchstart') {
  166. $('.search_input').val('');
  167. $('.reset_input').addClass('ton');
  168. } else if (e.type == 'touchend') {
  169. $('.reset_input').removeClass('ton').hide();
  170. }
  171. });
  172. $('#reg_now').bind('click', function () {
  173. $('#reg_index').addClass('show');
  174. $(window).unbind('touchmove');
  175. });
  176. $('.reg_bar_close').bind('touchstart touchend click', function (e) {
  177. if (e.type == 'touchstart') {
  178. $(this).addClass('ton');
  179. } else if (e.type == 'touchend') {
  180. $(this).removeClass('ton');
  181. } else {
  182. if (document.getElementById('us_panel')) {
  183. $('#reg_index').removeClass('show');
  184. $(window).bind('touchmove', function (e) {
  185. e.preventDefault();
  186. e.stopImmediatePropagation();
  187. });
  188. } else {
  189. $('#reg_index').removeClass('show');
  190. }
  191. }
  192. });
  193. $('.login').bind('click', function () {
  194. $('#login_index').addClass('show');
  195. $(window).unbind('touchmove');
  196. });
  197. $('.login_bar_close').bind('touchstart touchend click', function (e) {
  198. if (e.type == 'touchstart') {
  199. $(this).addClass('ton');
  200. } else if (e.type == 'touchend') {
  201. $(this).removeClass('ton');
  202. } else {
  203. $('#login_index').removeClass('show');
  204. $(window).bind('touchmove', function (e) {
  205. e.preventDefault();
  206. e.stopImmediatePropagation();
  207. });
  208. }
  209. });
  210. $('.login_user input,.login_password input').bind('input', function () {
  211. if ($(this).val().length > 0) {
  212. $(this).parent().find('i').show();
  213. loginIpt();
  214. } else {
  215. $(this).parent().find('i').hide();
  216. }
  217. });
  218. function loginIpt() {
  219. $('.login_user i').bind('touchstart touchend', function (e) {
  220. if (e.type == 'touchstart') {
  221. $(this).addClass('ton');
  222. } else {
  223. $(this).parent().find('input').val('');
  224. $(this).hide();
  225. $(this).removeClass('ton');
  226. }
  227. });
  228. $('.login_password i').bind('touchstart touchend', function (e) {
  229. if (e.type == 'touchstart') {
  230. $(this).addClass('ton');
  231. } else {
  232. $(this).parent().find('input').val('');
  233. $(this).hide();
  234. $(this).removeClass('ton');
  235. }
  236. });
  237. };
  238. $('#add_f').click(function () {
  239. var i = parseInt($(this).find('.lf span').html());
  240. if ($(this).hasClass('liked')) {
  241. var _this = $(this);
  242. $.post("http://m.yiwubaike.com/service/removeLike", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2}, function () {
  243. _this.removeClass('liked');
  244. _this.find('.lf span').html(i - 1);
  245. });
  246. } else {
  247. var _this = $(this);
  248. $.post("http://m.yiwubaike.com/service/addLike", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2}, function () {
  249. _this.addClass('liked');
  250. _this.find('.lf span').html(i + 1);
  251. });
  252. }
  253. });
  254. var wbI = 0;
  255. config.stx, config.edx, config.ttx = 0;
  256. $('.website').bind('touchstart touchmove touchend', function (e) {
  257. if (e.type == 'touchstart') {
  258. var t = e.touches[0];
  259. config.stx = t.pageX, config.sty = t.pageY;
  260. } else if (e.type == 'touchmove') {
  261. var t = e.touches[0];
  262. config.edx = t.pageX, config.edy = t.pageY;
  263. document.querySelector('.website ul').style.webkitTransform = 'translateX(' + ((config.edx - config.stx) + config.ttx) + 'px)';
  264. document.querySelector('.website ul').style.oTransform = 'translateX(' + ((config.edx - config.stx) + config.ttx) + 'px)';
  265. document.querySelector('.website ul').style.mozTransform = 'translateX(' + ((config.edx - config.stx) + config.ttx) + 'px)';
  266. document.querySelector('.website ul').style.transform = 'translateX(' + ((config.edx - config.stx) + config.ttx) + 'px)';
  267. if (config.edx - config.stx < 0) {
  268. e.preventDefault();
  269. }
  270. if (config.edx - config.stx > 0) {
  271. e.preventDefault();
  272. }
  273. } else {
  274. if (config.edx - config.stx <= 60 && config.edx - config.stx >= -60) {
  275. $('.website ul').animate({translate3d: '-' + (config.ww * wbI) + 'px,0,0'}, 300, 'cubic-bezier(0.175, 0.885, 0.32, 1.275)');
  276. e.preventDefault();
  277. }
  278. if (config.edx - config.stx > 60) {
  279. (wbI > 0) ? wbI-- : wbI = 0;
  280. $('.website ul').animate({translate3d: '-' + (config.ww * wbI) + 'px,0,0'}, 300, 'ease-in-out');
  281. e.preventDefault();
  282. }
  283. if (config.edx - config.stx < -60) {
  284. (wbI < config.wl - 1) ? wbI++ : wbI = config.wl - 1;
  285. $('.website ul').animate({translate3d: '-' + (config.ww * wbI) + 'px,0,0'}, 300, 'ease-in-out');
  286. e.preventDefault();
  287. }
  288. config.edx = 0, config.stx = 0, config.ttx = -config.ww * wbI;
  289. }
  290. });
  291. $('.designer_more').each(function () {
  292. $(this).find('a').each(function () {
  293. if ($(this).html() == '') {
  294. $(this).click(function () {
  295. return false;
  296. });
  297. }
  298. });
  299. });
  300. function addRela() {
  301. $('.relationship a').bind('click', function () {
  302. var _this = $(this);
  303. if (_this.hasClass('need_login')) {
  304. $('#reg_index').addClass('show');
  305. } else {
  306. if ($(this).hasClass('add_friend') && $(this).hasClass('need_login') == false) {
  307. $.post("http://m.yiwubaike.com/service/addFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: $(this).attr('data-uid')}, function () {
  308. _this.removeClass('add_friend').addClass('remove_friend');
  309. });
  310. } else if ($(this).hasClass('remove_friend') && $(this).hasClass('need_login') == false) {
  311. $.post("http://m.yiwubaike.com/service/removeFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: $(this).attr('data-uid')}, function () {
  312. _this.removeClass('remove_friend').addClass('add_friend');
  313. });
  314. } else if ($(this).hasClass('rela_friend') && $(this).hasClass('need_login') == false) {
  315. $.post("http://m.yiwubaike.com/service/removeFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: $(this).attr('data-uid')}, function () {
  316. _this.removeClass('rela_friend').addClass('add_friend');
  317. });
  318. }
  319. }
  320. });
  321. }
  322. addRela();
  323. $('#sort td').bind('click', function () {
  324. $('#sort_content').addClass('show');
  325. $('.asort').eq($(this).index()).addClass('show');
  326. });
  327. $('.asort .hd .fr').bind('click', function () {
  328. $('#sort_content').removeClass('show');
  329. var _this = $(this);
  330. setTimeout(function () {
  331. _this.parent().parent().parent().removeClass('show');
  332. }, 300);
  333. });
  334. var dt = ['', '', '', ''], scLock;
  335. $('.ct li').click(function () {
  336. if (document.getElementById('add_favorites_choose')) {
  337. var _this = $(this), d = $(this).attr('data-id');
  338. if ($(this).hasClass('a_selected') == false) {
  339. $.post("http://m.yiwubaike.com/service/addLike", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2, cid: d}, function () {
  340. _this.siblings().removeClass('a_selected');
  341. _this.addClass('a_selected');
  342. $('#add_favorite .hd .fr').trigger('click');
  343. $('.us_panel_like').addClass('liked');
  344. $('.us_panel_like span em').html(parseInt($('.us_panel_like span em').html()) + 1);
  345. });
  346. }
  347. } else {
  348. var v = $(this).find('span').html();
  349. var i = $(this).parent().parent().parent().parent().index();
  350. if ($(this).hasClass('a_selected') && $(this).find('.s').attr('class') == undefined) {
  351. var _this = $(this);
  352. dt[1] = '';
  353. $.get('http://m.yiwubaike.com/list/', {fid: dt[0], owner: dt[1], sort: dt[2], search: search_value}, function (data) {
  354. $('.sort_tag .sort_b_inner span').html('检索列表');
  355. var v = $(data).find('#list ul').html();
  356. $('#list ul').html(v);
  357. tcst();
  358. _this.removeClass('a_selected');
  359. var dd = _this.parent().parent().parent().parent().find('.fr');
  360. dd.trigger('click');
  361. /*$('.alist').openNewFrame();*/
  362. });
  363. } else {
  364. $(this).parent().parent().find('li').removeClass('a_selected');
  365. $(this).addClass('a_selected');
  366. if ($(this).attr('c_data')) {
  367. if ($(this).attr('c_data') != '') {
  368. dt[0] = $(this).attr('c_data');
  369. } else {
  370. dt[0] = '';
  371. }
  372. } else if ($(this).attr('t_data')) {
  373. dt[1] = $(this).attr('t_data').substring($(this).attr('t_data').indexOf('=') + 1, $(this).attr('t_data').length);
  374. } else {
  375. dt[2] = $(this).attr('s_data');
  376. }
  377. var dd = $(this).parent().parent().parent().parent().find('.fr');
  378. $.get('http://m.yiwubaike.com/list/', {fid: dt[0], owner: dt[1], sort: dt[2], search: search_value}, function (data) {
  379. var v = $(data).find('#list ul').html();
  380. $('#list ul').html(v);
  381. dd.trigger('click');
  382. tcst();
  383. $('.alist').openNewFrame();
  384. });
  385. $('#sort td').eq(i).find('.sort_b_inner span').html(v);
  386. if ($(this).find('.s').attr('class')) {
  387. var d = $(this).find('.s').attr('class');
  388. $('#sort td').eq(i).find('.sort_b_inner i').attr('class', d);
  389. }
  390. }
  391. scLock = true, now_page = 1;
  392. $('.list_loading').html('<i></i><span>努力加载中...</span>');
  393. }
  394. });
  395. var postReplyId, cmofsT = 0;
  396. if (document.getElementById('more_about')) {
  397. cmofsT = $('#more_about').offset().top;
  398. }
  399. $('#post_comment_btn').click(function () {
  400. if ($('.post_comment_content').hasClass('show')) {
  401. if (reply_lock == false) {
  402. if ($('#post_comment_content').val() != '') {
  403. $.post("http://m.yiwubaike.com/service/postnewComment", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2, content: $('#post_comment_content').val()}, function (data) {
  404. $('#comment ul').prepend('<li postdata="' + data.id + '" usdata="' + comment_id + '"><div class="pd5"><a class="avt fl" target="_blank" href="' + comment_at_url + '"><img src="' + comment_avatar + '"></a><div class="comment_content"><h5><div class="fl"><a class="comment_name" href="' + comment_at_url + '">' + comment_author + '</a><span>' + data.postdate + '</span></div><div class="fr reply_this">[回复]</div><div class="clear"></div></h5><div class="comment_p">' + data.content + '</div></div><div class="clear"></div><div class="comment_reply"></div></div></li>');
  405. document.getElementById('container').scrollTop = cmofsT;
  406. reply_lock = false;
  407. }, 'json');
  408. } else {
  409. return false;
  410. }
  411. } else {
  412. if ($('#post_comment_content').val() != '') {
  413. $.post("http://m.yiwubaike.com/service/postnewComment", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2, postcid: _cid, postuid: comment_id, content: $('#post_comment_content').val()}, function (data) {
  414. var ddd = '<div class="quote"><div class="pd10">' + _ct + '</div></div>';
  415. $('#comment ul').prepend('<li postdata="' + data.id + '" usdata="' + comment_id + '"><div class="pd5"><a class="avt fl" target="_blank" href="' + comment_at_url + '"><img src="' + comment_avatar + '"></a><div class="comment_content"><h5><div class="fl"><a class="comment_name" href="' + comment_at_url + '">' + comment_author + '</a><span>' + data.postdate + '</span></div><div class="fr reply_this">[回复]</div><div class="clear"></div></h5><div class="comment_p">' + data.content + ddd + '</div></div><div class="clear"></div><div class="comment_reply"></div></div></li>');
  416. document.getElementById('container').scrollTop = cmofsT;
  417. reply_lock = false;
  418. }, 'json');
  419. } else {
  420. return false;
  421. }
  422. }
  423. } else {
  424. if ($(this).hasClass('atc')) {
  425. $('.post_comment_content').addClass('show');
  426. $('#post_comment_content').val('').attr('placeholder', '发表评论');
  427. document.getElementById('post_comment_content').focus();
  428. $('#us_panel').css({'position': 'absolute', 'bottom': '0px'});
  429. } else {
  430. $('#login_index').addClass('show');
  431. }
  432. }
  433. });
  434. var rmsInt, rmsId, rmsLock = true;
  435. $('.remove_msg').click(function () {
  436. rmsInt = $(this).parent().parent();
  437. rmsId = rmsInt.attr('data-messages');
  438. $('#delete_check').addClass('show');
  439. $('.delete_check_cancel,.delete_check').click(function () {
  440. $('#delete_check').removeClass('show');
  441. });
  442. $('.delete_check_sure').click(function () {
  443. if (rmsLock) {
  444. rmsLock = false;
  445. $.post("http://m.yiwubaike.com/service/delMessage", {timestamp: YYToken.timestamp, token: YYToken.token, id: rmsId}, function () {
  446. $('#delete_check').removeClass('show');
  447. rmsInt.animate({opacity: 0, translateX: '100%'}, 300, 'ease-in-out', function () {
  448. rmsInt.remove();
  449. });
  450. rmsLock = true;
  451. });
  452. }
  453. });
  454. });
  455. $('#reply_msg_area').bind('input', function () {
  456. if ($('#reply_msg_area').val() != '') {
  457. $('.reply_msg_post').addClass('checked');
  458. } else {
  459. $('.reply_msg_post').removeClass('checked');
  460. }
  461. });
  462. if (document.getElementById('reply_msg')) {
  463. $('#content').css('paddingBottom', 120);
  464. }
  465. $('.reply_msg_post').click(function () {
  466. if ($(this).hasClass('checked')) {
  467. $.post("http://m.yiwubaike.com/service/sendSMS", {timestamp: YYToken.timestamp, token: YYToken.token, content: $('#reply_msg_area').val(), nickname: reply_nickname}, function () {
  468. $.get("http://m.yiwubaike.com/sms", {id: reply_post_id}, function (data) {
  469. var v = $(data).find('.message_private_reply ul').html();
  470. $('.message_private_reply ul').html(v);
  471. $('#reply_msg_area').val('');
  472. });
  473. });
  474. } else {
  475. return false;
  476. }
  477. });
  478. if (document.getElementById('reply_msg')) {
  479. $('.menu_refresh').click(function () {
  480. $.get("http://m.yiwubaike.com/sms", {id: reply_post_id}, function (data) {
  481. var v = $(data).find('.message_private_reply ul').html();
  482. $('.message_private_reply ul').html(v);
  483. });
  484. });
  485. }
  486. var choose_cate = ['_cate_all', '_cate_creat', '_cate_site', '_cate_inspire', '_cate_article', '_cate_app'], choose_sort = ['sort_re', 'sort_recom', 'sort_fa', 'sort_vi', 'sort_com'];
  487. $('.choose_cate li').each(function (i) {
  488. });
  489. $('.choose_sort li').each(function (i) {
  490. $(this).find('.s').addClass(choose_sort[i]);
  491. });
  492. if (document.getElementById('list')) {
  493. $(window).bind('load', function () {
  494. scLock = true;
  495. // $('.alist').openNewFrame();
  496. $('#container').bind('scroll', function () {
  497. var t = $('#container').scrollTop();
  498. if (t >= ($('#list').height() - $(window).height()) && scLock == true) {
  499. now_page++;
  500. scLock = false;
  501. $.get('http://m.yiwubaike.com/list/', {page: now_page, fid: dt[0], owner: dt[1], sort: dt[2], search: search_value}, function (data) {
  502. var v = $(data).find('#list ul').html();
  503. $('#list ul').append(v);
  504. var patt1 = new RegExp("alist");
  505. if (patt1.test(v)) {
  506. scLock = true;
  507. } else {
  508. $('.list_loading').html('<span>没有了!</span>');
  509. }
  510. tcst();
  511. /*$('.alist').openNewFrame();*/
  512. });
  513. }
  514. });
  515. });
  516. }
  517. $('.more_comment').click(function () {
  518. $.post("http://m.yiwubaike.com/service/getcomment", {timestamp: YYToken.timestamp, token: YYToken.token, lastid: $('#comment li').eq($('#comment li').length - 1).attr('postdata'), postid: commentId2}, function (data) {
  519. for (i = 0; i < data.length; i++) {
  520. var ddd = '';
  521. if (data[i].comment) {
  522. ddd = '<div class="quote"><div class="pd10">' + data[i].comment.content + '</div></div>';
  523. }
  524. var ser = '<li postdata="' + data[i].id + '"><div class="pd5"><a class="avt fl" target="_blank" href="' + data[i].userurl + '"><img src="' + data[i].userimage + '"></a><div class="comment_content"><h5><div class="fl"><a class="comment_name" href="' + data[i].userurl + '">' + data[i].nickname + '</a><span>' + data[i].postdate + '</span></div><div class="fr reply_this">[回复]</div><div class="clear"></div></h5><div class="comment_p"><div class="comment_pct">' + data[i].content + '</div>' + ddd + '</div></div><div class="clear"></div><div class="comment_reply"></div></div></li>';
  525. $('#comment ul').append(ser);
  526. }
  527. replyThis();
  528. }, 'json');
  529. });
  530. $('.works').each(function () {
  531. var v = $(this).find('a img').attr('vsrc');
  532. $(this).find('a img').attr('vsrc', v.replace(/1140x0.jpg/, '800x0.jpg'));
  533. });
  534. if (document.getElementById('designer_list')) {
  535. $(window).bind('load', function () {
  536. scLock = true;
  537. $('#container').bind('scroll', function () {
  538. var t = $('#container').scrollTop();
  539. if (t >= ($('#designer_list').height() - $(window).height()) && scLock == true) {
  540. designers_page++;
  541. scLock = false;
  542. $.get('http://m.yiwubaike.com/designers/', {page: designers_page, sort: designers_sort}, function (data) {
  543. var v = $(data).find('#designer_list ul').html();
  544. $('#designer_list ul').append(v);
  545. addRela();
  546. var patt1 = new RegExp("designer_more");
  547. if (patt1.test(v)) {
  548. scLock = true;
  549. } else {
  550. $('.list_loading').html('<span>没有了!</span>');
  551. }
  552. });
  553. }
  554. });
  555. });
  556. }
  557. $('.add_fans').click(function () {
  558. var _this = $(this);
  559. $.post("http://m.yiwubaike.com/service/addFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: _this.attr('data-uid')}, function () {
  560. _this.removeClass('add_fans').addClass('remove_fans');
  561. $('.remove_fans').html('取消关注');
  562. });
  563. });
  564. $('.remove_fans').click(function () {
  565. var _this = $(this);
  566. $.post("http://m.yiwubaike.com/service/removeFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: _this.attr('data-uid')}, function () {
  567. _this.removeClass('remove_fans').addClass('add_fans');
  568. $('.add_fans').html('加关注');
  569. });
  570. });
  571. $('.home_remove_f').click(function () {
  572. if ($(this).hasClass('need_login')) {
  573. $('#reg_index').addClass('show');
  574. } else {
  575. var _this = $(this);
  576. $.post("http://m.yiwubaike.com/service/removeFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: _this.attr('data-uid')}, function () {
  577. _this.removeClass('home_remove_f').addClass('home_add_f');
  578. $('.home_add_f').find('span').html('加关注');
  579. });
  580. }
  581. });
  582. $('.home_rela_f').click(function () {
  583. if ($(this).hasClass('need_login')) {
  584. $('#reg_index').addClass('show');
  585. } else {
  586. var _this = $(this);
  587. $.post("http://m.yiwubaike.com/service/removeFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: _this.attr('data-uid')}, function () {
  588. _this.removeClass('home_rela_f').addClass('home_add_f');
  589. $('.home_add_f').find('span').html('加关注');
  590. });
  591. }
  592. });
  593. $('.home_add_f').click(function () {
  594. if ($(this).hasClass('need_login')) {
  595. $('#reg_index').addClass('show');
  596. } else {
  597. var _this = $(this);
  598. $.post("http://m.yiwubaike.com/service/addFollow", {timestamp: YYToken.timestamp, token: YYToken.token, uid: _this.attr('data-uid')}, function () {
  599. _this.removeClass('home_add_f').addClass('home_remove_f');
  600. $('.home_remove_f').find('span').html('取消关注');
  601. });
  602. }
  603. });
  604. var send_me;
  605. $('.home_send').click(function () {
  606. if ($(this).hasClass('need_login')) {
  607. $('#reg_index').addClass('show');
  608. } else {
  609. $('#send_msg').addClass('show');
  610. send_me = $(this).attr('data-name');
  611. }
  612. });
  613. $('#send_msg_content').bind('input', function () {
  614. if ($('#send_msg_content').val() != '') {
  615. $('.send_msg_to').addClass('checked');
  616. } else {
  617. $('.send_msg_to').removeClass('checked');
  618. }
  619. });
  620. $('.send_msg_to').click(function () {
  621. if ($(this).hasClass('checked')) {
  622. $.post("http://m.yiwubaike.com/service/sendSMS", {timestamp: YYToken.timestamp, token: YYToken.token, content: $('#send_msg_content').val(), nickname: send_me}, function () {
  623. $('#send_msg_content').val('');
  624. document.getElementById('send_msg_content').blur();
  625. $('#send_msg').removeClass('show');
  626. });
  627. } else {
  628. return false;
  629. }
  630. });
  631. if (document.getElementById('myworks')) {
  632. if ($('#myworks').hasClass('my_favorites')) {
  633. $(window).bind('load', function () {
  634. var scLock = true;
  635. $('#container').bind('scroll', function () {
  636. var t = $('#container').scrollTop();
  637. if (t >= ($('#myworks').height() - $(window).height()) && scLock == true) {
  638. now_page++;
  639. scLock = false;
  640. $.get(now_page_url + '/list/' + now_page_cur + '/' + albumId + '/', {page: now_page}, function (data) {
  641. var v = $(data).find('#myworks ul').html();
  642. $('#myworks ul').append(v);
  643. var patt1 = new RegExp("alist");
  644. if (patt1.test(v)) {
  645. scLock = true;
  646. } else {
  647. $('.list_loading').html('<span>没有了!</span>');
  648. }
  649. /*$('.alist').openNewFrame();*/
  650. });
  651. }
  652. });
  653. });
  654. } else {
  655. $(window).bind('load', function () {
  656. var scLock = true;
  657. $('#container').bind('scroll', function () {
  658. var t = $('#container').scrollTop();
  659. if (t >= ($('#myworks').height() - $(window).height()) && scLock == true) {
  660. now_page++;
  661. scLock = false;
  662. $.get(now_page_url + '/list/' + now_page_cur + '/', {page: now_page}, function (data) {
  663. var v = $(data).find('#myworks ul').html();
  664. $('#myworks ul').append(v);
  665. var patt1 = new RegExp("alist");
  666. if (patt1.test(v)) {
  667. scLock = true;
  668. } else {
  669. $('.list_loading').html('<span>没有了!</span>');
  670. }
  671. /*$('.alist').openNewFrame();*/
  672. });
  673. }
  674. });
  675. });
  676. }
  677. }
  678. $(window).bind('DOMContentLoaded', function () {
  679. setTimeout(function () {
  680. if (!document.getElementById('newwrap')) {
  681. img_loader();
  682. }
  683. $('html').removeClass('loading');
  684. }, 400);
  685. });
  686. /*$('a').click(function () {
  687. var _this = $(this);
  688. if (_this.parent().hasClass('menu_back')) {
  689. if (window.parent.document.getElementById('newwrap')) {
  690. var d = $(window.parent.document).find('#newwrap').attr('dataurl'), dt = $(window.parent.document).find('#newwrap').attr('datatitle');
  691. $(window.parent.document).find('#newwrap_t').removeClass('show');
  692. $(window.parent.document).find('#header,#container').removeClass('newframe');
  693. setTimeout(function () {
  694. $(window.parent.document).find('#newwrap').attr('src', '');
  695. }, 400);
  696. window.parent.history.replaceState(null, dt, d);
  697. window.parent.document.title = dt;
  698. _this.attr('href', '');
  699. $('.alist').openNewFrame();
  700. } else {
  701. $('html').addClass('loading2');
  702. $('html').addClass('loading');
  703. setTimeout(function () {
  704. window.location.href = _this.attr('href');
  705. }, 200);
  706. }
  707. return false;
  708. } else if (_this.parent().hasClass('menu_back2')) {
  709. $('html').addClass('loading2');
  710. $('html').addClass('loading');
  711. setTimeout(function () {
  712. window.location.href = _this.attr('href');
  713. }, 200);
  714. } else if (_this.parent().hasClass('sort_b') || _this.parent().hasClass('home_profile_c') || _this.parent().hasClass('cancel_share') || _this.parent().hasClass('relationship') || _this.attr('id') == 'reg_now' || _this.attr('class') == 'login_submit' || _this.attr('class') == 'more_comment' || _this.attr('class') == 'delete_check_sure' || _this.attr('class') == 'delete_check_cancel' || _this.attr('href') == '' || _this.attr('href') == '#' || _this.attr('href') == 'javascript:void(0);' || $(this).attr('target') == "_blank") {
  715. } else {
  716. $('html').addClass('loading');
  717. setTimeout(function () {
  718. window.location.href = _this.attr('href');
  719. }, 400);
  720. return false;
  721. }
  722. });*/
  723. $('.login_submit').click(function () {
  724. $.post("http://m.yiwubaike.com/service/loginUser", {timestamp: YYToken.timestamp, token: Y0YToken.token, email: $('.login_user input').val(), password: $('.login_password input').val()}, function () {
  725. window.location.href = "/";
  726. });
  727. });
  728. var img_loader = function () {
  729. var imgReady = (function () {
  730. var list = [], intervalId = null, tick = function () {
  731. var i = 0;
  732. for (; i < list.length; i++) {
  733. list[i].end ? list.splice(i--, 1) : list[i]();
  734. }
  735. ;
  736. !list.length && stop();
  737. }, stop = function () {
  738. clearInterval(intervalId);
  739. intervalId = null;
  740. };
  741. return function (url, ready, load, error) {
  742. var onready, width, height, newWidth, newHeight, img = new Image();
  743. img.src = url;
  744. if (img.complete) {
  745. ready.call(img);
  746. load && load.call(img);
  747. return;
  748. }
  749. ;
  750. width = img.width;
  751. height = img.height;
  752. img.onerror = function () {
  753. error && error.call(img);
  754. onready.end = true;
  755. img = img.onload = img.onerror = null;
  756. };
  757. onready = function () {
  758. newWidth = img.width;
  759. newHeight = img.height;
  760. if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
  761. ready.call(img);
  762. onready.end = true;
  763. }
  764. ;
  765. };
  766. onready();
  767. img.onload = function () {
  768. !onready.end && onready();
  769. load && load.call(img);
  770. img = img.onload = img.onerror = null;
  771. };
  772. if (!onready.end) {
  773. list.push(onready);
  774. if (intervalId === null)intervalId = setInterval(tick, 40);
  775. };
  776. };
  777. })();
  778. $('.works').each(function () {
  779. var e = $(this).find('img'), v = e.attr('vsrc');
  780. imgReady(v, function () {
  781. e.attr('width', this.width);
  782. e.attr('height', (($(window).width() - 10) / this.width) * this.height);
  783. e.attr('src', v);
  784. });
  785. });
  786. }
  787. $('.article_ct img').css('height', 'auto').attr('height', '').attr('width', '');
  788. var _thist_ = document.title, thistd = window.location.href;
  789. $.fn.openNewFrame = function () {
  790. $(this).click(function () {
  791. var _thisv = $(this).attr('vhref'), _thist = $(this).find('.info h4').html();
  792. if (document.getElementById('newwrap')) {
  793. $('#newwrap').attr('src', _thisv).attr('dataurl', thistd).attr('datatitle', _thist_);
  794. $('#newwrap_t').addClass('show');
  795. history.replaceState(null, _thist, _thisv);
  796. document.title = _thist;
  797. $('#header,#container').addClass('newframe');
  798. }
  799. });
  800. };
  801. $('.works_info iframe').css({'margin': '0 auto', 'display': 'inlineBlock', 'maxWidth': '100%', 'height': 'auto', 'position': 'relative'});
  802. $('.works_info iframe').each(function () {
  803. if ($(this).parent().parent().hasClass('pd10')) {
  804. $(this).parent().parent().css({'position': 'relative', 'paddingLeft': '0', 'paddingRight': '0'});
  805. }
  806. });
  807. /*$('.alist').openNewFrame();*/
  808. location.href.indexOf('fid=') < 0 && $('.a_selected').trigger('click');
  809. $('.us_panel_menu').click(function () {
  810. if ($('#us_panel_menu').hasClass('show')) {
  811. $('#us_panel_menu').removeClass('show');
  812. $('.arrow_top').removeClass('open');
  813. $(window).unbind('touchmove');
  814. } else {
  815. $('#us_panel_menu').addClass('show');
  816. $('.arrow_top').addClass('open');
  817. $(window).bind('touchmove', function (e) {
  818. e.preventDefault();
  819. e.stopImmediatePropagation();
  820. });
  821. }
  822. });
  823. $('.us_panel_msk').click(function () {
  824. $('.us_panel_menu').trigger('click');
  825. });
  826. $('.add_newpost_cancel').click(function () {
  827. $('#add_newpost').removeClass('show');
  828. $('.newpost_w_t textarea').blur();
  829. });
  830. $('.us_panel_menu_t td a').click(function () {
  831. var v = $(this).attr('href');
  832. window.parent.location.href = v;
  833. return false;
  834. });
  835. var _cid, _ct, isReply, _nickname;
  836. function replyThis() {
  837. $('.reply_this').click(function () {
  838. if (logined == 1) {
  839. isReply = true;
  840. reply_lock = true;
  841. _cid = $(this).parent().parent().parent().parent().attr('postdata');
  842. _ct = $(this).parent().parent().parent().parent().find('.comment_p .comment_pct').html();
  843. _nickname = $(this).parent().parent().parent().parent().find('h5 .fl a').html();
  844. $('#add_newpost').addClass('show');
  845. $('.newpost_w_t textarea').val('').attr('placeholder', '回复' + _nickname + '');
  846. } else {
  847. $('#reg_index').addClass('show');
  848. }
  849. });
  850. $('.us_panel_post').click(function () {
  851. if (logined == 1) {
  852. $('#add_newpost').addClass('show');
  853. if ($('.newpost_w_t textarea').val() == '') {
  854. $('.newpost_w_t textarea').val('').attr('placeholder', '发表评论');
  855. }
  856. ;
  857. reply_lock = true;
  858. isReply = false;
  859. reply_lock = true;
  860. } else {
  861. $('#reg_index').addClass('show');
  862. }
  863. });
  864. $('.add_newpost_post').click(function () {
  865. if (reply_lock == true && isReply == true && $('.newpost_w_t textarea').val() != '') {
  866. reply_lock = false;
  867. $.post("http://m.yiwubaike.com/service/postnewComment", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2, postcid: _cid, postuid: comment_id, content: $('.newpost_w_t textarea').val()}, function (data) {
  868. var ddd = '<div class="quote"><div class="pd10">' + _ct + '</div></div>';
  869. $('#comment ul').prepend('<li postdata="' + data.id + '" usdata="' + comment_id + '"><div class="pd5"><a class="avt fl" target="_blank" href="' + comment_at_url + '"><img src="' + comment_avatar + '"></a><div class="comment_content"><h5><div class="fl"><a class="comment_name" href="' + comment_at_url + '">' + comment_author + '</a><span>' + data.postdate + '</span></div><div class="fr reply_this">[回复]</div><div class="clear"></div></h5><div class="comment_p"><div class="comment_pct">' + data.content + '</div>' + ddd + '</div></div><div class="clear"></div><div class="comment_reply"></div></div></li>');
  870. document.getElementById('container').scrollTop = cmofsT;
  871. $('#add_newpost').removeClass('show');
  872. $('.us_panel_post').find('span em').html(parseInt($('.us_panel_post').find('span em').html()) + 1);
  873. replyThis();
  874. }, 'json');
  875. }
  876. if (reply_lock == true && isReply == false && $('.newpost_w_t textarea').val() != '') {
  877. reply_lock = false;
  878. $.post("http://m.yiwubaike.com/service/postnewComment", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2, content: $('.newpost_w_t textarea').val()}, function (data) {
  879. $('#comment ul').prepend('<li postdata="' + data.id + '" usdata="' + comment_id + '"><div class="pd5"><a class="avt fl" target="_blank" href="' + comment_at_url + '"><img src="' + comment_avatar + '"></a><div class="comment_content"><h5><div class="fl"><a class="comment_name" href="' + comment_at_url + '">' + comment_author + '</a><span>' + data.postdate + '</span></div><div class="fr reply_this">[回复]</div><div class="clear"></div></h5><div class="comment_p"><div class="comment_pct">' + data.content + '</div></div></div><div class="clear"></div><div class="comment_reply"></div></div></li>');
  880. document.getElementById('container').scrollTop = cmofsT;
  881. $('#add_newpost').removeClass('show');
  882. $('.us_panel_post').find('span em').html(parseInt($('.us_panel_post').find('span em').html()) + 1);
  883. replyThis();
  884. }, 'json');
  885. }
  886. });
  887. };
  888. replyThis();
  889. $('.t_slide').click(function () {
  890. if ($('#choose_album').hasClass('show')) {
  891. $('#choose_album,.menu_slide').removeClass('show');
  892. } else {
  893. $('#choose_album,.menu_slide').addClass('show');
  894. }
  895. });
  896. $('.menu_slide').click(function () {
  897. $('.t_slide').trigger('click');
  898. });
  899. $('.edit_this').click(function () {
  900. });
  901. $('.edit_album_msk').click(function () {
  902. $('#edit_album').removeClass('show');
  903. });
  904. var editAlbum = (function () {
  905. var _this;
  906. $('.edit_this').click(function () {
  907. _this = $(this), pid = _this.parent().parent().parent().attr('data-id'), title = _this.parent().parent().parent().find('dt .pd5').html();
  908. $('#edit_album').addClass('show');
  909. $('.edit_album_input').val(title);
  910. $('.edit_album_sure').click(function () {
  911. $.post("http://m.yiwubaike.com/service/editUserCat", {timestamp: YYToken.timestamp, token: YYToken.token, id: pid, title: $('.edit_album_input').val()}, function (data) {
  912. _this.parent().parent().parent().find('dt .pd5').html($('.edit_album_input').val());
  913. $('#edit_album').removeClass('show');
  914. }, 'json');
  915. });
  916. $('.edit_album_delete').click(function () {
  917. $.post("http://m.yiwubaike.com/service/removeUserCat", {timestamp: YYToken.timestamp, token: YYToken.token, id: pid}, function (data) {
  918. _this.parent().parent().parent().remove();
  919. $('#edit_album').removeClass('show');
  920. }, 'json');
  921. });
  922. });
  923. }());
  924. $('.us_panel_like').click(function () {
  925. if (logined == 1) {
  926. var _this = $(this);
  927. if ($(this).hasClass('liked')) {
  928. $.post("http://m.yiwubaike.com/service/removeLike", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2}, function () {
  929. _this.removeClass('liked');
  930. _this.find('span em').html(parseInt(_this.find('span em').html()) - 1);
  931. });
  932. } else {
  933. $('#add_favorite').addClass('show');
  934. }
  935. } else {
  936. $('#reg_index').addClass('show');
  937. }
  938. });
  939. $('#add_favorite .hd .fr').click(function () {
  940. $('#add_favorite').removeClass('show');
  941. });
  942. $('.created_cate_add').click(function () {
  943. if ($('.created_cate_ipt input').val() != '') {
  944. var v = $('.created_cate_ipt input').val();
  945. $.post("http://m.yiwubaike.com/service/addUserCat", {timestamp: YYToken.timestamp, token: YYToken.token, fid: $('.created_cate_ipt input').val()}, function (data) {
  946. if (typeof(data) != 'object') {
  947. $('#add_favorites_choose').append('<li data-id="' + data + '"><i></i><span>' + v + '</span><i class="e"></i></li>');
  948. $('.ct li').click(function () {
  949. var _this = $(this), d = $(this).attr('data-id');
  950. if ($(this).hasClass('a_selected') == false) {
  951. $.post("http://m.yiwubaike.com/service/addLike", {timestamp: YYToken.timestamp, token: YYToken.token, postid: commentId2, cid: d}, function () {
  952. _this.siblings().removeClass('a_selected');
  953. _this.addClass('a_selected');
  954. $('#add_favorite .hd .fr').trigger('click');
  955. $('.us_panel_like').addClass('liked');
  956. $('.us_panel_like span em').html(parseInt($('.us_panel_like span em').html()) + 1);
  957. });
  958. }
  959. });
  960. }
  961. }, 'json');
  962. }
  963. });
  964. })(Zepto)