Hormold

VK Change (#1355334224)

Dec 12th, 2012
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 99.36 KB | None | 0 0
  1. Файл - page.js:
  2. 991.  +     if (cur.module == 'feed' && !isVisible(ge('feed_news_bar'))) {
  3. 992.  +       cur.onFeedBarShow = Wall.setDraft.pbind(data);
  4. 993.  +       return;
  5. 994.  +     }
  6. 1479.  -       if (top < 0 || top > lastWindowHeight - 200) {
  7. 1480.  +       if (top < 0 || top > lastWindowHeight) {
  8. 1503.  -         WkView.wallShowPreviousReplies(reply);
  9. 1504.  +         WkView.wallShowPreviousPosts(reply);
  10. 2001.  -       shift: [(reply && !(reply % 2)) ? 329 : 64, 0, 0],
  11. 2002.  +       shift: [(reply && !(reply % 2)) ? 300 : 35, -3, 0],
  12. 2961.  -     }
  13. 2962.  -     var nameStr = ev[3].replace('mem_link', 'author').replace('memLink', 'author');
  14. 2963.  -     if (ev[6].indexOf('id="wpfo') != -1) {
  15. 2964.  -       nameStr += '<span class="page_fronly inl_bl" onmouseover="Wall.foTT(this, false, {oid: \'' + oid + '\', pid: \'' + ev[2] + '\'})"></span>';
  16. 2968.  -       name: nameStr,
  17. 2969.  +       name: ev[3].replace('mem_link', 'author').replace('memLink', 'author'),
  18. 2982.  -       date_postfix: '',
  19. 2983.  +       date_postfix: (ev[6].indexOf('id="wpfo') != -1) ? '<span class="page_fronly inl_bl" onmouseover="Wall.foTT(this, false, {oid: \'' + oid + '\', pid: \'' + ev[2] + '\'})"></span>' : '',
  20. 3449.  -           } else {
  21. 3450.  -             updH = el.offsetHeight - startH;
  22. 3451.  -             updY = getXY(highlight ? newEl : openEl)[1];
  23. 3452.  -             Wall.repliesSideSetup(post_id);
  24. 3453.  -           }
  25. 3454.  -           break;
  26. 3455.  -
  27. 3456.  -         case 'del_reply':
  28. 3457.  -           if (cur.wallMyDeleted[post_id] || !el) break;
  29. 3458.  -           updH = -el.offsetHeight;
  30. 3459.  -           updY = getXY(el, fixed)[1];
  31. 3460.  -           // debugLog(ev, post_id, el);
  32. 3461.  -           if (cur.layerpost) {
  33. 3462.  -             hide(el);
  34. 3463.  -             cur.count--;
  35. 3464.  -             cur.loaded--;
  36. 3465.  -           } else if (cur.onepost) {
  37. 3466.  -             hide(el);
  38. 3467.  -             cur.pgOffset--;
  39. 3468.  -             cur.pgCount--;
  40. 3469.  -           } else {
  41. 3470.  -             var post = el.parentNode.id.match(/replies(-?\d+_\d+)/);
  42. 3471.  -             re(el);
  43. 3472.  -             if (post) {
  44. 3473.  -               Wall.repliesSideSetup(post[1]);
  45. 3474.  -             }
  46. 3475.  -           }
  47. 3476.  -           break;
  48. 3477.  -
  49. 3478.  -         case 'like_post':
  50. 3479.  -         case 'like_reply':
  51. 3480.  -           if (!el) break;
  52. 3481.  -           var likePost = ev_type == 'like_reply' ? post_id.replace('_', '_wall_reply') : post_id,
  53. 3482.  -               likeLayerPost = layer && post_id == window.cur.wallLayer,
  54. 3483.  -               cntEl = likeLayerPost ? ge('wk_like_count') : ge('like_count' + likePost),
  55. 3484.  -               iconEl = likeLayerPost ? ge('wk_like_icon') : ge('like_icon' + likePost),
  56. 3485.  -               ttEl = iconEl && iconEl.parentNode,
  57. 3486.  -               cnum = intval(val(cntEl)),
  58. 3487.  -               num = intval(ev[3]);
  59. 3488.  -
  60. 3489.  -           animateCount(cntEl, num);
  61. 3490.  -           val('like_real_count_wall' + post_id, num);
  62. 3491.  -           toggleClass(iconEl, 'no_likes', num <= 0);
  63. 3492.  -           if (ttEl && ttEl.tt && !isVisible(ttEl.tt.container)) {
  64. 3493.  -             ttEl && ttEl.tt && ttEl.tt.destroy();
  65. 3494.  -           }
  66. 3495.  -           setStyle(iconEl, {opacity: '', visibility: ''});
  67. 3496.  -           break;
  68. 3497.  -
  69. 3498.  -         case 'vote_poll':
  70. 3499.  -           if (!el) break;
  71. 3500.  -           Wall.updatePollResults(post_id, ev[3]);
  72. 3501.  -           break;
  73. 3502.  -
  74. 3503.  -
  75. 3504.  -         case 'upd_ci':
  76. 3505.  -           var edit = ge('current_info'), info = ev[2], el = edit || ge('page_current_info');
  77. 3506.  -           switch (ev[3]) {
  78. 3507.  -             case 'audio':
  79. 3508.  -               var attr = edit ? '' : (' onmouseover="showTooltip(this, {forcetoup: true, text: \'' + cur.options.ciAudioTip + '\', black: 1, shift: [13, 0, 0]})" onclick="Profile.playCurrent(this, this.getAttribute(\'data-audio\'), \'' + cur.options.ciAudioHash + '\')" data-audio="' + ev[4] + '"');
  80. 3509.  -               info = '<a class="current_audio"' + attr + '>' + info + '</a>';
  81. 3510.  -             break;
  82. 3511.  -
  83. 3512.  -             case 'app':
  84. 3513.  -               var shift = ev[6] ? '[11, 0, 0]' : '[13, 0, 0]', addCls = ev[6] ? ' current_app_icon' : '';
  85. 3514.  -               var attr = edit ? (' onclick="cur.ciApp = ' + ev[4] + '"') : (' onmouseover="showTooltip(this, {forcetoup: true, text: \'' + cur.options.ciAppTip + '\', black: 1, shift: ' + shift + '})" href="' + ev[5] + '?ref=14" onclick="return showApp(event, ' + ev[4] + ', 1, 14, cur.oid)"');
  86. 3515.  -               if (ev[6]) attr += ' style="background-image: url(\'' + ev[6] + '\')"';
  87. 3516.  -               info = '<a class="current_app' + addCls + '"' + attr + '>' + info + '</a>';
  88. 3517.  -             break;
  89. 3518.  -
  90. 3519.  -             default:
  91. 3520.  -               info = info ? ('<span class="current_text">' + info + '</span>') : info;
  92. 3521.  -             break;
  93. 3522.  -           }
  94. 3523.  -           if (edit) {
  95. 3524.  -             var cls = info ? 'my_current_info' : 'no_current_info';
  96. 3525.  -             info = '<span class="' + cls + '">' + (info || getLang('change_current_info')) + '</span>';
  97. 3526.  -             val(el.parentNode.nextSibling, info);
  98. 3527.  -             if (!isVisible('currinfo_editor') && cur.oid > 0) {
  99. 3528.  -               toggle('currinfo_audio', ev[3] != 'app');
  100. 3529.  -               toggle('currinfo_app', ev[3] == 'app');
  101. 3530.  -               addClass('currinfo_app', 'on');
  102. 3531.  -             }
  103. 3532.  -           }
  104. 3533.  -           val(el, info);
  105. 3534.  -           setStyle(el.firstChild, {backgroundColor: '#FEFAE4'});
  106. 3535.  -           animate(el.firstChild, {backgroundColor: '#FFF'}, 6000, function () {
  107. 3536.  -             setStyle(el.firstChild, {backgroundColor: ''});
  108. 3537.  -           });
  109. 3538.  -         break;
  110. 3539.  -       }
  111. 3540.  -       if (updH && (layer ? (updY < 0) : (curST > updY))) {
  112. 3541.  -         curST += updH;
  113. 3542.  -       }
  114. 3543.  -     });
  115. 3544.  -     var endST = scrollGetY();
  116. 3545.  -     if (curST != startST && startST > 100/* && Math.abs(startST - endST) > 100*/) {
  117. 3546.  -       if (layer) {
  118. 3547.  -         wkLayerWrap.scrollTop = curST;
  119. 3548.  -       } else {
  120. 3549.  -         scrollToY(curST, 0);
  121. 3550.  -       }
  122. 3551.  -     }
  123. 3552.  -     Wall.update();
  124. 3553.  -   },
  125. 3554.  -
  126. 3555.  -   initUpdates: function (key) {
  127. 3556.  -     if (!key || !window.Notifier) {
  128. 3557.  -       return;
  129. 3558.  -     }
  130. 3559.  -     var wasKey = cur.wallAddQueue,
  131. 3560.  -         checkCb = function () {if (cur.wallAddQueue) Notifier.addKey(cur.wallAddQueue, Wall.updated.pbind(false));};
  132. 3561.  -
  133. 3562.  -     cur.wallAddQueue = key;
  134. 3563.  -     checkCb();
  135. 3564.  -     if (!wasKey) {
  136. 3565.  -       checkInt = setInterval(checkCb, 10000);
  137. 3566.  -       cur.destroy.push(function () {clearInterval(checkInt)});
  138. 3567.  -     }
  139. 3568.  -   },
  140. 3569.  -
  141. 3570.  -   initWallOptions: function (opts) {
  142. 3571.  -     extend(cur, {
  143. 3572.  -       wallType: opts.wall_type,
  144. 3573.  -       wallTpl: opts.wall_tpl,
  145. 3574.  -       wallMyDeleted: {},
  146. 3575.  -       tsDiff: opts.wall_tpl && opts.wall_tpl.abs_timestamp ? Math.round((vkNow() / 1000 - opts.wall_tpl.abs_timestamp) / 900.0) * 900 : 0,
  147. 3576.  -       wallMyOpened: {},
  148. 3577.  -       wallMyReplied: {},
  149. 3578.  -       wallMyRepliesCnt: 0
  150. 3579.  -     });
  151. 3580.  -     if (opts.wall_tpl && opts.wall_tpl.lang) {
  152. 3581.  -       cur.lang = extend(cur.lang || {}, opts.wall_tpl.lang);
  153. 3582.  -     }
  154. 3583.  -
  155. 3584.  -     window.Notifier && Notifier.addRecvClbk('wall_reply_multiline', 'wall', function(data) {
  156. 3585.  -       Wall.onReplySubmitChanged(data.value, 1);
  157. 3586.  -     }, true);
  158. 3587.  -   },
  159. 3588.  -
  160. 3589.  -   init: function(opts) {
  161. 3590.  -     Wall.initWallOptions(opts);
  162. 3591.  -
  163. 3592.  -     extend(cur, {
  164. 3593.  -       wallInited: true,
  165. 3594.  -       postField: ge('post_field'),
  166. 3595.  -       wallPage: ge('profile') || ge('group') || ge('public'),
  167. 3596.  -       wallPageNarrow: ge('profile_narrow') || ge('group_narrow'),
  168. 3597.  -       wallPageWide: false,
  169. 3598.  -       wallUploadOpts: opts.upload || false,
  170. 3599.  -       deletedCnts: {own: 0, all: 0}
  171. 3600.  -     });
  172. 3601.  -
  173. 3602.  -     cur.destroy.push(function(c) {
  174. 3603.  -       cleanElems(c.postField);
  175. 3604.  -     });
  176. 3605.  -     var rem = removeEvent.pbind(document, 'click', Wall.hideEditPostReply);
  177. 3606.  -
  178. 3607.  -     if (cur._back) {
  179. 3608.  -       cur._back.hide.push(rem);
  180. 3609.  -       cur._back.show.push(rem);
  181. 3610.  -       cur._back.show.push(addEvent.pbind(document, 'click', Wall.hideEditPostReply));
  182. 3611.  -     } else {
  183. 3612.  -       cur.destroy.push(rem);
  184. 3613.  -     }
  185. 3614.  -     var ownCnt = ge('page_wall_count_own');
  186. 3615.  -     if (cur.wallType == 'own' && !intval(ownCnt && ownCnt.value)) {
  187. 3616.  -       cur.wallType = ge('page_wall_posts').className = 'all';
  188. 3617.  -     }
  189. 3618.  -     Wall.update();
  190. 3619.  -     Wall.initUpdates(opts.add_queue_key);
  191. 3620.  -
  192. 3621.  -     // Times update interval. For relative time correction
  193. 3622.  -     if (opts.wall_tpl) {
  194. 3623.  -       cur.timeUpdateInt = setInterval(function () {Wall.updateTimes(opts.wallCont);}, 10000);
  195. 3624.  -       cur.destroy.push(function () {clearInterval(cur.timeUpdateInt);});
  196. 3625.  -     }
  197. 3626.  -
  198. 3627.  -     if (opts.draft) {
  199. 3628.  -       Wall.setDraft(opts.draft);
  200. 3629.  -     }
  201. 3630.  -
  202. 3631.  -     var scrollNode = browser.msie6 ? pageNode : window;
  203. 3632.  -     addEvent(scrollNode, 'scroll', Wall.scrollCheck);
  204. 3633.  -     addEvent(window, 'resize', Wall.scrollCheck);
  205. 3634.  -     cur.destroy.push(function () {
  206. 3635.  -       removeEvent(scrollNode, 'scroll', Wall.scrollCheck);
  207. 3636.  -       removeEvent(window, 'resize', Wall.scrollCheck);
  208. 3637.  -     });
  209. 3638.  -     cur.wallAutoMore = opts.automore;
  210. 3639.  -
  211. 3640.  -     placeholderSetup(cur.postField);
  212. 3641.  -
  213. 3642.  -     removeEvent(document, 'click', Wall.hideEditPostReply);
  214. 3643.  -     addEvent(document, 'click', Wall.hideEditPostReply);
  215. 3644.  -
  216. 3645.  -     if (opts.media_types) {
  217. 3646.  -       cur.wallAddMedia = initAddMedia(ge('page_add_media').firstChild, 'media_preview', opts.media_types, {
  218. 3647.  -         onMediaAdd: function() {
  219. 3648.  -           if (cur.module == 'profile' || cur.module == 'feed' || cur.module == 'wall') {
  220. 3649.  -             Wall.postChanged(val('post_field'), true);
  221. 3650.  -           }
  222. 3651.  -         }
  223. 3652.  -       });
  224. 3653.  -       cur.wallAddMedia.onChange = function() {
  225. 3654.  -         //Wall.checkPostLen('post_field', 'post_warn', val('post_field'), true);
  226. 3655.  -       }
  227. 3656.  -     }
  228. 3657.  -     cur.withUpload = window.WallUpload && !(browser.msie111 || browser.safari_mobile) && (cur.wallType == 'all' || cur.wallType == 'own' || cur.wallType == 'feed') && Wall.withMentions && cur.wallUploadOpts;
  229. 3658.  -     if (cur.withUpload && WallUpload.checkDragDrop()) {
  230. 3659.  -       var clean = function () {
  231. 3660.  -           removeEvent(document, 'dragover dragenter drop dragleave', cb);
  232. 3661.  -         },
  233. 3662.  -         cb = function (e) {
  234. 3663.  -           if (dragtimer !== false) {
  235. 3664.  -             clearTimeout(dragtimer);
  236. 3665.  -             dragtimer = false;
  237. 3666.  -           }
  238. 3667.  -           if (cur.uploadInited) {
  239. 3668.  -             clean();
  240. 3669.  -             return cancelEvent(e);
  241. 3670.  -           }
  242. 3671.  -           switch (e.type) {
  243. 3672.  -             case 'drop':
  244. 3673.  -               started = false;
  245. 3674.  -               delete cur.wallUploadFromDrag;
  246. 3675.  -               hide('post_upload_dropbox');
  247. 3676.  -               break;
  248. 3677.  -
  249. 3678.  -             case 'dragleave':
  250. 3679.  -               dragtimer = setTimeout(function () {
  251. 3680.  -                 started = false;
  252. 3681.  -                 delete cur.wallUploadFromDrag;
  253. 3682.  -                 hide('post_upload_dropbox');
  254. 3683.  -               }, 100);
  255. 3684.  -               break;
  256. 3685.  -
  257. 3686.  -             case 'dragover':
  258. 3687.  -             case 'dragenter':
  259. 3688.  -               if (!started) {
  260. 3689.  -                 started = (e.target && (e.target.tagName == 'IMG' || e.target.tagName == 'A')) ? 1 : 2;
  261. 3690.  -                 if (started == 2) {
  262. 3691.  -                   setTimeout(Wall.showEditPost, 0);
  263. 3692.  -                 }
  264. 3693.  -               }
  265. 3694.  -               if (started == 2) {
  266. 3695.  -                 cur.wallUploadFromDrag = 1;
  267. 3696.  -               }
  268. 3697.  -           }
  269. 3698.  -           return cancelEvent(e);
  270. 3699.  -         },
  271. 3700.  -         started = false,
  272. 3701.  -         dragtimer = false;
  273. 3702.  -       addEvent(document, 'dragover dragenter drop dragleave', cb);
  274. 3703.  -       cur.destroy.push(clean);
  275. 3704.  -     }
  276. 3705.  -     cur.nav.push(function(changed, old, n) {
  277. 3706.  -       if (!changed[0] && changed.fixed != undefined) {
  278. 3707.  -         Page.toggleFixedPost(cur.oid+'_'+cur.options['fixed_post_id']);
  279. 3708.  -         nav.setLoc(n);
  280. 3709.  -         return false;
  281. 3710.  -       }
  282. 3711.  -     });
  283. 3712.  -   },
  284. 3713.  -   switchOwner: function(obj, sw) {
  285. 3714.  -     obj.innerHTML = '<div class="progress_inline"></div>';
  286. 3715.  -     nav.change({owners_only: sw});
  287. 3716.  -   }
  288. 3717.  - }
  289. 3718.  -
  290. 3719.  - var wall = extend(Wall, {
  291. 3720.  -   showDeletePost: Wall._animDelX.pbind(0.3),
  292. 3721.  -   hideDeletePost: Wall._animDelX.pbind(0),
  293. 3722.  -   activeDeletePost: function(post, tt, action) {
  294. 3723.  -     Wall._animDelX(1, 1, post, action);
  295. 3724.  -     if (tt) showTooltip(ge((action || 'delete_post') + post), {text: tt, showdt: 0, black: 1, shift: [14, 3, 3]});
  296. 3725.  -   },
  297. 3726.  -   deactiveDeletePost: Wall._animDelX.pbind(0.3, 0)
  298. 3727.  - });
  299. 3728.  -
  300. 3729.  - WallUpload = {
  301. 3730.  -   photoUploaded: function(info, params) {
  302. 3731.  -     var i = info.ind !== undefined ? info.ind : info,
  303. 3732.  -         fileName = info.fileName ? info.fileName : info,
  304. 3733.  -         ind = info.fileName ? i + '_' + info.fileName : info,
  305. 3734.  -         prg = ge('upload' + ind + '_progress_wrap');
  306. 3735.  -
  307. 3736.  -     prg && hide(geByClass1('progress_x', prg));
  308. 3737.  -     ajax.post('al_photos.php', extend({act: 'choose_uploaded'}, params), {
  309. 3738.  -       onDone: function(media, data) {
  310. 3739.  -         cur.wallAddMedia.chooseMedia('photo', media, extend(data, {upload_ind: i + '_' + fileName}));
  311. 3740.  -       },
  312. 3741.  -       onFail: WallUpload.uploadFailed.pbind(info)
  313. 3742.  -     });
  314. 3743.  -   },
  315. 3744.  -   uploadFailed: function(info, code) {
  316. 3745.  -     var i = info.ind !== undefined ? info.ind : info, fileName = info.fileName ? info.fileName : info;
  317. 3746.  -     if (Upload.types[i] == 'fileApi' && !Upload.options[i].wiki_editor) {
  318. 3747.  -       var lnkId, ind = info.fileName ? i+'_'+info.fileName : info;
  319. 3748.  -       if (cur.imMedia) {
  320. 3749.  -         re('upload'+ind+'_progress_wrap');
  321. 3750.  -         lnkId = cur.imMedia.lnkId;
  322. 3751.  -         cur.addMedia[lnkId].unchooseMedia();
  323. 3752.  -       } else if (cur.addMedia) {
  324. 3753.  -         re('upload'+ind+'_progress_wrap');
  325. 3754.  -         lnkId = (cur.attachMediaIndexes || {})[fileName];
  326. 3755.  -         if (lnkId) cur.addMedia[lnkId].unchooseMedia();
  327. 3756.  -       }
  328. 3757.  -     }
  329. 3758.  -     // hide(box.progress);
  330. 3759.  -     topError('Upload failed', {dt: -1, type: 102, url: (ge('file_uploader_form' + i) || {}).action});
  331. 3760.  -     Upload.embed(i);
  332. 3761.  -   },
  333. 3762.  -   show: function () {
  334. 3763.  -     if (!cur.uploadInited) return;
  335. 3764.  -     var s = {};
  336. 3765.  -     if (cur.wallType == 'feed') {
  337. 3766.  -       removeClass(cur.uploadWrap, 'post_upload_min_wrap');
  338. 3767.  -       s.width = 515;
  339. 3768.  -       s[vk.rtl ? 'paddingLeft' : 'paddingRight'] = 35;
  340. 3769.  -     } else {
  341. 3770.  -       show(cur.uploadWrap);
  342. 3771.  -       s.width = 340;
  343. 3772.  -       s[vk.rtl ? 'paddingLeft' : 'paddingRight'] = 35;
  344. 3773.  -     }
  345. 3774.  -     setStyle('post_field', s);
  346. 3775.  -   },
  347. 3776.  -   hide: function () {
  348. 3777.  -     if (!cur.uploadInited) return;
  349. 3778.  -     var s = {};
  350. 3779.  -     if (cur.wallType == 'feed') {
  351. 3780.  -       addClass(cur.uploadWrap || ge('post_preupload_wrap'), 'post_upload_min_wrap');
  352. 3781.  -       s.width = 515;
  353. 3782.  -       s[vk.rtl ? 'paddingLeft' : 'paddingRight'] = 35;
  354. 3783.  -     } else {
  355. 3784.  -       hide(cur.uploadWrap);
  356. 3785.  -       s.width = 372;
  357. 3786.  -       s[vk.rtl ? 'paddingLeft' : 'paddingRight'] = 3;
  358. 3787.  -     }
  359. 3788.  -     setStyle('post_field', s);
  360. 3789.  -     hide('post_upload_dropbox');
  361. 3790.  -   },
  362. 3791.  -   checkDragDrop: function() {
  363. 3792.  -     var b = browser, bv = floatval(browser.version);
  364. 3793.  -     if (!(b.msie && bv >= 9 || b.mozilla && bv >= 3.5 || b.chrome || b.safari)) { // Drag'n'Drop reqs
  365. 3794.  -       return false;
  366. 3795.  -     }
  367. 3796.  -     return (window.XMLHttpRequest || window.XDomainRequest) &&
  368. 3797.  -            (window.FormData || window.FileReader && (window.XMLHttpRequest && XMLHttpRequest.sendAsBinary ||  window.ArrayBuffer && window.Uint8Array && (window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder)));
  369. 3798.  -   },
  370. 3799.  -   preinit: function () {
  371. 3800.  -     var data = cur.wallUploadOpts,
  372. 3801.  -         field = ge('post_field'),
  373. 3802.  -         tt = WallUpload.checkDragDrop() ?  ' onmouseover="showTooltip(this, {text: \'' + (data.opts.lang.wall_photos_drag_hint || 'You can also drop files here') + '\',  black: 1, shift: [3, -6, 0]})"' : '';
  374. 3803.  -     field.parentNode.insertBefore(cur.uploadWrap = ce('div', {
  375. 3804.  -       className: 'post_upload_wrap post_upload_min_wrap',
  376. 3805.  -       id: 'post_preupload_wrap',
  377. 3806.  -       innerHTML: '<div id="post_field_upload" class="post_upload"' + tt + '><input class="file" type="file" size="28" onchange="data(this, \'changed\', true); Wall.showEditPost();" ' + (browser.opera ? '' : 'multiple="true" ') + 'accept="image/jpeg,image/png,image/gif" name="photo"/></div>'
  378. 3807.  -     }), field);
  379. 3808.  -   },
  380. 3809.  -   init: function () {
  381. 3810.  -     removeEvent(bodyNode, 'dragover dragenter');
  382. 3811.  -     var preinited = ge('post_preupload_wrap'),
  383. 3812.  -         fileinput = preinited && geByTag1('input', preinited),
  384. 3813.  -         data = cur.wallUploadOpts,
  385. 3814.  -         field = ge('post_field'),
  386. 3815.  -         tt = WallUpload.checkDragDrop() ?  ' onmouseover="showTooltip(this, {text: \'' + (data.opts.lang.wall_photos_drag_hint || 'You can also drop files here') + '\', black: 1, shift: [3, -10, 0]})"' : '';
  387. 3816.  -
  388. 3817.  -     if (preinited) {
  389. 3818.  -       var btn = preinited.firstChild;
  390. 3819.  -       if (btn.tt && btn.tt.el) {
  391. 3820.  -         btn.tt.destroy();
  392. 3821.  -       }
  393. 3822.  -       re(preinited);
  394. 3823.  -     }
  395. 3824.  -     field.parentNode.insertBefore(cur.uploadWrap = ce('div', {
  396. 3825.  -       className: 'post_upload_wrap fl_r',
  397. 3826.  -       innerHTML: '<div id="post_field_upload" class="post_upload"' + tt + '></div>'
  398. 3827.  -     }), field);
  399. 3828.  -     var submitBox = ge('submit_post_box');
  400. 3829.  -     submitBox.insertBefore(ce('div', {
  401. 3830.  -       id: 'post_upload_dropbox',
  402. 3831.  -       className: 'post_upload_dropbox',
  403. 3832.  -       innerHTML: '<div class="post_upload_dropbox_inner noselect"><span class="post_upload_drop_label">' + (data.opts.lang.wall_drop_photos_here || 'Drop files here') + '</span><span class="post_upload_release_label">' + (data.opts.lang.wall_release_photos_here || 'Release button to attach files') + '</span></div>'
  404. 3833.  -     }), submitBox.firstChild);
  405. 3834.  -
  406. 3835.  -     Upload.init('post_field_upload', data.url, data.params, {
  407. 3836.  -       file_name: 'photo',
  408. 3837.  -       file_size_limit: 1024 * 1024 * 5, // 5Mb
  409. 3838.  -       file_types_description: 'Image files (*.jpg, *.png, *.gif)',
  410. 3839.  -       file_types: '*.jpg;*.JPG;*.png;*.PNG;*.gif;*.GIF',
  411. 3840.  -       file_input: fileinput,
  412. 3841.  -       accept: 'image/jpeg,image/png,image/gif',
  413. 3842.  -       file_match:  data.opts.ext_re,
  414. 3843.  -       lang: data.opts.lang,
  415. 3844.  -       wiki_editor: 0,
  416. 3845.  -
  417. 3846.  -       onUploadStart: function(info, res) {
  418. 3847.  -         var i = info.ind !== undefined ? info.ind : info, options = Upload.options[i];
  419. 3848.  -         if (Upload.types[i] == 'form') {
  420. 3849.  -           // show(box.progress);
  421. 3850.  -           geByClass1('file', ge('choose_photo_upload')).disabled = true;
  422. 3851.  -         }
  423. 3852.  -         if (Upload.types[i] == 'fileApi') {
  424. 3853.  -           if (cur.notStarted) {
  425. 3854.  -             boxQueue.hideLast();
  426. 3855.  -             delete cur.notStarted;
  427. 3856.  -           }
  428. 3857.  -           if (options.multi_progress) this.onUploadProgress(info, 0, 0);
  429. 3858.  -         }
  430. 3859.  -       },
  431. 3860.  -       onUploadComplete: function(info, res) {
  432. 3861.  -         var params, i = info.ind !== undefined ? info.ind : info, fileName = info.fileName ? info.fileName : info;
  433. 3862.  -         try {
  434. 3863.  -           params = eval('(' + res + ')');
  435. 3864.  -         } catch(e) {
  436. 3865.  -           params = q2ajx(res);
  437. 3866.  -         }
  438. 3867.  -         if (!params.photos) {
  439. 3868.  -           Upload.onUploadError(info);
  440. 3869.  -           return;
  441. 3870.  -         }
  442. 3871.  -         WallUpload.photoUploaded(info, params);
  443. 3872.  -       },
  444. 3873.  -       onUploadProgress: function(info, bytesLoaded, bytesTotal) {
  445. 3874.  -         var i = info.ind !== undefined ? info.ind : info;
  446. 3875.  -         if (Upload.types[i] == 'fileApi') {
  447. 3876.  -           var lnkId = (cur.attachMediaIndexes || {})[i];
  448. 3877.  -           if (lnkId === undefined || lnkId && cur.addMedia[lnkId].chosenMedia || cur.imMedia) {
  449. 3878.  -             var data = {loaded: bytesLoaded, total: bytesTotal};
  450. 3879.  -             if (info.fileName) data.fileName = info.fileName;
  451. 3880.  -             cur.wallAddMedia.showMediaProgress('photo', i, data);
  452. 3881.  -           }
  453. 3882.  -         }
  454. 3883.  -       },
  455. 3884.  -       onUploadError: WallUpload.uploadFailed,
  456. 3885.  -       onCheckServerFailed: function () {
  457. 3886.  -         delete cur.uploadInited;
  458. 3887.  -         WallUpload.hide();
  459. 3888.  -       },
  460. 3889.  -       onUploadCompleteAll: function (i) {
  461. 3890.  -         if (Upload.types[i] == 'form') {
  462. 3891.  -           Upload.embed(i);
  463. 3892.  -         }
  464. 3893.  -       },
  465. 3894.  -       onDragEnter: function () {
  466. 3895.  -         Wall.showEditPost();
  467. 3896.  -         var dropEl = ge('post_upload_dropbox').firstChild,
  468. 3897.  -             h = ge('submit_post_box').offsetHeight - (browser.webkit || browser.chrome ? 2 : 0);
  469. 3898.  -         if (cur.wallType != 'feed') {
  470. 3899.  -           h -= 16;
  471. 3900.  -         }
  472. 3901.  -         setStyle(dropEl, {height: h});
  473. 3902.  -       },
  474. 3903.  -
  475. 3904.  -       noFlash: 1,
  476. 3905.  -       multiple: 1,
  477. 3906.  -       multi_progress: 1,
  478. 3907.  -       max_files: 10,
  479. 3908.  -       chooseBox: 1,
  480. 3909.  -       clear: 1,
  481. 3910.  -       type: 'photo',
  482. 3911.  -       max_attempts: 3,
  483. 3912.  -       server: data.opts.server,
  484. 3913.  -       error: data.opts.default_error,
  485. 3914.  -       error_hash: data.opts.error_hash,
  486. 3915.  -       dropbox: 'post_upload_dropbox',
  487. 3916.  -       label: data.opts.label,
  488. 3917.  -       dragEl: bodyNode
  489. 3918.  -     });
  490. 3919.  -     cur.uploadInited = true;
  491. 3920.  -     WallUpload.show();
  492. 3921.  -     if (cur.wallUploadFromDrag) {
  493. 3922.  -       if (cur.wallUploadFromDrag == 1) {
  494. 3923.  -         var dropEl = ge('post_upload_dropbox'),
  495. 3924.  -             h = ge('submit_post_box').offsetHeight - (browser.webkit || browser.chrome ? 2 : 0);
  496. 3925.  -         if (cur.wallType != 'feed') {
  497. 3926.  -           h -= 16;
  498. 3927.  -         }
  499. 3928.  -         setStyle(dropEl.firstChild, {height: h});
  500. 3929.  -         show(dropEl);
  501. 3930.  -       }
  502. 3931.  -       delete cur.wallUploadFromDrag;
  503. 3932.  -     }
  504. 3933.  -   }
  505. 3934.  - };
  506. 3935.  -
  507. 3936.  - function initCustomMedia(lnk, types, opts) {
  508. 3937.  -   lnk = ge(lnk);
  509. 3938.  -   if (!lnk) return false;
  510. 3939.  -
  511. 3940.  -   opts = opts || {};
  512. 3941.  -
  513. 3942.  -   if (!window.__addMediaIndex) __addMediaIndex = 0;
  514. 3943.  -   var menuId = ++__addMediaIndex;
  515. 3944.  -
  516. 3945.  -   if (opts.bgsprite) {
  517. 3946.  -     var icons = opts.bgsprite;
  518. 3947.  -   } else if (window.devicePixelRatio >= 2) {
  519. 3948.  -     var icons = '/images/icons/attach_icons_2x.png?3';
  520. 3949.  -     opts.bgSize = '20px 198px';
  521. 3950.  -   } else {
  522. 3951.  -     var icons = '/images/icons/attach_icons.png?3';
  523. 3952.  -   }
  524. 3953.  -   vkImage().src = icons;
  525. 3954.  -
  526. 3955.  -   var html = '<div class="rows"><div class="add_media_head"><nobr>' + lnk.innerHTML + '</nobr></div></div>';
  527. 3956.  -
  528. 3957.  -   if (!window.customMenuNode) {
  529. 3958.  -     window.customMenuNode = domFC(domFC(pageNode.appendChild(ce('div', {
  530. 3959.  -       id: '',
  531. 3960.  -       innerHTML: '<div class="scroll_fix" id="custom_menu_wrap" style="width:' + (lastInnerWidth - 1) + 'px"><div id="custom_menu_cont"></div></div>'
  532. 3961.  -     }))));
  533. 3962.  -   }
  534. 3963.  -   var menuNode = ce('div', {
  535. 3964.  -     id: 'add_media_menu_' + menuId,
  536. 3965.  -     className: 'add_media_menu',
  537. 3966.  -     innerHTML: '<div class="add_media_rows">' + html + '</div>'
  538. 3967.  -   }, {position: 'absolute'}), rowsNode = geByClass1('rows', menuNode, 'div');
  539. 3968.  -   customMenuNode.appendChild(menuNode);
  540. 3969.  -
  541. 3970.  -   var _hideTimer, mediaMenu = {
  542. 3971.  -     id: menuId,
  543. 3972.  -     fixed: -1,
  544. 3973.  -     menuNode: menuNode,
  545. 3974.  -     updateFixed: function(newVal) {
  546. 3975.  -       if (mediaMenu.fixed != -1 && newVal != -1 && newVal !== undefined && mediaMenu.fixed == newVal) {
  547. 3976.  -         return;
  548. 3977.  -       }
  549. 3978.  -       if (mediaMenu.fixed == -1 || newVal !== undefined) {
  550. 3979.  -         if (newVal === undefined || newVal == -1) {
  551. 3980.  -           var el = lnk;
  552. 3981.  -           mediaMenu.fixed = false;
  553. 3982.  -           while (el) {
  554. 3983.  -             if (getStyle(el, 'position') == 'fixed') {
  555. 3984.  -               mediaMenu.fixed = true;
  556. 3985.  -               break;
  557. 3986.  -             }
  558. 3987.  -             el = el.offsetParent;
  559. 3988.  -           }
  560. 3989.  -         } else {
  561. 3990.  -           mediaMenu.fixed = newVal;
  562. 3991.  -         }
  563. 3992.  -         if (mediaMenu.fixed) {
  564. 3993.  -           setStyle(customMenuNode, {position: ''});
  565. 3994.  -           addClass(customMenuNode, 'fixed');
  566. 3995.  -         } else {
  567. 3996.  -           setStyle(customMenuNode, {position: 'absolute'});
  568. 3997.  -           removeClass(customMenuNode, 'fixed');
  569. 3998.  -         }
  570. 3999.  -         if (isVisible(menuNode)) {
  571. 4000.  -           mediaMenu._updatePosition(true);
  572. 4001.  -         }
  573. 4002.  -       }
  574. 4003.  -     },
  575. 4004.  -     show: function() {
  576. 4005.  -       clearTimeout(_hideTimer);
  577. 4006.  -       if (menuNode && !isVisible(menuNode)) {
  578. 4007.  -         lnk.blur();
  579. 4008.  -         mediaMenu.updateFixed(-1);
  580. 4009.  -         var h = mediaMenu._updatePosition(), el = menuNode.firstChild;
  581. 4010.  -
  582. 4011.  -         if (browser.msie && browser.version < 9 || browser.mobile) {
  583. 4012.  -           show(menuNode);
  584. 4013.  -         } else {
  585. 4014.  -           setStyle(el, {height: 26, overflow: 'hidden'});
  586. 4015.  -           fadeIn(menuNode, 200);
  587. 4016.  -           if (mediaMenu.reverse) {
  588. 4017.  -             setStyle(el, {position: 'absolute', bottom: '-25px', width: getSize(el.firstChild)[0]});
  589. 4018.  -             setStyle(el.firstChild, {position: 'absolute', bottom: '0px'});
  590. 4019.  -           }
  591. 4020.  -           animate(el, {height: h - 2}, 200, function() {
  592. 4021.  -             setStyle(el.firstChild, {position: 'relative', bottom: ''});
  593. 4022.  -             setStyle(el, {height: '', overflow: '', position: 'static'});
  594. 4023.  -           });
  595. 4024.  -         }
  596. 4025.  -         opts.onShow && opts.onShow();
  597. 4026.  -       }
  598. 4027.  -     },
  599. 4028.  -     _updatePosition: function(visible) {
  600. 4029.  -       var coords = getXY(lnk, mediaMenu.fixed);
  601. 4030.  -       var top = coords[1] - 4 + (browser.msie && browser.version < 8 ? 1 : 0);
  602. 4031.  -       var rowsEl = menuNode.firstChild, more = geByClass1('add_media_more', menuNode);
  603. 4032.  -       if (vk.rtl) {
  604. 4033.  -         var right = (lastInnerWidth - 1) - (coords[0] + getSize(lnk)[0] + 8);
  605. 4034.  -         setStyle(menuNode, {right: right, top: top});
  606. 4035.  -       } else {
  607. 4036.  -         var left = coords[0] - 8 + (browser.msie6 ? 1 : 0);
  608. 4037.  -         setStyle(menuNode, {left: left, top: top});
  609. 4038.  -       }
  610. 4039.  -
  611. 4040.  -       // Showing to up in case of little widget height
  612. 4041.  -       if (!visible) {
  613. 4042.  -         setStyle(menuNode, {visibility: 'hidden', display: 'block'});
  614. 4043.  -         if (more) {
  615. 4044.  -           hide(more);
  616. 4045.  -           show(more.nextSibling);
  617. 4046.  -         }
  618. 4047.  -       }
  619. 4048.  -       var countSize = getSize(rowsEl), st = (mediaMenu.fixed ? 0 : scrollGetY()), size = countSize;
  620. 4049.  -       if (!visible) {
  621. 4050.  -         if (more) {
  622. 4051.  -           show(more);
  623. 4052.  -           hide(more.nextSibling);
  624. 4053.  -           size = getSize(rowsEl);
  625. 4054.  -         }
  626. 4055.  -         setStyle(menuNode, {visibility: '', display: 'none'});
  627. 4056.  -       }
  628. 4057.  -
  629. 4058.  -       var needReverse = false;
  630. 4059.  -       if (countSize[1] - 25 < top - st && lastWindowHeight + st < top + countSize[1]) {
  631. 4060.  -         setStyle(rowsEl, 'marginTop', -size[1] + 25);
  632. 4061.  -         if (!mediaMenu.reverse) needReverse = true;
  633. 4062.  -       } else {
  634. 4063.  -         setStyle(rowsEl, 'marginTop', -4);//(/mac/.test(_ua) && browser.mozilla ? 22 : 20));
  635. 4064.  -         if (mediaMenu.reverse) needReverse = true;
  636. 4065.  -       }
  637. 4066.  -       if (needReverse) {
  638. 4067.  -         var els = rowsNode.childNodes, len = els.length, el = (mediaMenu.moreWrap || {}).lastChild || {};
  639. 4068.  -         while (len--) {
  640. 4069.  -           rowsNode.appendChild(els[len]);
  641. 4070.  -         }
  642. 4071.  -         els = el.childNodes; len = (els || []).length;
  643. 4072.  -         while (len--) {
  644. 4073.  -           el.appendChild(els[len]);
  645. 4074.  -         }
  646. 4075.  -         mediaMenu.reverse = !mediaMenu.reverse;
  647. 4076.  -         (mediaMenu.reverse ? addClass : removeClass)(menuNode, 'add_media_rev');
  648. 4077.  -       }
  649. 4078.  -
  650. 4079.  -       return size[1];
  651. 4080.  -     },
  652. 4081.  -     hide: function(noTimeout) {
  653. 4082.  -       clearTimeout(_hideTimer);
  654. 4083.  -       var hideFunc = (browser.msie && browser.version < 9 || browser.mobile) ? hide.pbind(menuNode) : fadeOut.pbind(menuNode, 100);
  655. 4084.  -       if (noTimeout === true) {
  656. 4085.  -         hideFunc();
  657. 4086.  -       } else {
  658. 4087.  -         _hideTimer = setTimeout(hideFunc, 300);
  659. 4088.  -       }
  660. 4089.  -       opts.onHide && opts.onHide();
  661. 4090.  -     },
  662. 4091.  -     setItems: function(types) {
  663. 4092.  -       for (var f = rowsNode.firstChild, l = rowsNode.lastChild; f != l; f = rowsNode.firstChild, l = rowsNode.lastChild) {
  664. 4093.  -         rowsNode.removeChild(f.className == 'add_media_head' ? l : f);
  665. 4094.  -       }
  666. 4095.  -       var test = '';
  667. 4096.  -       var spec_style = (/mac/.test(_ua) && browser.mozilla) ? {height: 19, paddingTop: 3} : {};
  668. 4097.  -       var moreNode = false;
  669. 4098.  -
  670. 4099.  -       var needHide = (types.length > 6 && getLang('global_add_media_more'));
  671. 4100.  -       mediaMenu.moreWrap = false;
  672. 4101.  -
  673. 4102.  -       each(types, function(i, v) { // [id, name, bg-position, onclick, href, bg-url, customStyle]
  674. 4103.  -
  675. 4104.  -         var attrs = {
  676. 4105.  -           innerHTML: '<nobr>' + v[1].replace(/\s/g, '&nbsp;') + '</nobr>',
  677. 4106.  -           className: 'add_media_type_' + menuId + '_' + v[0] + ' add_media_item'
  678. 4107.  -         }, style = v[6] || {
  679. 4108.  -           backgroundImage: 'url(' + (v[5] || icons) + ')',
  680. 4109.  -           backgroundPosition: (v[2] || '0 0')
  681. 4110.  -         }, row;
  682. 4111.  -         if (opts.bgSize) {
  683. 4112.  -           style.backgroundSize = opts.bgSize;
  684. 4113.  -         }
  685. 4114.  -
  686. 4115.  -         if (needHide && i == 3) {
  687. 4116.  -           var rowsEl = menuNode.firstChild;
  688. 4117.  -           var moreWrap = rowsNode.appendChild(ce('div', {
  689. 4118.  -             className: "add_media_more_wrap"
  690. 4119.  -           }));
  691. 4120.  -           addEvent(moreWrap, 'mouseover click', function() {
  692. 4121.  -             clearTimeout(mediaMenu.moreHide);
  693. 4122.  -             if (isVisible(moreWrap.lastChild)) return;
  694. 4123.  -             show(moreWrap.lastChild);
  695. 4124.  -             hide(moreWrap.firstChild);
  696. 4125.  -             if (!mediaMenu.reverse) return;
  697. 4126.  -             var size = getSize(rowsEl);
  698. 4127.  -             setStyle(rowsEl, 'marginTop', -size[1] + 25);
  699. 4128.  -           });
  700. 4129.  -           addEvent(moreWrap, 'mouseout', function () {
  701. 4130.  -             clearTimeout(mediaMenu.moreHide);
  702. 4131.  -             mediaMenu.moreHide = setTimeout(function() {
  703. 4132.  -               hide(moreWrap.lastChild);
  704. 4133.  -               show(moreWrap.firstChild);
  705. 4134.  -               if (!mediaMenu.reverse) return;
  706. 4135.  -               var size = getSize(rowsEl);
  707. 4136.  -               setStyle(rowsEl, 'marginTop', -size[1] + 25);
  708. 4137.  -             }, 300);
  709. 4138.  -           });
  710. 4139.  -           row = moreWrap.appendChild(ce('a', {
  711. 4140.  -             className: 'add_media_more add_media_item',
  712. 4141.  -             innerHTML: '<nobr>'+getLang('global_add_media_more')+'</nobr>'
  713. 4142.  -           }));
  714. 4143.  -           moreNode = ce('div', {
  715. 4144.  -             className: 'add_media_more_node',
  716. 4145.  -             innerHTML: '<div class="unshown"></div>'
  717. 4146.  -           }, {
  718. 4147.  -             display: 'none'
  719. 4148.  -           });
  720. 4149.  -           row = moreWrap.appendChild(moreNode);
  721. 4150.  -           mediaMenu.moreWrap = moreWrap;
  722. 4151.  -         }
  723. 4152.  -
  724. 4153.  -         extend(style, spec_style);
  725. 4154.  -         if (v[4]) {
  726. 4155.  -           attrs.href = v[4];
  727. 4156.  -         }
  728. 4157.  -         row = (moreNode ? moreNode : rowsNode).appendChild(ce('a', attrs, style));
  729. 4158.  -         if (v[3]) {
  730. 4159.  -           addEvent(row, 'click', function () {
  731. 4160.  -             mediaMenu.hide(true);
  732. 4161.  -             if (opts.onItemClick && !opts.onItemClick(v[0])) {
  733. 4162.  -               return false;
  734. 4163.  -             }
  735. 4164.  -             v[3]();
  736. 4165.  -             return false;
  737. 4166.  -           });
  738. 4167.  -         }
  739. 4168.  -       });
  740. 4169.  -     }
  741. 4170.  -   };
  742. 4171.  -
  743. 4172.  -   types && mediaMenu.setItems(types);
  744. 4173.  -
  745. 4174.  -   removeEvent(lnk, 'mouseover');
  746. 4175.  -   addEvent(lnk, 'mouseover click', mediaMenu.show);
  747. 4176.  -   addEvent(lnk, 'mouseout', mediaMenu.hide);
  748. 4177.  -   addEvent(menuNode, 'mouseover', mediaMenu.show);
  749. 4178.  -   addEvent(menuNode, 'mouseout', mediaMenu.hide);
  750. 4179.  -   addEvent(menuNode, 'click', cancelEvent);
  751. 4180.  -   addEvent(geByClass1('add_media_header', menuNode), 'click', function(e) {
  752. 4181.  -     mediaMenu.show(true);
  753. 4182.  -     cancelEvent(e);
  754. 4183.  -   });
  755. 4184.  -
  756. 4185.  -   cur.destroy.push(function() {
  757. 4186.  -     cleanElems(menuNode);
  758. 4187.  -     re(menuNode);
  759. 4188.  -     removeEvent(lnk, 'click', mediaMenu.show);
  760. 4189.  -   });
  761. 4190.  -
  762. 4191.  -   return mediaMenu;
  763. 4192.  - }
  764. 4193.  -
  765. 4194.  - var urlActiveExp = /([!()?., \n\r\t \u00A0]|^)((https?:\/\/)?((?:[a-z0-9_\-]+\.)+[a-z]{2,6})(\/.*?)?)(&nbsp;|[ \t\r\n \u00A0])/i,
  766. 4195.  -     urlInactiveExp = /([!()?., \n\r\t \u00A0]|^)((https?:\/\/)?((?:[a-z0-9_\-]+\.)+[a-z]{2,6})(\/.*?)?)(&nbsp;|[ \t\r\n \u00A0]|$)/i;
  767. 4196.  -
  768. 4197.  - function initAddMedia(lnk, previewId, mediaTypes, opts) {
  769. 4198.  -   var types = [], bgposes = {graffiti: -152, video: -20, photo: 3, audio: -42, poll: -108, doc: -64, map: -86, note: -130, postpone: -173}, addMedia;
  770. 4199.  -   opts = opts || {};
  771. 4200.  -   each (mediaTypes || [], function (i, v) {
  772. 4201.  -     if (!v[1]) return;
  773. 4202.  -     var handler = false, toId = opts.toId || cur.postTo, params = {to_id: toId, scrollbar_width: sbWidth()};
  774. 4203.  -     params.mail_add = opts.mail || nav.strLoc.match(/^(mail|im|al_mail\.php|al_im\.php)($|\?)/) ? 1 : '';
  775. 4204.  -     switch (v[0]) {
  776. 4205.  -       case 'graffiti':
  777. 4206.  -         if ((browser.chrome || browser.opera || browser.mobile || browser.safari || browser.mozilla || browser.msie && intval(browser.version) > 8) &&
  778. 4207.  -             document.createElement('canvas').getContext) {
  779. 4208.  -           handler = showBox.pbind('al_wall.php', {act: 'canvas_draw_box', to_id: toId, flash: browser.flash}, {cache: 1});
  780. 4209.  -         } else {
  781. 4210.  -           handler = showBox.pbind('al_wall.php', {act: 'draw_box', to_id: toId, flash: browser.flash}, {cache: 1});
  782. 4211.  -         }
  783. 4212.  -         break;
  784. 4213.  -       case 'photos_list':
  785. 4214.  -         handler = showBox.pbind('al_photos.php', extend(params, {act: 'choose_photo'}), {cache: 1, stat: ['photos.js', 'photos.css', 'upload.js']});
  786. 4215.  -         break;
  787. 4216.  -       case 'photo':
  788. 4217.  -         handler = showBox.pbind('al_photos.php', extend(params, {act: 'choose_photo'}), {cache: 1, stat: ['photos.js', 'photos.css', 'upload.js']});
  789. 4218.  -         break;
  790. 4219.  -       case 'video':
  791. 4220.  -         handler = showBox.pbind('video.php', extend(params, {act: 'a_choose_video_box'}), {cache: 1});
  792. 4221.  -         break;
  793. 4222.  -       case 'audio':
  794. 4223.  -         handler = showBox.pbind('audio', extend(params, {act: 'a_choose_audio_box'}), {cache: 1});
  795. 4224.  -         break;
  796. 4225.  -       case 'poll':
  797. 4226.  -         handler = function () {addMedia.chooseMedia('poll', '', v[2])};
  798. 4227.  -         break;
  799. 4228.  -       case 'app':
  800. 4229.  -         handler = showBox.pbind('apps.php', {act: 'a_choose_app_box', to_id: toId, aid: v[2]}, {stat: ['apps_flash.js'], cache: 1});
  801. 4230.  -         break;
  802. 4231.  -       case 'doc':
  803. 4232.  -         handler = showBox.pbind('docs.php', extend(params, {act: 'a_choose_doc_box'}), {stat: ['docs.css']});
  804. 4233.  -         break;
  805. 4234.  -       case 'map':
  806. 4235.  -         handler = showBox.pbind('al_places.php', extend(params, {act: 'a_choose_place_box'}), {stat: ['places.css', 'map.css', 'maps.js', 'ui_controls.css', 'ui_controls.js', 'boxes.css'], cache: 1, width: 640, bodyStyle: 'padding: 0px;'});
  807. 4236.  -         break;
  808. 4237.  -       case 'note':
  809. 4238.  -         handler = showWiki.pbind({note: 'new'}, true);
  810. 4239.  -         break;
  811. 4240.  -       case 'postpone':
  812. 4241.  -         handler = function () {addMedia.chooseMedia('postpone', v[1], v[2])};
  813. 4242.  -         break;
  814. 4243.  -     }
  815. 4244.  -     var isApp = (v[0] == 'app');
  816. 4245.  -     var icon = isApp ? v[4] : false;
  817. 4246.  -     var bgpos = isApp ? '5px 5px' : ('3px ' + bgposes[v[0]] + 'px');
  818. 4247.  -     var url = isApp ? ('/app' + v[2] + '?to_id=' + toId) : false;
  819. 4248.  -     var name = v[1].replace(/\s/g, '&nbsp;');
  820. 4249.  -     types.push([v[0], v[1], bgpos, handler, url, icon]);
  821. 4250.  -   });
  822. 4251.  -
  823. 4252.  -   var limit = opts.limit || 10,
  824. 4253.  -       multi = limit > 1;
  825. 4254.  -
  826. 4255.  -   var menu = initCustomMedia(lnk, types, {
  827. 4256.  -     onShow: function () {
  828. 4257.  -       cur.chooseMedia = addMedia.chooseMedia;
  829. 4258.  -       cur.showMediaProgress = addMedia.showMediaProgress;
  830. 4259.  -       cur.attachCount = addMedia.attachCount;
  831. 4260.  -     },
  832. 4261.  -     onItemClick: function(type) {
  833. 4262.  -       if (multi && addMedia.attachCount() >= limit && type !== 'postpone') {
  834. 4263.  -         showFastBox(getLang('global_error'), getLang('attachments_limit', limit));
  835. 4264.  -         return false;
  836. 4265.  -       }
  837. 4266.  -       return true;
  838. 4267.  -     }
  839. 4268.  -   });
  840. 4269.  -
  841. 4270.  -   if (!menu) return;
  842. 4271.  -   previewId = previewId || 'media_preview';
  843. 4272.  -
  844. 4273.  -   var lnkId = menu.id,
  845. 4274.  -       previewEl = ge(previewId),
  846. 4275.  -       progressEl, picsEl, docsEl;
  847. 4276.  -
  848. 4277.  -   if (multi) {
  849. 4278.  -     val(previewEl, '<div id="page_pics_preview' + lnkId + '" class="page_pics_preview media_preview clear_fix"></div><div id="page_docs_preview' + lnkId + '" class="page_docs_preview media_preview clear_fix"></div><div id="page_progress_preview' + lnkId + '" class="page_progress_preview media_preview clear_fix"></div>');
  850. 4279.  -     var picsEl = previewEl.childNodes[0],
  851. 4280.  -         docsEl = previewEl.childNodes[1],
  852. 4281.  -         progressEl = previewEl.childNodes[2];
  853. 4282.  -     removeClass(previewEl, 'media_preview');
  854. 4283.  -     addClass(previewEl, 'multi_media_preview');
  855. 4284.  -   }
  856. 4285.  -
  857. 4286.  -   addMedia = {
  858. 4287.  -     _addMediaLink: lnk,
  859. 4288.  -     lnkId: lnkId,
  860. 4289.  -     menu: menu,
  861. 4290.  -     handlers: {},
  862. 4291.  -     chosenMedias: [],
  863. 4292.  -     _showAddMedia: function() {
  864. 4293.  -       menu.show();
  865. 4294.  -     },
  866. 4295.  -     _hideAddMedia: function(noTimeout) {
  867. 4296.  -       menu.hide(noTimeout);
  868. 4297.  -     },
  869. 4298.  -     chooseMedia: function(type, media, data, url, noboxhide) {
  870. 4299.  -       if (addMedia.onChange && addMedia.onChange(type, media, data) === false) {
  871. 4300.  -         return false;
  872. 4301.  -       }
  873. 4302.  -       if (inArray(type, opts.disabledTypes || [])) {
  874. 4303.  -         return false;
  875. 4304.  -       }
  876. 4305.  -       if (addMedia.attachCount() >= limit && data.upload_ind === undefined && type !== 'postpone') {
  877. 4306.  -         if (multi) {
  878. 4307.  -           return false;
  879. 4308.  -         } else {
  880. 4309.  -           addMedia.unchooseMedia();
  881. 4310.  -         }
  882. 4311.  -       }
  883. 4312.  -       var already = false, alreadyTypes = {};
  884. 4313.  -       if (multi) {
  885. 4314.  -         each (addMedia.chosenMedias, function () {
  886. 4315.  -           if (this[0] == type && this[1] == media) {
  887. 4316.  -             already = true;
  888. 4317.  -             return false;
  889. 4318.  -           }
  890. 4319.  -           alreadyTypes[this[0]] = alreadyTypes[this[0]] ? alreadyTypes[this[0]] + 1 : 1;
  891. 4320.  -         });
  892. 4321.  -         if (already) {
  893. 4322.  -           return false;
  894. 4323.  -         }
  895. 4324.  -       }
  896. 4325.  -       var preview = '', postview = '', toPics = false, oncl;
  897. 4326.  -       switch (type) {
  898. 4327.  -         case 'graffiti':
  899. 4328.  -           if (!isObject(data)) {
  900. 4329.  -             data = {thumb: data || ''};
  901. 4330.  -           }
  902. 4331.  -           preview = '<div class="fl_l page_preview_graffiti"><img class="page_preview_graffiti" src="' + data.thumb + '" /></div>';
  903. 4332.  -           toPics = true;
  904. 4333.  -           break;
  905. 4334.  -
  906. 4335.  -         case 'photos_list':
  907. 4336.  -           hide(this._addMediaLink);
  908. 4337.  -           vkImage().src = data[1];
  909. 4338.  -           oncl = opts.nocl ? '' : ' onclick="return showPhoto(\'' + data[4] + '\', \'' + data[2] + '\', ' + data[3].replace(/"/g, '&quot;') + ');"';
  910. 4339.  -           preview = '<div' + oncl + ' class="fl_l page_preview_photo"><img class="page_preview_photo" src="' + data[1] + '" /></div>';
  911. 4340.  -           toPics = true;
  912. 4341.  -           break;
  913. 4342.  -
  914. 4343.  -         case 'photo':
  915. 4344.  -           vkImage().src = data[1];
  916. 4345.  -           if (!isObject(data)) {
  917. 4346.  -             data = {
  918. 4347.  -               thumb_m: data[0] || '',
  919. 4348.  -               thumb_s: data[1] || '',
  920. 4349.  -               list: data[2] || '',
  921. 4350.  -               view_opts: data[3] || '',
  922. 4351.  -               upload_ind: data.upload_ind || undefined
  923. 4352.  -             };
  924. 4353.  -           }
  925. 4354.  -           oncl = opts.nocl ? '' : ' onclick="return showPhoto(\'' + media + '\', \'' + data.list + '\', ' + data.view_opts.replace(/"/g, '&quot;') + ');"';
  926. 4355.  -           preview = '<div ' + oncl + ' class="fl_l page_preview_photo"><img class="page_preview_photo" src="' + data.thumb_m + '" /></div>';
  927. 4356.  -           toPics = true;
  928. 4357.  -           break;
  929. 4358.  -
  930. 4359.  -         case 'video':
  931. 4360.  -           if (!isObject(data)) {
  932. 4361.  -             data = {
  933. 4362.  -               thumb: data || ''
  934. 4363.  -             };
  935. 4364.  -           }
  936. 4365.  -           oncl = opts.nocl ? '' : ' onclick="return showVideo(\'' + media + '\');"';
  937. 4366.  -           preview = '<div' + oncl + ' class="fl_l page_preview_video"><img class="page_preview_video" src="' + data.thumb + '" /></div>';
  938. 4367.  -           toPics = true;
  939. 4368.  -           break;
  940. 4369.  -
  941. 4370.  -         case 'audio':
  942. 4371.  -           if (!data.info) return false;
  943. 4372.  -           preview = Page.addAudioPreview(media, data);
  944. 4373.  -           break;
  945. 4374.  -
  946. 4375.  -         case 'app':
  947. 4376.  -           preview = '<div class="app fl_l"><img src="' + data[0] + '" /><span>' + data[1] + '</span></div>';
  948. 4377.  -           each(geByClass('add_media_type_' + lnkId + '_app', menu.menuNode, 'a'), function () {hide(this);});
  949. 4378.  -           break;
  950. 4379.  -
  951. 4380.  -         case 'doc':
  952. 4381.  -           if (!data.lang) return false;
  953. 4382.  -           if (data.thumb && data.thumb_s) {
  954. 4383.  -             preview = '<a target="_blank" href="' + data.href + '" class="fl_l"><div class="page_preview_doc_photo"><img src="' + data.thumb_s + '" align="center"></div><div class="page_preview_doc_photo_hint">' + data.title + '</div></a>';
  955. 4384.  -             toPics = true;
  956. 4385.  -           } else {
  957. 4386.  -             preview = '<a target="_blank" href="' + data.href + '" class="medadd_h medadd_h_doc inl_bl">' + data.lang.profile_choose_doc + '</a>';
  958. 4387.  -             postview = '<div class="medadd_c medadd_c_doc"><a target="_blank" href="' + data.href + '">' + data.title + '</a></div>';
  959. 4388.  -           }
  960. 4389.  -           break;
  961. 4390.  -
  962. 4391.  -         case 'share':
  963. 4392.  -           if (alreadyTypes.share || alreadyTypes.page || !data.lang) {
  964. 4393.  -             return false;
  965. 4394.  -           }
  966. 4395.  -           if (isArray(data)) {
  967. 4396.  -             data = {
  968. 4397.  -               domain: data[0],
  969. 4398.  -               url: data[1],
  970. 4399.  -               initialPattern: data[2],
  971. 4400.  -               title: data[3],
  972. 4401.  -               description: data[4],
  973. 4402.  -               images: [data[5]],
  974. 4403.  -               user_id: data[6],
  975. 4404.  -               photo_id: data[7]
  976. 4405.  -             };
  977. 4406.  -           };
  978. 4407.  -           preview = '<a target="_blank" href="/away.php?to=' + encodeURIComponent(data.url) + '" class="medadd_h medadd_h_link inl_bl">' + data.lang.profile_choose_link + '</a>';
  979. 4408.  -           addMedia.shareData = extend(addMedia.shareData || {}, data, {imagesStyles: ['']});
  980. 4409.  -           break;
  981. 4410.  -
  982. 4411.  -         case 'poll':
  983. 4412.  -           if (!data.lang) return false;
  984. 4413.  -           preview = '<div class="medadd_h medadd_h_poll inl_bl">' + data.lang.q + '</div>';
  985. 4414.  -           hide(geByClass1('add_media_type_' + lnkId + '_poll', menu.menuNode, 'a'));
  986. 4415.  -           break;
  987. 4416.  -
  988. 4417.  -         case 'map':
  989. 4418.  -           preview = '<div class="fl_l"><a onclick="return showBox(\'al_places.php\', {act: \'geo_box\', lat: '+data[0]+', long: '+data[1]+', provider: '+intval(data[3])+'});"><div class="page_media_map_point"></div><img class="page_preview_map" width="180" height="70" src="'+locProtocol+'//maps.googleapis.com/maps/api/staticmap?center='+data[0]+','+data[1]+'&zoom=11&size='+(window.devicePixelRatio >= 2 ? '360x140' : '180x70')+'&sensor=false&language='+data[2]+'" /></a></div>';
  990. 4419.  -           toPics = true;
  991. 4420.  -           hide(geByClass1('add_media_type_' + lnkId + '_map', ge('add_media_menu_' + lnkId)));
  992. 4421.  -           break;
  993. 4422.  -
  994. 4423.  -         case 'page':
  995. 4424.  -           if (alreadyTypes.share || alreadyTypes.page || !data.lang) {
  996. 4425.  -             return false;
  997. 4426.  -           }
  998. 4427.  -           var lst = data.media.split('_');
  999. 4428.  -           preview = '<a href="/page' + data.media + '" onclick="return showWiki({oid: ' + lst[0] + ', id: ' + lst[1] + '}, false, event)" class="medadd_h medadd_h_page inl_bl">' + data.lang.profile_choose_page + '</a>';
  1000. 4429.  -           break;
  1001. 4430.  -
  1002. 4431.  -         case 'album':
  1003. 4432.  -           vkImage().src = data[1];
  1004. 4433.  -           oncl = opts.nocl ? '' : ' href="/album' + media + '" onclick="return nav.change({z: \'album' + media + '\'}, event)"';
  1005. 4434.  -           var cls = 'fl_l page_preview_album wall_album_cover_wrap' + (data.thumb ? '' : ' wall_album_nocover');
  1006. 4435.  -           preview = '<a class="' + cls + '" ' + oncl + '>\
  1007. 4436.  - ' + (data.thumb ? '<img class="wall_album_cover" src="' + data.thumb + '"/>' : '') + '\
  1008. 4437.  -   <div class="wall_album_caption">\
  1009. 4438.  -     <div class="wall_album_title_wrap clear_fix">\
  1010. 4439.  -       <div class="wall_album_title fl_l">' + data.title + '</div>\
  1011. 4440.  -       <div class="wall_album_count fl_r">' + data.count + '</div>\
  1012. 4441.  -     </div>\
  1013. 4442.  -   </div>\
  1014. 4443.  - </a>';
  1015. 4444.  -           toPics = true;
  1016. 4445.  -           break;
  1017. 4446.  -
  1018. 4447.  -         case 'note':
  1019. 4448.  -           if (!data.lang) return false;
  1020. 4449.  -           preview = '<a onclick="showWiki({w: \'note' + data.raw + '\', edit: 1}, true, event)" class="medadd_h medadd_h_note inl_bl">' + data.lang.profile_choose_note + '</a>';
  1021. 4450.  -           postview = '<div class="medadd_c medadd_c_note"><a onclick="showWiki({w: \'note' + data.raw + '\', edit: 1}, true, event)" id="share_note_title' + data.raw + '">' + data.title + '</a></div>';
  1022. 4451.  -           break;
  1023. 4452.  -
  1024. 4453.  -         case 'postpone':
  1025. 4454.  -           preview = '<div class="medadd_h medadd_h_timer inl_bl">' + data.lang.profile_choose_timer + '<span id="postpone_preview' + lnkId + '"></span></div>';
  1026. 4455.  -
  1027. 4456.  -           if (cur.editingPost && domPN(docsEl).id == 'wpe_media_preview') {
  1028. 4457.  -             media = intval(media);
  1029. 4458.  -             if (media) {
  1030. 4459.  -               data.date = media;
  1031. 4460.  -             } else {
  1032. 4461.  -               data.date = intval(cur.editingPost[6]);
  1033. 4462.  -             }
  1034. 4463.  -             var exp = geByClass1('medadd_c_timersett', docsEl);
  1035. 4464.  -             if (exp) {
  1036. 4465.  -               var pn = domPN(exp);
  1037. 4466.  -               exp = pn.innerHTML;
  1038. 4467.  -               re(pn);
  1039. 4468.  -             } else {
  1040. 4469.  -               exp = '';
  1041. 4470.  -             }
  1042. 4471.  -             geByTag1('button', geByClass1('button_blue', ge('post'+cur.editingPost[0]))).innerHTML = getLang('global_save');
  1043. 4472.  -           } else {
  1044. 4473.  -             if (cur.postponedLastDate) {
  1045. 4474.  -               data.date = intval(cur.postponedLastDate) + 14400;
  1046. 4475.  -             }
  1047. 4476.  -             var chk = ge('official');
  1048. 4477.  -             if (chk) {
  1049. 4478.  -               if (!isChecked(chk)) {
  1050. 4479.  -                 checkbox(chk);
  1051. 4480.  -                 toggle('signed', true);
  1052. 4481.  -               }
  1053. 4482.  -               addClass(chk, 'disabled');
  1054. 4483.  -             }
  1055. 4484.  -             var btn = ge('send_post');
  1056. 4485.  -             if (btn) {
  1057. 4486.  -               btn.innerHTML = data['lang']['profile_wall_postpone_btn'];
  1058. 4487.  -             }
  1059. 4488.  -           }
  1060. 4489.  -           hide(geByClass1('add_media_type_' + lnkId + '_postpone', menu.menuNode, 'a'));
  1061. 4490.  -           break;
  1062. 4491.  -       }
  1063. 4492.  -
  1064. 4493.  -       if (multi) {
  1065. 4494.  -         var medias = addMedia.chosenMedias,
  1066. 4495.  -             ind = medias.length,
  1067. 4496.  -             mediaEl = (type == 'photos_list') ?
  1068. 4497.  -               se('<div class="page_preview_' + type + '_wrap" style="position: relative">' + preview + '<div class="page_photos_count">' + media.split(',').length + '</div></div>') :
  1069. 4498.  -               se('<div class="page_preview_' + type + '_wrap"' + (opts.nocl ? ' style="cursor: default"' : '') + '>' + preview + '<div class="page_media_x_wrap inl_bl" '+ (browser.msie ? 'title' : 'tootltip') + '="'+getLang('dont_attach')+'" onmouseover="if (browser.msie) return; showTooltip(this, {text: this.getAttribute(\'tootltip\'), shift: [14, 3, 3], black: 1})" onclick="cur.addMedia['+addMedia.lnkId+'].unchooseMedia(' + ind + ')"><div class="page_media_x"></div></div>' + postview + '</div>');
  1070. 4499.  -         addClass(mediaEl, toPics ? 'fl_l' : 'clear_fix');
  1071. 4500.  -         if (data.upload_ind !== undefined) re('upload' + data.upload_ind + '_progress_wrap');
  1072. 4501.  -         (toPics ? picsEl : docsEl).appendChild(mediaEl);
  1073. 4502.  -         medias.push([type, media, mediaEl, url]);
  1074. 4503.  -
  1075. 4504.  -         toggle(picsEl, picsEl.childNodes.length > 0);
  1076. 4505.  -         toggle(docsEl, docsEl.childNodes.length > 0);
  1077. 4506.  -         toggle(progressEl, progressEl.childNodes.length > 0);
  1078. 4507.  -         if (opts.toggleLnk) toggle(lnk, addMedia.attachCount() < limit);
  1079. 4508.  -       } else {
  1080. 4509.  -         val(previewEl, '<div class="fl_l">' + preview + '</div><div class="x fl_l" onmouseover="showTooltip(this, {text: \'' + getLang('dont_attach') + '\', shift: [0, 3, 3]})" onclick="cur.addMedia[' + lnkId + '].unchooseMedia()"></div>');
  1081. 4510.  -         show(previewEl);
  1082. 4511.  -         addMedia.chosenMedia = [type, media];
  1083. 4512.  -         addMedia.chosenMediaData = data;
  1084. 4513.  -       }
  1085. 4514.  -
  1086. 4515.  -       if (type == 'share') {
  1087. 4516.  -         if (data.title && !url) {
  1088. 4517.  -           cur.shareShowImg = 0;
  1089. 4518.  -           addMedia.showPreview(true);
  1090. 4519.  -           addMedia.shareData.images = false;
  1091. 4520.  -         } else {
  1092. 4521.  -           addMedia.showExternalPreview();
  1093. 4522.  -         }
  1094. 4523.  -       } else if (type == 'page') {
  1095. 4524.  -         if (!data['nopreview']) {
  1096. 4525.  -           cur.shareShowImg = 0;
  1097. 4526.  -           addMedia.shareData = extend(addMedia.shareData || {}, data, {images: false});
  1098. 4527.  -           addMedia.showPreview();
  1099. 4528.  -         }
  1100. 4529.  -       } else if (type == 'poll') {
  1101. 4530.  -         addMedia.createPoll(data);
  1102. 4531.  -       } else if (type == 'postpone') {
  1103. 4532.  -         addMedia.setupPostpone(data, exp);
  1104. 4533.  -       }
  1105. 4534.  -
  1106. 4535.  -       if (!cur.fileApiUploadStarted && noboxhide !== true && type != 'poll' && type != 'share' && type != 'page' && type != 'postpone') {
  1107. 4536.  -         boxQueue.hideLast();
  1108. 4537.  -       }
  1109. 4538.  -
  1110. 4539.  -       cur.lastPostMsg = false;
  1111. 4540.  -       if (opts.onMediaAdd) {
  1112. 4541.  -         opts.onMediaAdd();
  1113. 4542.  -       }
  1114. 4543.  -
  1115. 4544.  -       if (data.upload_ind !== undefined) {
  1116. 4545.  -         delete data.upload_ind;
  1117. 4546.  -       }
  1118. 4547.  -       return false;
  1119. 4548.  -     },
  1120. 4549.  -     unchooseMedia: function(ind) {
  1121. 4550.  -       if (addMedia.onChange && addMedia.onChange(false, ind) === false) {
  1122. 4551.  -         return false;
  1123. 4552.  -       }
  1124. 4553.  -       if (multi) {
  1125. 4554.  -         if (ind === undefined) {
  1126. 4555.  -           each (addMedia.chosenMedias, function (k, v) {
  1127. 4556.  -             if (v && k !== undefined) addMedia.unchooseMedia(k);
  1128. 4557.  -           });
  1129. 4558.  -           addMedia.urlsCancelled = [];
  1130. 4559.  -           return;
  1131. 4560.  -         }
  1132. 4561.  -         var medias = addMedia.chosenMedias, x;
  1133. 4562.  -         if (medias[ind]) {
  1134. 4563.  -           if ((x = geByClass1('page_media_x_wrap', medias[ind][2], 'div')) && x.tt && x.tt.el) {
  1135. 4564.  -             x.tt.destroy();
  1136. 4565.  -           }
  1137. 4566.  -           re(medias[ind][2]);
  1138. 4567.  -           switch (medias[ind][0]) {
  1139. 4568.  -             case 'page':
  1140. 4569.  -             case 'share':
  1141. 4570.  -               addMedia.shareData = {};
  1142. 4571.  -               re(addMedia.sharePreview);
  1143. 4572.  -               delete addMedia.sharePreview;
  1144. 4573.  -               break;
  1145. 4574.  -
  1146. 4575.  -             case 'poll':
  1147. 4576.  -               re(addMedia.pollPreview);
  1148. 4577.  -               addMedia.pollPreview = false;
  1149. 4578.  -               show(geByClass1('add_media_type_' + lnkId + '_poll', menu.menuNode, 'a'));
  1150. 4579.  -               break;
  1151. 4580.  -
  1152. 4581.  -             case 'app':
  1153. 4582.  -               each(geByClass('add_media_type_' + lnkId + '_app', menu.menuNode, 'a'), function () {show(this);});
  1154. 4583.  -               break;
  1155. 4584.  -
  1156. 4585.  -             case 'map':
  1157. 4586.  -               show(geByClass1('add_media_type_' + lnkId + '_map', ge('add_media_menu_' + lnkId)));
  1158. 4587.  -               break;
  1159. 4588.  -
  1160. 4589.  -             case 'postpone':
  1161. 4590.  -               var exp = geByClass1('medadd_c_timersett', addMedia.postponePreview);
  1162. 4591.  -               if (cur.editingPost && exp) {
  1163. 4592.  -                 re(domFC(addMedia.postponePreview));
  1164. 4593.  -               } else {
  1165. 4594.  -                 re(addMedia.postponePreview);
  1166. 4595.  -               }
  1167. 4596.  -               addMedia.postponePreview = false;
  1168. 4597.  -               removeClass('official', 'disabled');
  1169. 4598.  -               if (!cur.editingPost) {
  1170. 4599.  -                 ge('send_post').innerHTML = getLang('wall_send');
  1171. 4600.  -               } else {
  1172. 4601.  -                 geByTag1('button', geByClass1('button_blue', ge('post'+cur.editingPost[0]))).innerHTML = getLang('wall_publish_now');
  1173. 4602.  -               }
  1174. 4603.  -               show(geByClass1('add_media_type_' + lnkId + '_postpone', menu.menuNode, 'a'));
  1175. 4604.  -               break;
  1176. 4605.  -           }
  1177. 4606.  -           medias[ind] = false;
  1178. 4607.  -         }
  1179. 4608.  -         if (opts.toggleLnk) toggle(lnk, addMedia.attachCount() < limit);
  1180. 4609.  -         toggle(picsEl, picsEl.childNodes.length > 0);
  1181. 4610.  -         toggle(docsEl, docsEl.childNodes.length > 0);
  1182. 4611.  -         toggle(progressEl, progressEl.childNodes.length > 0);
  1183. 4612.  -       } else {
  1184. 4613.  -         var share, x;
  1185. 4614.  -         if (addMedia.chosenMedia) {
  1186. 4615.  -           if ((x = previewEl.firstChild.nextSibling) && x.tt && x.tt.el) {
  1187. 4616.  -             x.tt.destroy();
  1188. 4617.  -           }
  1189. 4618.  -           addMedia.chosenMedia = false;
  1190. 4619.  -           addMedia.chosenMediaData = false;
  1191. 4620.  -           val(previewEl, '');
  1192. 4621.  -           hide(previewEl);
  1193. 4622.  -         }
  1194. 4623.  -         if (share = addMedia.shareData) {
  1195. 4624.  -           if (share.url) {
  1196. 4625.  -             addMedia.urlsCancelled.push(share.url);
  1197. 4626.  -           }
  1198. 4627.  -           if (share.initialPattern) {
  1199. 4628.  -             addMedia.urlsCancelled.push(share.initialPattern);
  1200. 4629.  -           }
  1201. 4630.  -           addMedia.shareData = {};
  1202. 4631.  -         }
  1203. 4632.  -         each([addMedia.sharePreview, addMedia.pollPreview, addMedia.postponePreview], function () {re(this);});
  1204. 4633.  -         addMedia.sharePreview = addMedia.pollPreview = addMedia.postponePreview = false;
  1205. 4634.  -       }
  1206. 4635.  -
  1207. 4636.  -       cur.lastPostMsg = false;
  1208. 4637.  -       if ((cur.module == 'profile' || cur.module == 'feed' || cur.module == 'wall') && cur.postTo) {
  1209. 4638.  -         setTimeout(function() {
  1210. 4639.  -           Wall.postChanged(val('post_field'), true);
  1211. 4640.  -         }, 0);
  1212. 4641.  -       }
  1213. 4642.  -
  1214. 4643.  -       if (addMedia.onChange) addMedia.onChange(false);
  1215. 4644.  -     },
  1216. 4645.  -     showMediaProgress: function(type, i, info) {
  1217. 4646.  -       if (addMedia.onProgress && addMedia.onProgress(type, i, info) === false) {
  1218. 4647.  -         return false;
  1219. 4648.  -       }
  1220. 4649.  -       var frac = info.loaded / info.total, percent = intval(frac * 100),
  1221. 4650.  -           fileName = info.fileName || info.name || '',
  1222. 4651.  -           // ind = i,
  1223. 4652.  -           ind = fileName ? i + '_' + fileName : i,
  1224. 4653.  -           label = fileName ? (fileName.length > 33 ? fileName.substr(0, 30) + '...' : fileName) : '';
  1225. 4654.  -
  1226. 4655.  -       var prg = ge('upload' + ind + '_progress');
  1227. 4656.  -       if (!prg) {
  1228. 4657.  -         if (!cur.attachMediaIndexes) cur.attachMediaIndexes = {};
  1229. 4658.  -         cur.attachMediaIndexes[ind] = lnkId;
  1230. 4659.  -
  1231. 4660.  -         var progress = '\
  1232. 4661.  - <div class="fl_l"><div class="page_attach_progress_wrap" style="margin-top: 3px; margin-bottom: 4px;">\
  1233. 4662.  -   <div id="upload' + ind + '_progress" class="page_attach_progress"></div>\
  1234. 4663.  - </div></div></div>' + (label ? '<div class="attach_label fl_l">' + label + '</div>' : '') + '<div class="progress_x fl_l" onmouseover="animate(this, {opacity: 1}, 200); showTooltip(this, {text: \'' + getLang('dont_attach') + '\', shift: [6, 3, 3]})" onmouseout="animate(this, {opacity: 0.6}, 200);" onclick="Upload.terminateUpload(' + i + ', \'' + (fileName || i) + '\');"></div>';
  1235. 4664.  -
  1236. 4665.  -         if (multi) {
  1237. 4666.  -           progressEl.appendChild(ce('div', {id: 'upload' + ind + '_progress_wrap', innerHTML: progress, className: 'clear_fix upload_' + i + '_progress'}, {marginTop: '6px'}));
  1238. 4667.  -           show(progressEl);
  1239. 4668.  -           if (opts.toggleLnk) toggle(lnk, addMedia.attachCount() < limit);
  1240. 4669.  -         } else {
  1241. 4670.  -           val(previewEl, progress);
  1242. 4671.  -           addMedia.chosenMedia = 'progress';
  1243. 4672.  -         }
  1244. 4673.  -         prg = ge('upload' + ind + '_progress');
  1245. 4674.  -         prg.full = false;//intval(getStyle(prg.parentNode, 'width'));
  1246. 4675.  -
  1247. 4676.  -         if (percent) {
  1248. 4677.  -           setStyle(prg, {width: prg.full ? (intval(prg.full * frac) + 'px') : percent + '%'})
  1249. 4678.  -         } else {
  1250. 4679.  -           setStyle(prg, {width: '1px'});
  1251. 4680.  -           hide(prg);
  1252. 4681.  -         }
  1253. 4682.  -       } else {
  1254. 4683.  -         show(prg);
  1255. 4684.  -         if (prg.full) {
  1256. 4685.  -           var tw = data(prg, 'tween'), w = intval(prg.full * frac);
  1257. 4686.  -           if (tw && tw.isTweening) {
  1258. 4687.  -             tw.to.width = w;
  1259. 4689.  -             animate(prg, {width: w + 'px'}, 500);
  1260. 4690.  -           }
  1261. 4691.  -         } else {
  1262. 4692.  -           setStyle(prg, {width: percent + '%'});
  1263. 4693.  -         }
  1264. 4694.  -       }
  1265. 4695.  -       // show(previewEl);
  1266. 4696.  -     },
  1267. 4697.  -
  1268. 4698.  -     attachCount: function() {
  1269. 4699.  -       if (addMedia.attachedCount) {
  1270. 4700.  -         return addMedia.attachedCount();
  1271. 4701.  -       }
  1272. 4702.  -       if (!previewEl) {
  1273. 4703.  -         return 0;
  1274. 4704.  -       }
  1275. 4705.  -       if (!multi) {
  1276. 4706.  -         return previewEl.childNodes.length;
  1277. 4707.  -       }
  1278. 4708.  -       var num = picsEl.childNodes.length + docsEl.childNodes.length + progressEl.childNodes.length;
  1279. 4709.  -       if (addMedia.sharePreview) {
  1280. 4710.  -         num--;
  1281. 4711.  -       }
  1282. 4712.  -       if (addMedia.pollPreview) {
  1283. 4713.  -         num--;
  1284. 4714.  -       }
  1285. 4715.  -       if (addMedia.postponePreview) {
  1286. 4716.  -         num -= 2;
  1287. 4717.  -       }
  1288. 4718.  -       return num;
  1289. 4719.  -     },
  1290. 4720.  -
  1291. 4721.  -     // Inline Polls
  1292. 4722.  -     createPoll: function(data) {
  1293. 4723.  -       var h = (browser.msie6 || data.question) ? '' : '1px', html = [], ans;
  1294. 4724.  -       var incCl = data[4 + (10 - 1) * 2] ? 'disabled' : '', decCl = data[4 + 2 * 2] ? '' : 'disabled';
  1295. 4725.  -       addMedia.pollPreview = docsEl.appendChild(ce('div', {className: 'medadd_c medadd_c_poll', innerHTML: '\
  1296. 4726.  - <input onkeydown="cur.addMedia[' + lnkId + '].keyPoll(this, event)" class="text medadd_c_pollq" id="create_poll_question' + lnkId + '" value="' + (data.question || '') + '" />\
  1297. 4727.  - <div class="medadd_c_pollh">' + data.lang.a + '</div>\
  1298. 4728.  - <div class="medadd_c_pollans" id="create_poll_answers' + lnkId + '"></div>\
  1299. 4729.  - <div class="medadd_c_polladd_wr" id="create_poll_add' + lnkId + '">\
  1300. 4730.  -   <div class="medadd_c_polladd" onclick="cur.addMedia[' + lnkId + '].incPoll()">' + data.lang.i + '</div>\
  1301. 4731.  - </div>' + (data.edit ? '' : '<div class="checkbox medadd_c_pollcb" id="create_poll_anonymous' + lnkId + '" onclick="checkbox(this)"><div></div>' + data.lang.c + '</div>')}));
  1302. 4732.  -       if (!data.answers) data.answers = [[0, ''], [0, '']];
  1303. 4733.  -       cur.pollAnswerTemplate = '<input onkeydown="cur.addMedia[%lnkid%].keyPoll(this, event)" class="text medadd_c_polla" %attrs%/><div class="page_media_x_wrap medadd_c_pollrem inl_bl" '+ (browser.msie ? 'title' : 'tootltip') + '="'+data.lang.d+'" onmouseover="if (browser.msie) return; showTooltip(this, {text: this.getAttribute(\'tootltip\'), shift: [14, 3, 3], black: 1})" onclick="cur.addMedia[%lnkid%].decPoll(this)"><div class="page_media_x"></div></div>';
  1304. 4734.  -       for (var i = 0, l = data.answers.length; i < l; ++i) {
  1305. 4735.  -         ans = data.answers[i];
  1306. 4736.  -         html.push('<div class="medadd_c_polla_wr">' + rs(cur.pollAnswerTemplate, {
  1307. 4737.  -           attrs: (ans[0] ? 'id="create_poll_ans' + ans[0] + '" value="' + ans[1] + '" ' : ''),
  1308. 4738.  -           lnkid: lnkId
  1309. 4739.  -         }) + '</div>');
  1310. 4740.  -         if (i == 9) hide('create_poll_add' + lnkId);
  1311. 4741.  -       }
  1312. 4742.  -       val('create_poll_answers' + lnkId, html.join(''));
  1313. 4743.  -       if (browser.msie6 || data.question) {
  1314. 4744.  -         elfocus('create_poll_question' + lnkId);
  1315. 4745.  -         return;
  1316. 4746.  -       }
  1317. 4747.  -       addMedia.pollPreview.style.height = h;
  1318. 4748.  -       animate(addMedia.pollPreview, {height: 166}, 200, function() {
  1319. 4749.  -         addMedia.pollPreview.style.height = 'auto';
  1320. 4750.  -         elfocus('create_poll_question' + lnkId);
  1321. 4751.  -       });
  1322. 4752.  -     },
  1323. 4753.  -     incPoll: function() {
  1324. 4754.  -       var answers = ge('create_poll_answers' + lnkId), l = answers.childNodes.length;
  1325. 4755.  -       if (l < 10) {
  1326. 4756.  -         elfocus(geByTag1('input', answers.appendChild(ce('div', {
  1327. 4757.  -           className: 'medadd_c_polla_wr',
  1328. 4758.  -           innerHTML: rs(cur.pollAnswerTemplate, {attrs: '', lnkid: lnkId})
  1329. 4759.  -         }))));
  1330. 4760.  -       }
  1331. 4761.  -       toggle('create_poll_add' + lnkId, l < 9);
  1332. 4762.  -     },
  1333. 4763.  -     decPoll: function(el) {
  1334. 4764.  -       if (el.tt && el.tt.destroy) el.tt.destroy();
  1335. 4765.  -       re(domPN(el));
  1336. 4766.  -       show('create_poll_add' + lnkId);
  1337. 4767.  -     },
  1338. 4768.  -     keyPoll: function(el, ev) {
  1339. 4769.  -       ev = ev || window.event;
  1340. 4770.  -       if (ev && (ev.keyCode == 10 || ev.keyCode == 13 || ev.keyCode == 9)) {
  1341. 4771.  -         var n = hasClass(el, 'medadd_c_pollq') ? domFC(domNS(domNS(el))) : domNS(domPN(el));
  1342. 4772.  -         if (n) {
  1343. 4773.  -           elfocus(geByTag1('input', n));
  1344. 4774.  -         } else {
  1345. 4775.  -           this.incPoll();
  1346. 4776.  -         }
  1347. 4777.  -         return cancelEvent(ev);
  1348. 4778.  -       }
  1349. 4779.  -     },
  1350. 4780.  -     pollData: function() {
  1351. 4781.  -       var answers = ge('create_poll_answers' + lnkId), q = trim(val('create_poll_question' + lnkId)), a;
  1352. 4782.  -       var result = {media: q, anonymous: isChecked('create_poll_anonymous' + lnkId)}, ind = 0, found = false;
  1353. 4783.  -       for (var el = domFC(answers); el; el = domNS(el)) {
  1354. 4784.  -         a = trim(val(domFC(el)));
  1355. 4785.  -         if (a) {
  1356. 4786.  -           var id = -intval((domFC(el).id.match(/^create_poll_ans(\d+)$/) || [0, -(ind++)])[1]); // -id or ind
  1357. 4787.  -           result['answers[' + id + ']'] = a;
  1358. 4788.  -           found = true;
  1359. 4789.  -         }
  1360. 4790.  -       }
  1361. 4791.  -       if (!q) {
  1362. 4792.  -         notaBene('create_poll_question' + lnkId);
  1363. 4793.  -         return false;
  1364. 4794.  -       }
  1365. 4795.  -       if (!found) {
  1366. 4796.  -         if (!domFC(answers)) cur.addMedia[lnkId].incPoll();
  1367. 4797.  -         notaBene(domFC(domFC(answers)));
  1368. 4798.  -         return false;
  1369. 4799.  -       }
  1370. 4800.  -       return result;
  1371. 4801.  -     },
  1372. 4802.  -
  1373. 4803.  -     // Inline Share
  1374. 4804.  -     urlsCancelled: [],
  1375. 4805.  -     shareData: {},
  1376. 4806.  -     checkMessageURLs: function(message, inactive) {
  1377. 4807.  -       if (addMedia.chosenMedia || addMedia.urlAttachmentLoading && addMedia.urlAttachmentLoading[0] > vkNow() - 10000) {
  1378. 4808.  -         return;
  1379. 4809.  -       }
  1380. 4810.  -       var rx = inactive ? urlInactiveExp : urlActiveExp,
  1381. 4811.  -           matches;
  1382. 4812.  -       while (message && (matches = message.match(rx))) {
  1383. 4813.  -         message = message.substr(matches.index + matches[0].length);
  1384. 4814.  -         var url = matches[2],
  1385. 4815.  -             query = matches[5] || '',
  1386. 4816.  -             initialUrl = url;
  1387. 4817.  -         if (!url.match(/^https?:\/\//)) {
  1388. 4818.  -           url = 'http://' + url;
  1389. 4819.  -         }
  1390. 4820.  -         if (inArray(url, addMedia.urlsCancelled)) {
  1391. 4821.  -           continue;
  1392. 4822.  -         }
  1393. 4823.  -         var valid = true;
  1394. 4824.  -         if (matches[4].match(/(^|\.|\/\/)vkontakte\.ru|vk\.com/)) {
  1395. 4825.  -           valid = query.match(/(#photo|^\/(photo|video|album|page|audio)|z=(album|photo|video)|w=(page))(-?\d+_)?\d+|\.(jpg|png|gif)$/) ? true : false;
  1396. 4826.  -         }
  1397. 4827.  -         if (valid) {
  1398. 4828.  -          addMedia.checkURL(initialUrl);
  1399. 4829.  -          return;
  1400. 4830.  -         }
  1401. 4831.  -       }
  1402. 4832.  -     },
  1403. 4833.  -     onCheckURLDone: function(result, data) {
  1404. 4834.  -       var url = '';
  1405. 4835.  -       if (addMedia.urlAttachmentLoading) {
  1406. 4836.  -         re(addMedia.urlAttachmentLoading[2]);
  1407. 4837.  -         toggle(progressEl, progressEl.childNodes > 0);
  1408. 4838.  -         url = addMedia.urlAttachmentLoading[1];
  1409. 4839.  -         addMedia.urlAttachmentLoading = false;
  1410. 4840.  -         setStyle(bodyNode, {cursor: 'default'});
  1411. 4841.  -       }
  1412. 4842.  -       if (result) {
  1413. 4843.  -         addMedia.chooseMedia(data[0], data[1], data[2], url, true);
  1414. 4844.  -       }
  1415. 4845.  -     },
  1416. 4846.  -     checkURL: function(url) {
  1417. 4847.  -       if (!url) return;
  1418. 4848.  -       addMedia.urlsCancelled.push(url);
  1419. 4849.  -       addMedia.urlAttachmentLoading = [vkNow(), url];
  1420. 4850.  -
  1421. 4851.  -       re(addMedia.checkURLForm);
  1422. 4852.  -       addMedia.checkURLForm = ce('div', {innerHTML: '<iframe name="share_parse_iframe' + lnkId + '"></iframe>'});
  1423. 4853.  -       utilsNode.appendChild(addMedia.checkURLForm);
  1424. 4854.  -       var parseForm = addMedia.checkURLForm.appendChild(ce('form', {
  1425. 4855.  -         action: 'share.php?act=url_attachment',
  1426. 4856.  -         method: 'post',
  1427. 4857.  -         target: 'share_parse_iframe' + lnkId
  1428. 4858.  -       }));
  1429. 4859.  -
  1430. 4860.  -       each({hash: cur.options.share.timehash || '', index: lnkId, url: url}, function(i, v) {
  1431. 4861.  -         parseForm.appendChild(ce('input', {type: 'hidden', name: i, value: v}));
  1432. 4862.  -       });
  1433. 4863.  -
  1434. 4864.  -       // var progress = ce('div', {className: 'share_parse_progress progress'});
  1435. 4865.  -       // progressEl.appendChild(progress);
  1436. 4866.  -       // show(progressEl);
  1437. 4867.  -       // addMedia.urlAttachmentLoading.push(progress);
  1438. 4868.  -       setStyle(bodyNode, {cursor: 'wait'});
  1439. 4869.  -
  1440. 4870.  -       window.onUploadDone = addMedia.onCheckURLDone.pbind(true);
  1441. 4871.  -       window.onUploadFail = addMedia.onCheckURLDone.pbind(false);
  1442. 4872.  -
  1443. 4873.  -       parseForm.submit();
  1444. 4874.  -     },
  1445. 4875.  -     addPreview: function(progress) {
  1446. 4876.  -       return (addMedia.sharePreview = docsEl.appendChild(ce('div', {className: 'medadd_c medadd_c_link', innerHTML: '\
  1447. 4877.  - <div class="medadd_c_linkcon"><div></div>' + (progress ? '<div class="progress medadd_c_linkprg"></div>' : '') + '</div>'})));
  1448. 4878.  -     },
  1449. 4879.  -     showPreview: function(fast) {
  1450. 4880.  -       var data = addMedia.shareData,
  1451. 4881.  -           prev = addMedia.sharePreview || addMedia.addPreview();
  1452. 4882.  -
  1453. 4883.  -       if (data.failed) {
  1454. 4884.  -         var html = getLang('page_not_loaded');
  1455. 4885.  -       } else {
  1456. 4886.  -         var html = (data.images && data.images[cur.shareShowImg]  ? '<img class="medadd_c_linkimg fl_l" src="' + data.images[cur.shareShowImg] + '" ' + (data.imagesStyles && data.imagesStyles[cur.shareShowImg] || '') + ' />' : '') + (data.title ? '<h4 class="medadd_c_linkhead">' + data.title + '</h4>' : '') + (data.description ? '<div class="medadd_c_linkdsc">' + data.description + '</div>' : '') + '<div class="clear"></div>';
  1457. 4887.  -       }
  1458. 4888.  -
  1459. 4889.  -       if (fast) {
  1460. 4890.  -         val(domFC(prev), html);
  1461. 4891.  -         domFC(prev).style.height = 'auto';
  1462. 4892.  -       } else {
  1463. 4893.  -         var hidden = !isVisible(docsEl);
  1464. 4894.  -         show(docsEl);
  1465. 4895.  -         var tmpDiv = ge(previewId).appendChild(ce('div', {
  1466. 4896.  -             innerHTML: '<div class="medadd_c_linkcon">' + html + '</div>'
  1467. 4897.  -         }, {
  1468. 4898.  -           position: 'absolute',
  1469. 4899.  -           width: getSize(prev)[0] - 10,
  1470. 4900.  -           visibility: 'hidden'
  1471. 4901.  -         }));
  1472. 4902.  -         var height = getSize(tmpDiv)[1];
  1473. 4903.  -         re(tmpDiv);
  1474. 4904.  -
  1475. 4905.  -         animate(domFC(prev), {height: height}, 200, function () {
  1476. 4906.  -           val(domFC(prev), html);
  1477. 4907.  -         });
  1478. 4908.  -       }
  1479. 4909.  -     },
  1480. 4910.  -     showExternalPreview: function () {
  1481. 4911.  -       var data = addMedia.shareData;
  1482. 4912.  -       if (!data.images || !data.images.length) {
  1483. 4913.  -         cur.shareShowImg = 0;
  1484. 4914.  -         addMedia.showPreview();
  1485. 4915.  -         return;
  1486. 4916.  -       } else {
  1487. 4917.  -         cur.shareShowImg = -1;
  1488. 4918.  -         addMedia.addPreview(true);
  1489. 4919.  -       }
  1490. 4920.  -       data.imagesStyles = {};
  1491. 4921.  -       var fast = false;
  1492. 4922.  -
  1493. 4923.  -       cur.shareShowNext = function () {
  1494. 4924.  -         var tmpImg = vkImage();
  1495. 4925.  -         cur.shareShowImg += 1;
  1496. 4926.  -
  1497. 4927.  -         if (cur.shareShowImg > data.images.length - 1) {
  1498. 4928.  -           cur.shareShowImg = 0;
  1499. 4929.  -         } else if (cur.shareShowImg == 0) {
  1500. 4930.  -           for (var i = 1; i < data.images.length - 1; i++) {
  1501. 4931.  -             var t = vkImage();
  1502. 4932.  -             t.src = data.images[i];
  1503. 4933.  -           }
  1504. 4934.  -         }
  1505. 4935.  -         if (!data.images.length || isEmpty(data.images) || data.images[cur.shareShowImg] === undefined) {
  1506. 4936.  -           addMedia.showPreview(fast);
  1507. 4937.  -           fast = true;
  1508. 4938.  -           return;
  1509. 4939.  -         }
  1510. 4940.  -         tmpImg.src = data.images[cur.shareShowImg];
  1511. 4941.  -
  1512. 4942.  -         var imgLoadTimeout = setTimeout(function() {
  1513. 4943.  -           if (cur.shareImgInterval === true) return;
  1514. 4944.  -           data.images.splice(cur.shareShowImg, 1);
  1515. 4945.  -           cur.shareShowNext();
  1516. 4946.  -         }, 5000);
  1517. 4947.  -
  1518. 4948.  -         var updatePreview = function() {
  1519. 4949.  -           if (tmpImg.width || tmpImg.height) {
  1520. 4950.  -             var w = tmpImg.width, h = tmpImg.height;
  1521. 4951.  -             var imgStyle = '';
  1522. 4952.  -             var imgParams = '';
  1523. 4953.  -             if (imgLoadTimeout) {
  1524. 4954.  -               clearTimeout(imgLoadTimeout);
  1525. 4955.  -             }
  1526. 4956.  -             clearInterval(cur.shareImgInterval);
  1527. 4957.  -             if (w < 20 || h < 20) {
  1528. 4958.  -               data.images.splice(cur.shareShowImg, 1);
  1529. 4959.  -               if (data.images.length) {
  1530. 4960.  -                 return setTimeout(cur.shareShowNext, 0);
  1531. 4961.  -               }
  1532. 4962.  -             } else {
  1533. 4963.  -               if (w > h && w > 150) {
  1534. 4964.  -                 h = 150 * h / w;
  1535. 4965.  -                 w = 150;
  1536. 4966.  -               } else if (h > 150) {
  1537. 4967.  -                 w = 150 * w / h;
  1538. 4968.  -                 h = 150;
  1539. 4969.  -               }
  1540. 4970.  -               imgStyle = 'width: ' + w + 'px; height: ' + h + 'px;';
  1541. 4971.  -             }
  1542. 4972.  -             if (data.images.length > 1) {
  1543. 4973.  -               imgStyle += 'cursor: pointer';
  1544. 4974.  -               imgParams = ' onclick="cur.shareShowNext();"';
  1545. 4975.  -             }
  1546. 4976.  -             data.imagesStyles[cur.shareShowImg] = 'style="' + imgStyle + '"' + imgParams;
  1547. 4977.  -             addMedia.showPreview(fast);
  1548. 4978.  -             fast = true;
  1549. 4979.  -           }
  1550. 4980.  -         }
  1551. 4981.  -         clearInterval(cur.shareImgInterval);
  1552. 4982.  -         cur.shareImgInterval = setInterval(updatePreview, 300);
  1553. 4983.  -         setTimeout(updatePreview, 0);
  1554. 4984.  -       }
  1555. 4985.  -       cur.shareShowNext();
  1556. 4986.  -     },
  1557. 4987.  -     uploadShare: function(callback) {
  1558. 4988.  -       var data = addMedia.shareData, prev = addMedia.sharePreview;
  1559. 4989.  -       var uploadCont = prev.appendChild(ce('div', {innerHTML: '<iframe class="upload_frame" name="share_upload_iframe' + lnkId + '"></iframe>'})),
  1560. 4990.  -           uploadForm = uploadCont.appendChild(ce('form', {action: '/share.php', method: 'post', target: 'share_upload_iframe' + lnkId})),
  1561. 4991.  -           photoUrl = data.images[cur.shareShowImg];
  1562. 4992.  -       each({
  1563. 4993.  -         act: 'a_photo',
  1564. 4994.  -         url: data.url,
  1565. 4995.  -         index: lnkId,
  1566. 4996.  -         image: photoUrl,
  1567. 4997.  -         extra: data.extra || 0
  1568. 4998.  -       }, function (i, v) {
  1569. 4999.  -         uploadForm.appendChild(ce('input', {type: 'hidden', name: i, value: v}));
  1570. 5000.  -       });
  1571. 5001.  -       window.onUploadDone = function(index, params) {
  1572. 5002.  -         window.onUploadFail = window.onUploadDone = function () {};
  1573. 5003.  -         prev.removeChild(uploadCont);
  1574. 5004.  -         addMedia.shareData = extend(addMedia.shareData, {
  1575. 5005.  -           user_id: params.user_id,
  1576. 5006.  -           photo_id: params.photo_id,
  1577. 5007.  -           photo_url: photoUrl,
  1578. 5008.  -           images: []
  1579. 5009.  -         });
  1580. 5010.  -         callback();
  1581. 5011.  -       }
  1582. 5012.  -       window.onUploadFail = function(index, msg) {
  1583. 5013.  -         window.onUploadFail = window.onUploadDone = function () {};
  1584. 5014.  -         prev.removeChild(uploadCont);
  1585. 5015.  -         addMedia.shareData.images = [];
  1586. 5016.  -         callback();
  1587. 5017.  -       }
  1588. 5018.  -       uploadForm.submit();
  1589. 5019.  -     },
  1590. 5020.  -
  1591. 5021.  -     setupPostpone: function(data, export_row) {
  1592. 5022.  -       var ed = (cur.editingPost && domPN(docsEl).id == 'wpe_media_preview'), h = (browser.msie6 || ed) ? '' : '1px';
  1593. 5023.  -       var html = '<div class="clear_fix">\
  1594. 5024.  - <div class="fl_l"><input type="hidden" id="postpone_date' + lnkId + '" value="' + (data.date || '') + '" /></div>\
  1595. 5025.  - <div class="fl_l medadd_c_timerat">' + data.lang.profile_wall_postpone_at + '</div>\
  1596. 5026.  - <div class="fl_l"><input type="hidden" id="postpone_time' + lnkId + '"/></div></div>';
  1597. 5027.  -       if (cur.editingPost && data.friends_only != undefined) {
  1598. 5028.  -         html += '<div class="medadd_c_timersett">';
  1599. 5029.  -         if (data.status_export != undefined) {
  1600. 5030.  -           html += '<div class="checkbox_status_export' + (data.status_export ? ' on' : '') + ' fl_l" id="status_export' + lnkId + '" onclick="checkbox(this)" onmouseover="showTooltip(this, {text: \'' + data.lang.export_to_twitter + '\', black: 1, shift: [12,4,0]});"><div></div></div>';
  1601. 5031.  -         }
  1602. 5032.  -         if (data.facebook_export != undefined) {
  1603. 5033.  -           html += '<div class="checkbox_facebook_export' + (data.facebook_export ? ' on' : '') + ' fl_l" id="facebook_export' + lnkId + '" onclick="checkbox(this)" onmouseover="showTooltip(this, {text: \'' + data.lang.export_to_facebook + '\', black: 1, shift: [12,4,0]});"><div></div></div>';
  1604. 5034.  -         }
  1605. 5035.  -         html += '<div class="checkbox' + (data.friends_only ? ' on' : '') + ' fl_l" id="friends_only' + lnkId + '" onclick="checkbox(this);checkbox(\'status_export' + lnkId + '\',!isChecked(this));checkbox(\'facebook_export' + lnkId + '\',!isChecked(this));"><div></div>'+ data.lang.friends_only +'</div></div>';
  1606. 5036.  -       } else if (cur.editingPost && export_row) {
  1607. 5037.  -         html += export_row;
  1608. 5038.  -       }
  1609. 5039.  -       addMedia.postponePreview = docsEl.appendChild(ce('div', {className: 'medadd_c medadd_c_timer clear_fix', innerHTML: html}));
  1610. 5040.  -       addMedia.postponePreview.style.height = h;
  1611. 5041.  -       stManager.add(['ui_controls.css', 'ui_controls.js', 'datepicker.css', 'datepicker.js'], function() {
  1612. 5042.  -         new Datepicker('postpone_date' + lnkId, {time: 'postpone_time' + lnkId, width: 120, noPast: true});
  1613. 5043.  -         if (!browser.msie6 && !ed) {
  1614. 5044.  -           animate(addMedia.postponePreview, {height: 33}, 200, function() {
  1615. 5045.  -             addMedia.postponePreview.style.height = '';
  1616. 5046.  -           });
  1617. 5047.  -         }
  1618. 5048.  -       });
  1619. 5049.  -     }
  1620. 5050.  -   }
  1621. 5051.  -
  1622. 5052.  -   if (!cur.addMedia) {
  1623. 5053.  -     cur.addMedia = {};
  1624. 5054.  -   }
  1625. 5055.  -
  1626. 5056.  -   cur.addMedia[lnkId] = addMedia;
  1627. 5057.  -   return addMedia;
  1628. 5058.  - };
  1629. 5059.  -
  1630. 5060.  - Composer = {
  1631. 5061.  -   init: function (el, options) {
  1632. 5062.  -     if (!(el = ge(el))) {
  1633. 5063.  -       return null;
  1634. 5064.  -     }
  1635. 5065.  -
  1636. 5066.  -     var composer = data(el, 'composer');
  1637. 5067.  -     if (composer) {
  1638. 5068.  -       return composer;
  1639. 5069.  -     }
  1640. 5070.  -     composer = {
  1641. 5071.  -       input: el,
  1642. 5072.  -       inited: false,
  1643. 5073.  -       options: options
  1644. 5074.  -     };
  1645. 5075.  -
  1646. 5076.  -     data(el, 'composer', composer);
  1647. 5077.  -
  1648. 5078.  -     el.parentNode.insertBefore(
  1649. 5079.  -       composer.wddWrap = ce('div', {
  1650. 5080.  -         className: 'composer_wdd clear_fix ' + (options.wddClass || ''),
  1651. 5081.  -         id: el.id + '_composer_wdd',
  1652. 5082.  -         innerHTML: '<input type="hidden" id="' + el.id + '_composer_wdd_term"/>'
  1653. 5083.  -       }, {
  1654. 5084.  -         width: options.width || getSize(el)[0]
  1655. 5085.  -       }),
  1656. 5086.  -       el.nextSibling
  1657. 5087.  -     );
  1658. 5088.  -
  1659. 5089.  -     composer.wddInput = composer.wddWrap.firstChild;
  1660. 5090.  -     composer.wdd = WideDropdown.initSelect(composer.wddWrap, extend({
  1661. 5091.  -       text: composer.wddInput,
  1662. 5092.  -       url: 'hints.php',
  1663. 5093.  -       params: {act: 'a_json_friends', from: 'composer'},
  1664. 5094.  -       noResult: options.lang.noResult || '',
  1665. 5095.  -       introText: options.lang.introText || '',
  1666. 5096.  -       onItemSelect: Composer.onItemSelect.bind(Composer).pbind(composer)
  1667. 5097.  -     }, options.wddOpts || {}));
  1668. 5098.  -
  1669. 5099.  -     el.dd = composer.wddWrap.id;
  1670. 5100.  -
  1671. 5101.  -     Composer.initEvents(composer);
  1672. 5102.  -
  1673. 5103.  -     if (options.media) {
  1674. 5104.  -       composer.addMedia = initAddMedia(options.media.lnk, options.media.preview, options.media.types, options.media.options);
  1675. 5105.  -     }
  1676. 5106.  -
  1677. 5107.  -     setStyle(composer.wddWrap, 'width', '');
  1678. 5108.  -
  1679. 5109.  -     composer.inited = true;
  1680. 5110.  -
  1681. 5111.  -     return composer;
  1682. 5112.  -   },
  1683. 5113.  -   initEvents: function (composer) {
  1684. 5114.  -     addEvent(composer.input, 'keyup keydown keypress', Composer.onKeyEvent.pbind(composer));
  1685. 5115.  -     addEvent(composer.input, 'click mousedown mouseup focus blur paste', Composer.onMouseEvent.pbind(composer));
  1686. 5116.  -   },
  1687. 5117.  -   destroy: function (composer) {
  1688. 5118.  -     WideDropdown.deinit(composer.wddWrap);
  1689. 5119.  -     cleanElems(composer.input, composer.wddWrap);
  1690. 5120.  -     re(composer.wddWrap);
  1691. 5121.  -     composer.inited = false;
  1692. 5122.  -     data(composer.input, 'composer', null);
  1693. 5123.  -   },
  1694. 5124.  -
  1695. 5125.  -   onKeyEvent: function (composer, event) {
  1696. 5126.  -     var controlEvent = composer.wdd && inArray(event.keyCode, [KEY.UP, KEY.DOWN, KEY.RETURN]);
  1697. 5127.  -     if (event.type == 'keypress' || event.type == 'keydown') {
  1698. 5128.  -       if (event.keyCode == KEY.RETURN || event.keyCode == 10) {
  1699. 5129.  -         if (!composer.select || !composer.select.isVisible()) {
  1700. 5130.  -           if (event.ctrlKey && isFunction(composer.options.onSubmit)) {
  1701. 5131.  -             // composer.input.blur();
  1702. 5132.  -             // composer.options.onSubmit();
  1703. 5133.  -             return true;
  1704. 5134.  -           }
  1705. 5135.  -         } else {
  1706. 5136.  -           triggerEvent(document, event.type, event);
  1707. 5137.  -           return cancelEvent(event);
  1708. 5138.  -         }
  1709. 5139.  -       }
  1710. 5140.  -       if (event.keyCode == KEY.TAB) {
  1711. 5141.  -         var input = composer.input,
  1712. 5142.  -             value = val(input),
  1713. 5143.  -             curPos = Composer.getCursorPosition(input);
  1714. 5144.  -             curValue = value.substr(0, curPos) + "\001" + value.substr(curPos),
  1715. 5145.  -             matches = curValue.match(/^[\s\S]*(@|\*)[\S]+\s*\([\s\S]*?\001[\s\S]*?\)\s*/);
  1716. 5146.  -
  1717. 5147.  -         if (matches) {
  1718. 5148.  -           var pos = matches[0].length - 1;
  1719. 5149.  -           elfocus(composer.input, pos, pos);
  1720. 5150.  -           return cancelEvent(event);
  1721. 5151.  -         }
  1722. 5152.  -       }
  1723. 5153.  -       if (controlEvent && isVisible(composer.wdd.listWrap)) {
  1724. 5154.  -         if (event.type == (browser.opera ? 'keypress' : 'keydown')) {
  1725. 5155.  -           WideDropdown._textEvent(event);
  1726. 5156.  -         }
  1727. 5157.  -         return cancelEvent(event);
  1728. 5158.  -       }
  1729. 5159.  -     }
  1730. 5160.  -
  1731. 5161.  -     if (event.type == 'keyup' && !controlEvent) {
  1732. 5162.  -       if (event.keyCode == 65 && event.ctrlKey) { // fix Ctrl+A
  1733. 5163.  -         return;
  1734. 5164.  -       }
  1735. 5165.  -       if (composer.wdd && inArray(event.keyCode, [KEY.SPACE, KEY.HOME, 190, 191, 78, 55, 49])) {
  1736. 5166.  -         Composer.hideSelectList(composer);
  1737. 5167.  -       }
  1738. 5168.  -       Composer.updateAutoComplete(composer, event);
  1739. 5169.  -     }
  1740. 5170.  -   },
  1741. 5171.  -   onMouseEvent: function (composer, event) {
  1742. 5172.  -     if (event.type == 'blur') {
  1743. 5173.  -       Composer.hideSelectList(composer);
  1744. 5174.  -       return;
  1745. 5175.  -     }
  1746. 5176.  -     if (event.type == 'focus' || event.type == 'click') {
  1747. 5177.  -       Composer.updateAutoComplete(composer, event);
  1748. 5178.  -     }
  1749. 5179.  -     if (event.type == 'paste') {
  1750. 5180.  -       setTimeout(Composer.updateAutoComplete.pbind(composer, event), 0);
  1751. 5181.  -     }
  1752. 5182.  -   },
  1753. 5183.  -   updateAutoComplete: function (composer, event) {
  1754. 5184.  -     var input = composer.input,
  1755. 5185.  -         value = val(input),
  1756. 5186.  -         curPos = Composer.getCursorPosition(input),
  1757. 5187.  -         prefValue = value.substr(0, curPos),
  1758. 5188.  -         pos = Math.max(prefValue.lastIndexOf('@'), prefValue.lastIndexOf('*')),
  1759. 5189.  -         term = pos > -1 ? prefValue.substr(pos + 1) : false;
  1760. 5190.  -
  1761. 5191.  -     if (term && term.match(/&nbsp;|[,\.\(\)\?\!\s\n \u00A0]|\#/)) {
  1762. 5192.  -       term = false;
  1763. 5193.  -     }
  1764. 5194.  -     composer.curValue = value;
  1765. 5195.  -     composer.curTerm = term;
  1766. 5196.  -     composer.curPos = pos;
  1767. 5197.  -     val(composer.wddInput, term);
  1768. 5198.  -     Composer.toggleSelectList(composer);
  1769. 5199.  -
  1770. 5200.  -     if (event.type == 'keyup' || event.type == 'paste') {
  1771. 5201.  -       if (composer.options.onValueChange) {
  1772. 5202.  -         composer.options.onValueChange(prefValue, event.type != 'keyup');
  1773. 5203.  -       }
  1774. 5204.  -       if (composer.addMedia) {
  1775. 5205.  -         composer.addMedia.checkMessageURLs(prefValue, event.type != 'keyup');
  1776. 5206.  -       }
  1777. 5207.  -       if (composer.options.checkLen) {
  1778. 5208.  -         composer.options.checkLen(value);
  1779. 5209.  -       }
  1780. 5210.  -     }
  1781. 5211.  -   },
  1782. 5212.  -   toggleSelectList: function (composer) {
  1783. 5213.  -     var term = composer.curTerm;
  1784. 5214.  -     if (term === false) {
  1785. 5215.  -       Composer.hideSelectList(composer);
  1786. 5216.  -     } else {
  1787. 5217.  -       Composer.showSelectList(composer, term);
  1788. 5218.  -     }
  1789. 5219.  -   },
  1790. 5220.  -   hideSelectList: function (composer) {
  1791. 5221.  -     composer.wddInput.focused = false;
  1792. 5222.  -     WideDropdown._hideList(composer.wdd);
  1793. 5223.  -   },
  1794. 5224.  -   showSelectList: function (composer, term) {
  1795. 5225.  -     composer.wddInput.focused = true;
  1796. 5226.  -     WideDropdown._updateList(composer.wdd, false, term);
  1797. 5227.  -   },
  1798. 5228.  -   onItemSelect: function (composer, item) {
  1799. 5229.  -     if (!item) {
  1800. 5230.  -       return false;
  1801. 5231.  -     }
  1802. 5232.  -
  1803. 5233.  -     var mention = item[2].replace('@', ''),
  1804. 5234.  -         alias = replaceEntities(item[1]),
  1805. 5235.  -         prefValue = composer.curValue.substr(0, composer.curPos),
  1806. 5236.  -         suffValue = composer.curValue.substr(composer.curPos),
  1807. 5237.  -         aliasStartPos, aliasEndPos;
  1808. 5238.  -
  1809. 5239.  -     if (!mention) {
  1810. 5240.  -       if (itemId > 0) {
  1811. 5241.  -         mention = 'id' + itemId;
  1812. 5242.  -       } else {
  1813. 5243.  -         mention = 'club' + Math.abs(itemId);
  1814. 5244.  -       }
  1815. 5245.  -     }
  1816. 5246.  -
  1817. 5247.  -     var noAlias = prefValue.match(/\#[\w_\.\u0400-\u04FF]+$/i) ? true : false;
  1818. 5248.  -
  1819. 5249.  -     suffValue = suffValue.replace(/^(@|\*)[^\s]*(?:\s+\((?:(.*?)\))?\s*)?/, function (whole, asterisk, prevAlias) {
  1820. 5250.  -       var replacement = asterisk + mention + ' ';
  1821. 5251.  -
  1822. 5252.  -       if (noAlias) {
  1823. 5253.  -         aliasStartPos = aliasEndPos = replacement.length;
  1824. 5254.  -       } else {
  1825. 5255.  -         replacement += ' (';
  1826. 5256.  -         aliasStartPos = replacement.length;
  1827. 5257.  -         replacement += alias.replace(/[\(\)\]\[]/g, '');
  1828. 5258.  -         aliasEndPos = replacement.length;
  1829. 5259.  -         replacement += ')';
  1830. 5260.  -       }
  1831. 5261.  -
  1832. 5262.  -       return replacement;
  1833. 5263.  -     });
  1834. 5264.  -
  1835. 5265.  -     aliasStartPos += composer.curPos;
  1836. 5266.  -     aliasEndPos += composer.curPos;
  1837. 5267.  -
  1838. 5268.  -     Composer.hideSelectList(composer);
  1839. 5269.  -     val(composer.input, prefValue + suffValue);
  1840. 5270.  -     elfocus(composer.input, aliasStartPos, aliasEndPos);
  1841. 5271.  -     return false;
  1842. 5272.  -   },
  1843. 5273.  -   getCursorPosition: function (node) {
  1844. 5274.  -     if (node.selectionStart) {
  1845. 5275.  -       return node.selectionStart;
  1846. 5276.  -     } else if (!document.selection) {
  1847. 5277.  -       return 0;
  1848. 5278.  -     }
  1849. 5279.  -
  1850. 5280.  -     var c = "\001",
  1851. 5281.  -         sel = document.selection.createRange(),
  1852. 5282.  -         txt = sel.text,
  1853. 5283.  -         dup = sel.duplicate(),
  1854. 5284.  -         len = 0;
  1855. 5285.  -
  1856. 5286.  -     try {
  1857. 5287.  -       dup.moveToElementText(node);
  1858. 5288.  -     } catch(e) {
  1859. 5289.  -       return 0;
  1860. 5290.  -     }
  1861. 5291.  -     sel.text  = txt + c;
  1862. 5292.  -     len = (dup.text.indexOf(c));
  1863. 5293.  -     sel.moveStart('character',-1);
  1864. 5294.  -     sel.text  = '';
  1865. 5295.  -     if (browser.msie && len == -1) {
  1866. 5296.  -       return node.value.length;
  1867. 5297.  -     }
  1868. 5298.  -     return len;
  1869. 5299.  -   },
  1870. 5300.  -   getSendParams: function(composer, delayedCallback) {
  1871. 5301.  -     var addMedia = composer.addMedia || {},
  1872. 5302.  -         media = addMedia.chosenMedia || {},
  1873. 5303.  -         medias = clone(addMedia.chosenMedias || []),
  1874. 5304.  -         share = (addMedia.shareData || {}),
  1875. 5305.  -         limit = composer && composer.options.media && composer.options.media.options.limit || 0,
  1876. 5306.  -         input = composer.input,
  1877. 5307.  -         message = trim(val(input)),
  1878. 5308.  -         params = {message: message},
  1879. 5309.  -         attachI = 0;
  1880. 5310.  -
  1881. 5311.  -     if (isArray(media) && media.length) {
  1882. 5312.  -       medias.push(clone(media));
  1883. 5313.  -     }
  1884. 5314.  -
  1885. 5315.  -     setStyle(bodyNode, {cursor: 'default'});
  1886. 5316.  -
  1887. 5317.  -     if (isArray(medias) && medias.length) {
  1888. 5318.  -       var delayed = false;
  1889. 5319.  -       each (medias, function (k, v) {
  1890. 5320.  -         if (!v) {
  1891. 5321.  -           return;
  1892. 5322.  -         }
  1893. 5323.  -         if (attachI >= limit) {
  1894. 5324.  -           return false;
  1895. 5325.  -         }
  1896. 5326.  -         var type = this[0],
  1897. 5327.  -             attachVal = this[1];
  1898. 5328.  -
  1899. 5329.  -         switch (type) {
  1900. 5330.  -           case 'poll':
  1901. 5331.  -             var poll = addMedia.pollData();
  1902. 5332.  -             if (!poll) {
  1903. 5333.  -               params.delayed = true;
  1904. 5334.  -               return false;
  1905. 5335.  -             }
  1906. 5336.  -             if (intval(attachVal)) {
  1907. 5337.  -               params.poll_id = intval(attachVal);
  1908. 5338.  -             }
  1909. 5339.  -             attachVal = poll.media;
  1910. 5340.  -             delete poll.media;
  1911. 5341.  -             params = extend(params, poll);
  1912. 5342.  -             break;
  1913. 5343.  -
  1914. 5344.  -           case 'share':
  1915. 5345.  -             if (share.failed || !share.url ||
  1916. 5346.  -                 !share.title && (!share.images || !share.images.length) && !share.photo_url) {
  1917. 5347.  -               if (cur.shareLastParseSubmitted && vkNow() - cur.shareLastParseSubmitted < 2000) {
  1918. 5348.  -                 params.delayed = true;
  1919. 5349.  -                 return false;
  1920. 5350.  -               } else {
  1921. 5351.  -                 return;
  1922. 5352.  -               }
  1923. 5353.  -             }
  1924. 5354.  -             attachVal = share.user_id + '_' + share.photo_id;
  1925. 5355.  -             if (share.images && share.images.length) {
  1926. 5356.  -               addMedia.uploadShare(delayedCallback);
  1927. 5357.  -               params.delayed = true;
  1928. 5358.  -               return false;
  1929. 5359.  -             }
  1930. 5360.  -             if (share.initialPattern && (trim(message) == share.initialPattern)) {
  1931. 5361.  -               params.message = '';
  1932. 5362.  -             }
  1933. 5363.  -             extend(params, {
  1934. 5364.  -               url: share.url,
  1935. 5365.  -               title: replaceEntities(share.title),
  1936. 5366.  -               description: replaceEntities(share.description),
  1937. 5367.  -               extra: share.extra,
  1938. 5368.  -               extra_data: share.extraData,
  1939. 5369.  -               photo_url: replaceEntities(share.photo_url),
  1940. 5370.  -               open_graph_data: (share.openGraph || {}).data,
  1941. 5371.  -               open_graph_hash: (share.openGraph || {}).hash
  1942. 5372.  -             });
  1943. 5373.  -             break;
  1944. 5374.  -           case 'page':
  1945. 5375.  -             if (share.initialPattern && (trim(message) == share.initialPattern)) {
  1946. 5376.  -               params.message = '';
  1947. 5377.  -             }
  1948. 5378.  -             break;
  1949. 5379.  -           case 'postpone':
  1950. 5380.  -             params.postpone = cur.postponedLastDate = val('postpone_date' + addMedia.lnkId);
  1951. 5381.  -             return;
  1952. 5382.  -         }
  1953. 5383.  -         if (this[3] && trim(message) == this[3]) {
  1954. 5384.  -           params.message = '';
  1955. 5385.  -         }
  1956. 5386.  -         params['attach' + (attachI + 1) + '_type'] = type;
  1957. 5387.  -         params['attach' + (attachI + 1)] = attachVal;
  1958. 5388.  -         attachI++;
  1959. 5389.  -       });
  1960. 5390.  -     }
  1961. 5391.  -
  1962. 5392.  -     return params;
  1963. 5393.  -   },
  1964. 5394.  -   reset: function (composer) {
  1965. 5395.  -     var input = composer.input,
  1966. 5396.  -         value = val(input),
  1967. 5397.  -         media = composer.addMedia,
  1968. 5398.  -         state = {value: value};
  1969. 5399.  -
  1970. 5400.  -     val(input, '');
  1971. 5401.  -     if (media) {
  1972. 5402.  -       state.urlsCancelled = clone(media.urlsCancelled);
  1973. 5403.  -       media.unchooseMedia();
  1974. 5404.  -       media.urlsCancelled = [];
  1975. 5405.  -     }
  1976. 5406.  -
  1977. 5407.  -     return state;
  1978. 5408.  -   },
  1979. 5409.  -   restore: function (composer, prevState) {
  1980. 5410.  -     var input = composer.input,
  1981. 5411.  -         state = Composer.reset(composer);
  1982. 5412.  -     val(input, prevState.value || '');
  1983. 5413.  -
  1984. 5414.  -     return state;
  1985. 5415.  -   }
  1986. 5416.  - }
  1987. 5417.  -
  1988. 5418.  - if (!_postsSendTimer) _postsSendTimer = setTimeout(Page.postsSend, 10000);
  1989. 5419.  -
  1990. 5420.  - try{stManager.done('page.js');}catch(e){}
  1991. 5421.  -
  1992. 5422.  +             updH = el.offsetHeight - start
  1993. ------
  1994. Файл - feed.js:
  1995. 768.  -     var feedBar = ge('feed_bar'),
  1996. 769.  -         curSection = cur.section,
  1997. 770.  -         curTopTab = 'news',
  1998. 771.  +     var curTopTab = 'news',
  1999. 773.  -         curTab, newTab;
  2000. 774.  -
  2001. 775.  -     if (from >= 2 && newSection == cur.section) {
  2002. 776.  -       curSection = cur.prevSection || cur.section;
  2003. 777.  -     }
  2004. 778.  -     if (curSection == 'search') {
  2005. 779.  -       curTab = 'news';
  2006. 780.  -     } else if (curSection == 'articles_search') {
  2007. 781.  -       curTab = 'articles';
  2008. 782.  -     } else {
  2009. 783.  -       curTab = curSection || '';
  2010. 784.  -     }
  2011. 785.  -
  2012. 786.  -     if (newSection == 'search') {
  2013. 787.  -       newTab = 'news';
  2014. 788.  -     } else if (newSection == 'articles_search') {
  2015. 789.  -       newTab = 'articles';
  2016. 790.  -     } else {
  2017. 791.  -       newTab = newSection || '';
  2018. 792.  -     }
  2019. 793.  -     debugLog('set section', from, curTab, newTab);
  2020. 794.  +         curTabEl = geByClass1('feed_tab_' + cur.section);
  2021. 799.  +       case 'photos':
  2022. 800.  +       case 'recommended':
  2023. 803.  -       case 'articles':
  2024. 804.  -       case 'articles_search':
  2025. 805.  -         curTopTab = 'custom';
  2026. 806.  -         break
  2027. 807.  -       case 'notifications':
  2028. 808.  -         curTopTab = 'notifications';
  2029. 809.  -         break;
  2030. 810.  -
  2031. 811.  +       case 'articles': curTopTab = 'custom'; break
  2032. 812.  +       case 'notifications': curTopTab = 'notifications'; break;
  2033. 815.  +       case 'articles_search':
  2034. 816.  +       case 'search': curTopTab = 'search'; break;
  2035. 821.  +       case 'photos':
  2036. 822.  +       case 'recommended':
  2037. 825.  -       case 'articles':
  2038. 826.  +       case 'articles':newTopTab = 'custom'; break
  2039. 827.  +       case 'notifications': newTopTab = 'notifications'; break;
  2040. 828.  +       case 'owner': newTopTab = 'owner'; break;
  2041. 829.  +       case 'source': newTopTab = 'source'; break;
  2042. 831.  -         newTopTab = 'custom';
  2043. 832.  -         break
  2044. 833.  -
  2045. 834.  -       case 'notifications':
  2046. 835.  -         newTopTab = 'notifications';
  2047. 836.  -         break;
  2048. 837.  -
  2049. 838.  -       case 'owner':
  2050. 839.  -         newTopTab = 'owner';
  2051. 840.  -         break;
  2052. 841.  -
  2053. 842.  -       case 'source':
  2054. 843.  -         newTopTab = 'source';
  2055. 844.  -         break;
  2056. 845.  +       case 'search': newTopTab = 'search'; break;
  2057. 847.  -
  2058. 848.  -     var curTabEl = curTab && curTab != newTab && geByClass1('feed_tab_' + curTab, feedBar, 'div');
  2059. 849.  -         newTabEl = newTab && geByClass1('feed_tab_' + newTab, feedBar, 'div');
  2060. 850.  -
  2061. 851.  -     debugLog('replace old', curTabEl, debugEl(curTabEl));
  2062. 852.  -     curTabEl && replaceClass(curTabEl, 'summary_tab_sel', 'summary_tab');
  2063. 853.  -     debugLog('replace new', newTabEl, debugEl(newTabEl));
  2064. 854.  -     newTabEl && replaceClass(newTabEl, 'summary_tab', 'summary_tab_sel');
  2065. 856.  -     // debugLog(curTopTab, newTopTab, from);
  2066. 872.  -
  2067. 873.  -       toggle('feed_news_bar', newTopTab == 'news');
  2068. 874.  -       toggle('feed_custom_bar', newTopTab == 'custom');
  2069. 875.  -       toggle('feed_search_bar', newTopTab == 'news' || inArray(newSection, ['articles_search', 'articles', 'notifications']));
  2070. 876.  -       toggleClass('feed_search_bar', 'fl_r', newTopTab == 'custom');
  2071. 877.  -       toggleClass('feed_search_bar', 'fl_l', newTopTab != 'custom');
  2072. 878.  +       toggle('feed_form_toggler', newTopTab == 'news' || newSection == 'articles' || newTopTab == 'search');
  2073. 879.  +       feed.toggleSearchForm(false, newTopTab != 'search', !newSection.indexOf('articles'));
  2074. 880.  +       hide('feed_custom_bar', 'feed_news_bar');
  2075. 881.  +       switch (newTopTab) {
  2076. 882.  +         case 'custom':
  2077. 883.  +         case 'search':
  2078. 884.  +           show('feed_' + newTopTab + '_bar'); break;
  2079. 885.  +         default:
  2080. 886.  +           show('feed_news_bar');
  2081. 887.  +           if (cur.onFeedBarShow) cur.onFeedBarShow();
  2082. 888.  +       }
  2083. 890.  -
  2084. 892.  -       var topTabEl = ge('feedtab_custom'),
  2085. 893.  -           topTabLabel = geByClass1('tab_word', topTabEl),
  2086. 894.  -           topTabLink = geByTag1('a', topTabEl);
  2087. 895.  -
  2088. 896.  -       if (newTabEl) {
  2089. 897.  -         val(topTabLabel, val(geByTag1('nobr', newTabEl)));
  2090. 898.  -       }
  2091. 899.  -       if (topTabLink) {
  2092. 900.  -         topTabLink.onmousedown = function (event) {
  2093. 901.  +       val(geByClass1('tab_word', ge('feedtab_custom')), val(geByTag1('nobr', geByClass1('feed_tab_' + newSection))));
  2094. 902.  +       var topLink = geByTag1('a', ge('feedtab_custom'));
  2095. 903.  +       if (topLink) {
  2096. 904.  +         topLink.onmousedown = function (event) {
  2097. 907.  -         topTabLink.href = '/feed?section=' + newSection;
  2098. 908.  +         topLink.href = '/feed?section=' + newSection;
  2099. 915.  -
  2100. 916.  +     curTabEl && replaceClass(curTabEl, 'summary_tab_sel', 'summary_tab');
  2101. 923.  -
  2102. 924.  +     curTabEl = geByClass1('feed_tab_' + cur.section);
  2103. 925.  +     curTabEl && replaceClass(curTabEl, 'summary_tab', 'summary_tab_sel');
  2104. 1279.  +   },
  2105. 1280.  +   toggleSearchForm: function (fire, on, articles) {
  2106. 1281.  +     if (articles === undefined) {
  2107. 1282.  +       articles = cur.section == 'articles' || cur.section == 'articles_search';
  2108. 1283.  +     }
  2109. 1284.  +     if (on === undefined) {
  2110. 1285.  +       on = !isVisible('feed_nosearch_bar');
  2111. 1286.  +     }
  2112. 1287.  +     if (fire && on && articles) {
  2113. 1288.  +       feed.switchSection('articles');
  2114. 1289.  +       return;
  2115. 1290.  +     }
  2116. 1291.  +     toggle('feed_nosearch_bar', on);
  2117. 1292.  +     toggle('feed_search_bar', !on);
  2118. 1293.  +     if (fire) {
  2119. 1294.  +       if (on) {
  2120. 1295.  +         show(articles ? 'feed_custom_bar' : 'feed_news_bar');
  2121. 1296.  +       } else {
  2122. 1297.  +         elfocus('feed_search')
  2123. 1298.  +       }
  2124. 1299.  +     }
  2125. 1300.  +     val('feed_form_toggler', getLang(on ? 'news_switch_to_search' : (articles ? 'news_switch_to_articles' : 'feed_add_post')));
  2126. 2032.  +       fullPostHeight: 50,
  2127. 2033.  +       emptyPostheight: 24,
  2128. 2145.  +     WallUpload.preinit();
  2129. 2163.  -     var _a = window.audioPlayer,
  2130. 2164.  -         aid = currentAudioId();
  2131. 2165.  +     var _a = window.audioPlayer, aid = currentAudioId();
  2132. 2281.  -     this.resultList.style.width = this.resultListShadow.style.width = resultContainer.style.width = '273px';
  2133. 2282.  +     this.resultList.style.width = this.resultListShadow.style.width = resultContainer.style.width = '230px';
  2134. ------
  2135. Файл - feed.css:
  2136. 14.  -   padding: 8px 10px 8px;
  2137. 15.  +   padding: 5px;
  2138. 26.  -   padding: 6px 4px 5px 20px;
  2139. 27.  -   width: 247px;
  2140. 28.  +   padding: 5px 4px 4px 20px;
  2141. 29.  +   width: 492px;
  2142. 32.  -   background: #FFF url(/images/magglass.png) no-repeat 5px 8px;
  2143. 33.  +   background: #FFF url(/images/magglass.png) no-repeat 5px 6px;
  2144. 42.  +   padding: 5px;
  2145. 46.  -   padding: 4px 5px;
  2146. 47.  +   padding: 5px;
  2147. ------
  2148. Файл - notifier.js:
  2149. 1200.  -     audioObj.src = '/' + filename + ext;
  2150. 1201.  +     audioObj.src = filename + ext;
  2151. 1236.  -             swfObj.loadAudio('/' + filename + ext);
  2152. 1237.  +             swfObj.loadAudio(filename + ext);
  2153. ------
Add Comment
Please, Sign In to add comment