Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - gifts.js (Старый размер - 12667 | Новый - 0):
- 0. - var Gifts = {
- 1. - initGifts: function(opts, preload) {
- 2. - extend(cur, {
- 3. - pgStart: opts.start,
- 4. - pgOffset: opts.offset,
- 5. - pgCount: opts.count,
- 6. - pgPerPage: opts.perpage,
- 7. - pgCont: ge('gifts_rows'),
- 8. - pgMore: ge('gifts_load_more'),
- 9. - pgPages: ge('gifts_pages'),
- 10. - pgMorePrg: ge('gifts_more_progress'),
- 11. - pgPreload: preload,
- 12. - pgHref: '/gifts' + opts.mid + '?' + (opts.sent ? 'act=sent&' : '') + 'offset=',
- 13. - pgParams: opts.sent ? {act: 'sent'} : {},
- 14. - pgUrl: '/gifts' + opts.mid,
- 15. -
- 16. - mid: opts.mid,
- 17. - hash: opts.hash
- 18. - });
- 19. - Pagination.init();
- 20. - cur.destroy.push(Pagination.deinit);
- 21. - },
- 22. - deleteGift: function(el, gift, giftData, opts) {
- 23. - opts = opts || {};
- 24. - ajax.post('al_gifts.php', {act: 'delete', mid: opts.mid, gift: giftData, hash: opts.hash}, {onDone: function(text) {
- 25. - var p = ge('gift' + gift);
- 26. - if (!p) return;
- 27. - if (p.firstChild.nextSibling) {
- 28. - p.firstChild.nextSibling.innerHTML = text;
- 29. - } else {
- 30. - p.appendChild(ce('div', {className: 'gift_deleted', innerHTML: text}));
- 31. - hide(p.firstChild);
- 32. - if (window.Pagination && !curBox()) Pagination.recache(-1);
- 33. - }
- 34. - }, showProgress: function() {
- 35. - hide(el);
- 36. - show(el.parentNode.nextSibling);
- 37. - }, hideProgress: function() {
- 38. - hide(el.parentNode.nextSibling);
- 39. - show(el);
- 40. - }});
- 41. - },
- 42. - restoreGift: function(el, gift, giftData, opts) {
- 43. - opts = opts || {};
- 44. - ajax.post('al_gifts.php', {act: 'restore', mid: opts.mid, gift: giftData, hash: opts.hash}, {onDone: function() {
- 45. - var p = ge('gift' + gift);
- 46. - if (!p || !p.firstChild.nextSibling) return;
- 47. - re(p.firstChild.nextSibling);
- 48. - show(p.firstChild);
- 49. - }});
- 50. - },
- 51. - markSpamGift: function(el, gift, giftData, opts) {
- 52. - opts = opts || {};
- 53. - ajax.post('al_gifts.php', {act: 'mark_spam', mid: opts.mid, gift: giftData, hash: opts.hash}, {onDone: function(text) {
- 54. - ge('gift_mark_spam'+gift).innerHTML = text;
- 55. - }});
- 56. - },
- 57. - onReceiverChange: function() {
- 58. - var dd = cur.wdd && cur.wdd['gft_box_dd'];
- 59. - if (cur.giftsLeft) {
- 60. - var selected = 0, all = dd.selected;
- 61. - for (var i in all) {
- 62. - var d = (all[i][0] > 0) ? 1 : all[i][6];
- 63. - if (selected + d > cur.giftsLeft) {
- 64. - setTimeout(WideDropdown.deselect.pbind('gft_box_dd', all[i][0], false), 0);
- 65. - return false;
- 66. - } else {
- 67. - selected += d;
- 68. - }
- 69. - }
- 70. - }
- 71. -
- 72. - cur.sel = [];
- 73. - for (var i in dd.selected) {
- 74. - cur.sel.push(dd.selected[i]);
- 75. - }
- 76. - if (!cur.sel.length) {
- 77. - delete(cur.sel);
- 78. - }
- 79. - val('gft_box_to', getLang((cur.sel && cur.sel.length > 1) ? 'gifts_receivers' : 'gifts_receiver').replace(':', ''));
- 80. - },
- 81. - selectGift: function(num, votes, bonus, tip, left) {
- 82. - cur.gift = num;
- 83. - cur.giftsLeft = left;
- 84. - cur.giftsSendConfirmed = 0;
- 85. - var box = showFastBox({
- 86. - title: false,
- 87. - width: 444,
- 88. - bodyStyle: 'border: 0px; padding: 0px;',
- 89. - onShow: function() {
- 90. - addClass(boxLayerBG, 'bg_dark');
- 91. - cur._noEscHide = true;
- 92. - },
- 93. - onClean: function() {
- 94. - if (window.WideDropdown) WideDropdown.deinit('gft_box_dd');
- 95. - cur._noEscHide = false;
- 96. - }
- 97. - }, '\
- 98. - <a class="fl_r tb_close" onclick="curBox().hide()">' + getLang('global_close') + '</a>\
- 99. - <div class="tb_title">' + getLang('gifts_send_gift') + '</div>\
- 100. - <div id="gifts_do_send_wrap">\
- 101. - ' + (left > 0 ? '<div class="info_msg" style="margin-bottom: 10px;">' + getLang('gifts_free_send_left', left) + '</div>' : '') + '\
- 102. - <div class="gs_box_wrap">\
- 103. - <img class="gs_box_img" src="images/gifts/256/' + num + '.jpg" />\
- 104. - </div>\
- 105. - <div class="gft_send">\
- 106. - <div class="gft_box_label" id="gft_box_to">' + getLang('gifts_receiver').replace(':', '') + '</div>\
- 107. - <div class="wdd clear_fix" id="gft_box_dd">\
- 108. - <div class="fl_r wdd_arr"></div>\
- 109. - <input type="text" class="wdd_text fl_l" placeholder="' + clean(getLang('gifts_choose_recipients')) + '" id="gft_box_inp" onfocus="this.focused=1" onblur="this.focused=\'\'" />\
- 110. - <br class="clear" />\
- 111. - </div>\
- 112. - <div class="fl_r" id="gs_warn"></div>\
- 113. - <div class="gft_box_label">' + getLang('gifts_your_message').replace(':', '') + '</div>\
- 114. - <div class="gft_box_text_wrap">\
- 115. - <textarea id="gs_msg" onchange="cur.giftCurrentMessage = this.value;" onkeydown="onCtrlEnter(event, Gifts.sendGift)" onkeyup="checkTextLength(cur.maxLen, this, \'gs_warn\', false, true)"></textarea>\
- 116. - </div>\
- 117. - <div class="gs_privacy">\
- 118. - <div class="checkbox' + (cur.giftCurrentPrivacy ? ' on' : '') + '" id="gift_receiver_only" onclick="checkbox(this); cur.giftCurrentPrivacy = isChecked(this);">\
- 119. - <div></div>' + getLang('gifts_receiver_only') + '\
- 120. - </div>\
- 121. - </div>\
- 122. - </div>\
- 123. - ' + (bonus > 0 ? '<div class="gs_bonus">' + getLang('gifts_rate_increase').replace('{gifts_count}', getLang(bonus, 'gifts_X_votes')) + '</div>' : '') + '\
- 124. - ' + (tip ? '<div class="gs_tip">' + tip + '</div>' : '') + '\
- 125. - </div>\
- 126. - ', getLang('box_send'), Gifts.sendGift, getLang('global_cancel'));
- 127. - setStyle(domNS(box.bodyNode), {border: '0px'});
- 128. -
- 129. - if (WideDropdown.init('gft_box_dd', {
- 130. - defaultItems: cur.users,
- 131. - items: cur.users,
- 132. - noResult: getLang('gifts_nobody_found'),
- 133. - introText: getLang('gifts_start_typing_recipient'),
- 134. - maxItems: cur.giftsLimit ? cur.giftsLimit : 100,
- 135. - onChange: function(act) {
- 136. - if (act == 1 && !inArray(cur.section, ['valentines', 'love', 'friends', 'birthday'])) { // added
- 137. - setTimeout(WideDropdown.focus.pbind('gft_box_dd'), 0);
- 138. - }
- 139. - setTimeout(Gifts.onReceiverChange, 0);
- 140. - },
- 141. - itemMark: function(item) {
- 142. - return intval(item[5]) ? 1 : 0;
- 143. - }
- 144. - })) {
- 145. - if (cur.sel) {
- 146. - for (var i in cur.sel) {
- 147. - WideDropdown.select('gft_box_dd', false, cur.sel[i]);
- 148. - }
- 149. - }
- 150. - }
- 151. -
- 152. - box.setControlsText(' ');
- 153. - Gifts.onReceiverChange();
- 154. - box.changed = true;
- 155. - autosizeSetup('gs_msg', {minHeight: 50, maxHeight: 150});
- 156. - if (!cur.sel || isArray(cur.sel) && !cur.sel.length) {
- 157. - WideDropdown.focus('gft_box_dd');
- 158. - } else {
- 159. - elfocus('gs_msg');
- 160. - }
- 161. - },
- 162. - sendGift: function() {
- 163. - if (cur.giftsSendConfirmed) {
- 164. - var query = cur.giftsSendConfirmedQuery;
- 165. - cur.giftsSendConfirmed = false;
- 166. -
- 167. - var sendBtn = geByClass1('button_blue', cur.confirmBox.bodyNode.nextSibling).firstChild;
- 168. - } else {
- 169. - var mids = [], dd = cur.wdd && cur.wdd['gft_box_dd'], sel = dd.selected;
- 170. - for (var i in sel) {
- 171. - if (typeof(sel[i][4]) == 'string' && sel[i][4] != '' && sel[i][4] != 'none') {
- 172. - mids.push(sel[i][4]);
- 173. - } else {
- 174. - mids.push(sel[i][0]);
- 175. - }
- 176. - }
- 177. - mids = mids.join(',');
- 178. - if (!mids) {
- 179. - return WideDropdown.focus('gft_box_dd');
- 180. - }
- 181. - var query = {
- 182. - act: 'do_send',
- 183. - text: ge('gs_msg').value,//(isVisible('gs_msg_wrap') ? ge('gs_msg').value : ''),
- 184. - mids: mids,
- 185. - number: cur.gift,
- 186. - type: isChecked('gift_receiver_only') ? 1 : 0,
- 187. - hash: cur.hash,
- 188. - from: cur.giftSendFrom || '',
- 189. - };
- 190. - var sendBtn = geByClass1('button_blue', curBox().bodyNode.nextSibling).firstChild;
- 191. - }
- 192. - ajax.post('al_gifts.php', query, {
- 193. - onDone: function(data, text) {
- 194. - if (data === 'confirm') {
- 195. - while (boxQueue.count()) boxQueue.hideLast(false, window.event);
- 196. - cur.giftsSendConfirmed = 1;
- 197. - query.confirm = 1;
- 198. - cur.giftsSendConfirmedQuery = query;
- 199. - cur.confirmBox = showFastBox({title: cur.giftsTitle}, text, '{$lang['box_send']}', cur.sendBoxGift, '{$lang['global_cancel']}');
- 200. - return;
- 201. - }
- 202. - cur.giftCurrentMessage = '';
- 203. - updateMoney(data);
- 204. - curBox().hide();
- 205. - showDoneBox(text, {out: 1500})
- 206. - if (cur.giftsLeft) nav.reload();
- 207. - },
- 208. - showProgress: lockButton.pbind(sendBtn),
- 209. - hideProgress: unlockButton.pbind(sendBtn)
- 210. - });
- 211. - },
- 212. - initGiftsBox: function(box, opts) {
- 213. - box.setOptions({width: 620, bodyStyle: 'margin-top: 50px; padding: 0px', onShow: function() {
- 214. - if (cur.gftbxWasScroll) {
- 215. - boxLayerWrap.scrollTop = cur.gftbxWasScroll;
- 216. - cur.gftbxWasScroll = false;
- 217. - }
- 218. - addClass(boxLayerBG, 'bg_dark');
- 219. - }});
- 220. - if (opts.lang) {
- 221. - cur.lang = extend(cur.lang || {}, opts.lang);
- 222. - }
- 223. -
- 224. - if (cur.lSTL) re(cur.lSTL);
- 225. - if (cur.gftbxAddLnk) re(cur.gftbxAddLnk);
- 226. - extend(cur, {
- 227. - gftbxOffsets: cur.gftbxOffsets || {},
- 228. - gftbxPhCache: cur.gftbxPhCache || {},
- 229. - gftbxPhShown: cur.gftbxPhShown || {},
- 230. -
- 231. - gftbxAutoload: true,
- 232. - gftbxWasScroll: false,
- 233. - // gftbxHash: opts.hash,
- 234. - gftbxMid: opts.mid,
- 235. - gftbxId: box.tbId,
- 236. - gftbxAddLnk: ge('tb_'+box.tbId+'_prg').parentNode.insertBefore(se('<div class="gifts_add_lnk fl_r"><a href="/gifts?act=send" onclick="return (window.Profile ? Profile.showGiftBox(cur.oid, event) : nav.go(this, event));">' + getLang('gifts_send_gift') + '</a></div>'), ge('tb_'+box.tbId+'_prg')),
- 237. -
- 238. - lSTL: boxLayerWrap.appendChild(ce('div', {id: 'layer_stl', innerHTML: '<div id="layer_stl_bg" class="fixed"></div><div id="layer_stl_cl"></div><nobr id="layer_stl_text" class="fixed">' + getLang('global_to_top') + '</nobr>', el: box.bodyNode, onclick: cancelEvent, onmousedown: Gifts.lSTLDown, sc: Gifts.onGiftsScroll})),
- 239. - lSTLShown: 0,
- 240. - lSTLWas: 0,
- 241. - lSTLWasSet: 0
- 242. - });
- 243. - cur.gftbxOffsets[opts.tab] = opts.offset;
- 244. -
- 245. - ajax.preload('al_gifts.php', {
- 246. - act: 'box',
- 247. - tab: opts.tab,
- 248. - mid: opts.mid,
- 249. - offset: opts.offset
- 250. - }, opts.preload);
- 251. -
- 252. - if (!box.tbDeinit) {
- 253. - box.tbDeinit = function() {
- 254. - cur.gftbxMid = cur.gftbxOffsets = cur.gftbxPhShown = false;
- 255. - re(cur.lSTL);
- 256. - removeEvent(boxLayerWrap, 'scroll', Gifts.onGiftsScroll);
- 257. - }
- 258. - addEvent(boxLayerWrap, 'scroll', Gifts.onGiftsScroll);
- 259. - }
- 260. -
- 261. - if (cur.gftbxLoaded) cur.gftbxLoaded();
- 262. - onBodyResize();
- 263. - Gifts.onGiftsScroll();
- 264. - },
- 265. - moreGifts: function() {
- 266. - var t = curBox().tbCur;
- 267. - if (isVisible('gifts_more_prg' + t)) return;
- 268. - ajax.post('al_gifts.php', {act: 'box', tab: t, mid: cur.gftbxMid, offset: cur.gftbxOffsets[t]}, {
- 269. - onDone: function(rows, newOffset, needMore) {
- 270. - var el = ce('div', {innerHTML: rows}), cnt = ge('gifts_rows' + t);
- 271. - if (!cnt) return;
- 272. -
- 273. - for (var e = domFC(el); e; e = domFC(el)) {
- 274. - cnt.appendChild(e);
- 275. - }
- 276. - cur.gftbxOffsets[t] = newOffset;
- 277. - if (needMore) {
- 278. - Gifts.preloadGifts();
- 279. - } else {
- 280. - hide('gifts_more_link' + t);
- 281. - }
- 282. - }, showProgress: function() {
- 283. - hide('gifts_more_link' + t);
- 284. - show('gifts_more_prg' + t);
- 285. - }, hideProgress: function() {
- 286. - show('gifts_more_link' + t);
- 287. - hide('gifts_more_prg' + t);
- 288. - }, cache: 1
- 289. - });
- 290. - cur.gftbxAutoload = true;
- 291. - },
- 292. - preloadGifts: function() {
- 293. - var t = curBox().tbCur;
- 294. - ajax.post('al_gifts.php', {act: 'box', tab: t, mid: cur.gftbxMid, offset: cur.gftbxOffsets[t]}, {
- 295. - cache: 1
- 296. - });
- 297. - },
- 298. - lSTLDown: function(e) {
- 299. - e = e || window.event;
- 300. - if (checkEvent(e)) return;
- 301. -
- 302. - if (!__afterFocus) {
- 303. - var to = 0, st = boxLayerWrap.scrollTop;
- 304. - if (cur.lSTLWasSet && cur.lSTLWas) {
- 305. - to = cur.lSTLWas;
- 306. - cur.lSTLWas = 0;
- 307. - } else {
- 308. - cur.lSTLWas = st;
- 309. - }
- 310. - boxLayerWrap.scrollTop = to;
- 311. - }
- 312. - return cancelEvent(e);
- 313. - },
- 314. - onGiftsScroll: function() {
- 315. - var st = boxLayerWrap.scrollTop, mx = 200, vis = cur.lSTLWas || (st > mx), o = 0;
- 316. - cur.lSTL.style.marginTop = st + 'px';
- 317. - if (!vis) {
- 318. - if (cur.lSTLShown !== 0) {
- 319. - hide(cur.lSTL);
- 320. - cur.lSTLShown = 0;
- 321. - }
- 322. - } else {
- 323. - if (cur.lSTLShown !== 1) {
- 324. - show(cur.lSTL);
- 325. - cur.lSTLShown = 1;
- 326. - }
- 327. - if (cur.lSTLWas && st > 500) {
- 328. - cur.lSTLWas = 0;
- 329. - }
- 330. - if (st > mx) {
- 331. - o = (st - mx) / mx;
- 332. - if (cur.lSTLWasSet) {
- 333. - cur.lSTLWasSet = 0;
- 334. - val(domLC(cur.lSTL), getLang('global_to_top'));
- 335. - removeClass(domLC(cur.lSTL), 'down');
- 336. - }
- 337. - } else {
- 338. - o = (mx - st) / mx;
- 339. - if (cur.lSTLWas) {
- 340. - if (!cur.lSTLWasSet) {
- 341. - cur.lSTLWasSet = 1;
- 342. - val(domLC(cur.lSTL), '');
- 343. - addClass(domLC(cur.lSTL), 'down');
- 344. - }
- 345. - }
- 346. - }
- 347. - }
- 348. - setStyle(cur.lSTL, {opacity: Math.min(Math.max(o, 0), 1)});
- 349. - if (!cur.gftbxAutoload) return;
- 350. - var bt = lastWindowHeight, objMore = ge('gifts_more_link' + curBox().tbCur);
- 351. - if (isVisible(objMore) && (bt > getXY(objMore, true)[1])) {
- 352. - objMore.click();
- 353. - }
- 354. - }
- 355. - }
- 356. -
- 357. - try{stManager.done('gifts.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment