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