Hormold

VK Change (#1387296029)

Dec 17th, 2013
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 40.50 KB | None | 0 0
  1. Файл - photos_add.js (Старый размер - 33457 | Новый - 0):
  2. 0.  - var PhotosAdd = {
  3. 1.  -   checkChanges: function(showBox) {
  4. 2.  -     if (cur.leaving) return;
  5. 3.  -     if (cur.album && cur.uploadStarted) {
  6. 4.  -       var msg = getLang('photos_uploading_warning');
  7. 5.  -       if (showBox === 1) {
  8. 6.  -         var box = showFastBox(getLang('global_warning'), msg, getLang('photos_stop_uploading'), function () {
  9. 7.  -           cur.leaving = true;
  10. 8.  -           box.hide();
  11. 9.  -           if (cur.onContinueCb) {
  12. 10.  -             cur.onContinueCb();
  13. 11.  -           }
  14. 12.  -         }, getLang('global_cancel'));
  15. 13.  -         return true;
  16. 14.  -       } else {
  17. 15.  -         return winToUtf(msg);
  18. 16.  -       }
  19. 17.  -     } else {
  20. 18.  -       if (showBox) return false;
  21. 19.  -     }
  22. 20.  -   },
  23. 21.  -   go: function(el, ev) {
  24. 22.  -     if (PhotosAdd.checkChanges(1)) {
  25. 23.  -       cur.onContinueCb = nav.go.pbind(el, ev);
  26. 24.  -       return true;
  27. 25.  -     }
  28. 26.  -     return nav.go(el, ev);
  29. 27.  -   },
  30. 28.  -   initBeforeUnload: function () {
  31. 29.  -     if (cur.unloadInited) return;
  32. 30.  -     cur.unloadInited = true;
  33. 31.  -     cur.nav.push(function (changed, old, n, opts) {
  34. 32.  -       if (PhotosAdd.checkChanges(1)) {
  35. 33.  -         cur.onContinueCb = nav.go.pbind(n);
  36. 34.  -         return false;
  37. 35.  -       } else if (cur.album == vk.id + '_-7' && cur.savedPhotos && cur.savedPhotos.length && !cur.savingPhotos) {
  38. 36.  -         cur.savingPhotos = true;
  39. 37.  -         ajax.post('/al_photos.php', {act: 'publish_photos', hash: cur.post_hash, photos: cur.savedPhotos.join(',')}, {
  40. 38.  -           onDone: nav.go.pbind(n)
  41. 39.  -         });
  42. 40.  -         return false;
  43. 41.  -       }
  44. 42.  -     });
  45. 43.  -     addEvent(window, 'DOMMouseScroll mousewheel', PhotosAdd.wheelHandler);
  46. 44.  -     addEvent(document, 'DOMMouseScroll', PhotosAdd.wheelHandler);
  47. 45.  -     cur.prevBefUnload = window.onbeforeunload;
  48. 46.  -     window.onbeforeunload = PhotosAdd.checkChanges;
  49. 47.  -     cur.destroy.push(function () {
  50. 48.  -       window.onbeforeunload = cur.prevBefUnload;
  51. 49.  -       removeEvent(window, 'DOMMouseScroll mousewheel', PhotosAdd.wheelHandler);
  52. 50.  -       removeEvent(document, 'DOMMouseScroll', PhotosAdd.wheelHandler);
  53. 51.  -     });
  54. 52.  -   },
  55. 53.  -   genFile: function(i, oncancel, cancel) {
  56. 54.  -     return ce('div', {innerHTML: '\
  57. 55.  - <a class="photo_file_cancel" id="photo_cancel' + i + '" onclick="' + oncancel + '">' + cancel + '</a>\
  58. 56.  - <div class="photo_file_button">\
  59. 57.  -   <div class="file_button_gray">\
  60. 58.  -     <div class="file_button" id="photo_file_button' + i + '">' + getLang('photos_choose_file') + '</div>\
  61. 59.  -   </div>\
  62. 60.  - </div>\
  63. 61.  -     '});
  64. 62.  -   },
  65. 63.  -   initFile: function(i) {
  66. 64.  -     FileButton.init('photo_file_button' + i, {
  67. 65.  -       name: 'photo',
  68. 66.  -       id: 'photo_file' + i,
  69. 67.  -       accept: 'image/jpeg,image/png,image/gif',
  70. 68.  -       onchange: PhotosAdd.fileSelected
  71. 69.  -     });
  72. 70.  -   },
  73. 71.  -   addFile: function() {
  74. 72.  -     var i = cur.files.length, el = PhotosAdd.genFile(i, 'PhotosAdd.fileCancel(' + i + ')', getLang('global_cancel'));
  75. 73.  -     extend(el, {className: 'photo_upload_file', id: 'photo_upload_row' + i});
  76. 74.  -     ge('photo_upload_files').appendChild(el);
  77. 75.  -     PhotosAdd.initFile(i);
  78. 76.  -     cur.files.push({});
  79. 77.  -   },
  80. 78.  -   filesLoad: function() { // for opera mini
  81. 79.  -     var i = 0, j = 0;
  82. 80.  -     for (; i < cur.files.length; ++i) {
  83. 81.  -       var val = ge('photo_file' + i).value;
  84. 82.  -       if (val) break;
  85. 83.  -     }
  86. 84.  -     if (i == cur.files.length) return;
  87. 85.  -
  88. 86.  -     cur.allcont = utilsNode.appendChild(ce('div', {innerHTML: '\
  89. 87.  - <iframe name="photo_frame_all"></iframe>\
  90. 88.  - <form target="photo_frame_all" id="photo_form_all" method="POST" action="' + cur.url + '" enctype="multipart/form-data"></form>\
  91. 89.  -     '})), form = ge('photo_form_all');
  92. 90.  -     var fields = extend(cur.fields, {
  93. 91.  -       act: 'do_add',
  94. 92.  -       al: 1,
  95. 93.  -       from_host: locHost,
  96. 94.  -       ondone: 'PhotosAdd.filesDone',
  97. 95.  -       onfail: 'PhotosAdd.filesFail'
  98. 96.  -     });
  99. 97.  -     for (j in fields) {
  100. 98.  -       form.appendChild(ce('input', {name: j, value: fields[j]}));
  101. 99.  -     }
  102. 100.  -     for (i = 0, j = 0; i < cur.files.length; ++i) {
  103. 101.  -       var f = ge('photo_file' + i);
  104. 102.  -       if (f.value) {
  105. 103.  -         f.name = 'file' + j;
  106. 104.  -         form.appendChild(f);
  107. 105.  -         ++j;
  108. 106.  -       }
  109. 107.  -     }
  110. 108.  -     form.submit();
  111. 109.  -   },
  112. 110.  -   fileSelected: function() {
  113. 111.  -     var i = intval(this.id.replace('photo_file', ''));
  114. 112.  -     if (!cur.files[i].deleting && (cur.files[i].cont || cur.files[i].id)) return;
  115. 113.  -
  116. 114.  -     cur['fileDone' + i] = PhotosAdd.fileDone.pbind(i);
  117. 115.  -     cur['fileFail' + i] = PhotosAdd.fileFail.pbind(i);
  118. 116.  -
  119. 117.  -     cur.files[i].cont = utilsNode.appendChild(ce('div', {innerHTML: '\
  120. 118.  - <iframe name="photo_frame' + i + '"></iframe>\
  121. 119.  - <form target="photo_frame' + i + '" id="photo_form' + i + '" method="POST" action="' + cur.url + '" enctype="multipart/form-data"></form>\
  122. 120.  -     '})), form = ge('photo_form' + i);
  123. 121.  -     var fields = extend(cur.fields, {
  124. 122.  -       act: 'do_add',
  125. 123.  -       al: 1,
  126. 124.  -       from_host: locHost,
  127. 125.  -       ondone: 'cur.fileDone' + i,
  128. 126.  -       onfail: 'cur.fileFail' + i
  129. 127.  -     });
  130. 128.  -     for (var j in fields) {
  131. 129.  -       form.appendChild(ce('input', {name: j, value: fields[j]}));
  132. 130.  -     }
  133. 131.  -     form.appendChild(this);
  134. 132.  -     form.submit();
  135. 133.  -
  136. 134.  -     var btn = ge('photo_file_button' + i);
  137. 135.  -     lockButton(btn);
  138. 136.  -     setTimeout(function() {
  139. 137.  -       btn.innerHTML = btn.innerHTML; // opera hack for redraw
  140. 138.  -     }, 0);
  141. 139.  -     show('photo_cancel' + i);
  142. 140.  -     ge('photo_cancel' + i).innerHTML = getLang('global_cancel');
  143. 141.  -     if (i == cur.files.length - 1) PhotosAdd.addFile();
  144. 142.  -   },
  145. 143.  -   fileDone: function(i, res) {
  146. 144.  -     hide('photo_cancel' + i);
  147. 145.  -     var before = '';
  148. 146.  -     for (var j = i + 1; j < cur.files.length; ++j) {
  149. 147.  -       if (cur.files[j].id && !cur.files[j].deleting) {
  150. 148.  -         before = cur.files[j].id;
  151. 149.  -         break;
  152. 150.  -       }
  153. 151.  -     }
  154. 152.  -     var obj;
  155. 153.  -     try {
  156. 154.  -       obj = eval('(' + res + ')');
  157. 155.  -     } catch(e) {
  158. 156.  -       obj = q2ajx(res);
  159. 157.  -     }
  160. 158.  -     PhotosAdd.fetchGeo(obj);
  161. 159.  -     setTimeout(ajax.post.pbind('al_photos.php', extend({
  162. 160.  -       act: 'done_add',
  163. 161.  -       before: before,
  164. 162.  -       context: 1,
  165. 163.  -       geo: 1
  166. 164.  -     }, obj), {
  167. 165.  -       onDone: function(id, html) {
  168. 166.  -         if (!id) return PhotosAdd.fileFail(i, 0);
  169. 167.  -
  170. 168.  -         cur.files[i].cont.innerHTML = '';
  171. 169.  -         utilsNode.removeChild(cur.files[i].cont);
  172. 170.  -         extend(cur.files[i], {
  173. 171.  -           id: id,
  174. 172.  -           deleting: false,
  175. 173.  -           cont: false
  176. 174.  -         });
  177. 175.  -
  178. 176.  -         ge('photo_upload_row' + i).innerHTML = html;
  179. 177.  -         autosizeSetup('photo_caption' + id, {minHeight: 30});
  180. 178.  -         show('photo_delete' + id);
  181. 179.  -       },
  182. 180.  -       onFail: function(text) {
  183. 181.  -         if (text) {
  184. 182.  -           setTimeout(showFastBox(getLang('global_error'), text).hide, 3000);
  185. 183.  -           PhotosAdd.fileCancel(i);
  186. 184.  -           return true;
  187. 185.  -         }
  188. 186.  -       }
  189. 187.  -     }), 0);
  190. 188.  -   },
  191. 189.  -   fileCancel: function(i, cleaning) {
  192. 190.  -     if (cur.files[i].cont) {
  193. 191.  -       cur.files[i].cont.innerHTML = '';
  194. 192.  -       utilsNode.removeChild(cur.files[i].cont);
  195. 193.  -     }
  196. 194.  -     if (cleaning) return;
  197. 195.  -
  198. 196.  -     var btn = ge('photo_file_button' + i);
  199. 197.  -     unlockButton(btn);
  200. 198.  -     btn.innerHTML = getLang('photos_choose_file');
  201. 199.  -     cur.files[i] = {};
  202. 200.  -     PhotosAdd.initFile(i);
  203. 201.  -     hide('photo_cancel' + i);
  204. 202.  -   },
  205. 203.  -   fileFail: function(i, code) {
  206. 204.  -     PhotosAdd.fileCancel(i);
  207. 205.  -   },
  208. 206.  -   fileDelete: function(id, hash) {
  209. 207.  -     var i = 0;
  210. 208.  -     for (; i < cur.files.length && cur.files[i].id != id;) {
  211. 209.  -       ++i;
  212. 210.  -     }
  213. 211.  -     if (i == cur.files.length || cur.files[i].deleting) return;
  214. 212.  -     cur.files[i].deleting = true;
  215. 213.  -     ajax.post('al_photos.php', {act: 'delete_photo', photo: id, hash: hash, edit: 2}, {onFail: function() {
  216. 214.  -       cur.files[i].deleting = false;
  217. 215.  -     }});
  218. 216.  -     var er = ge('photo_edit_row' + id);
  219. 217.  -     er.parentNode.insertBefore(PhotosAdd.genFile(i, 'PhotosAdd.fileRestore(\'' + id + '\', \'' + hash + '\')', getLang('global_restore')), er);
  220. 218.  -     hide(er);
  221. 219.  -     PhotosAdd.initFile(i);
  222. 220.  -     show('photo_cancel' + i);
  223. 221.  -   },
  224. 222.  -   fileRestore: function(id, hash) {
  225. 223.  -     var i = 0, before = '';
  226. 224.  -     for (; i < cur.files.length && cur.files[i].id != id;) {
  227. 225.  -       ++i;
  228. 226.  -     }
  229. 227.  -     if (i == cur.files.length || !cur.files[i].deleting || cur.files[i].deleting === -1) return;
  230. 228.  -     if (cur.files[i].cont) {
  231. 229.  -       return PhotosAdd.fileCancel(i);
  232. 230.  -     }
  233. 231.  -     for (var j = i + 1; j < cur.files.length; ++j) {
  234. 232.  -       if (cur.files[j].id && !cur.files[j].deleting) {
  235. 233.  -         before = cur.files[j].id;
  236. 234.  -         break;
  237. 235.  -       }
  238. 236.  -     }
  239. 237.  -     cur.files[i].deleting = -1;
  240. 238.  -     ajax.post('al_photos.php', {act: 'restore_photo', photo: id, hash: hash, before: before, edit: 2}, {onDone: function() {
  241. 239.  -       cur.files[i].deleting = false;
  242. 240.  -     }});
  243. 241.  -     var er = ge('photo_edit_row' + id);
  244. 242.  -     show(er);
  245. 243.  -     re(er.previousSibling);
  246. 244.  -   },
  247. 245.  -   filesDone: function(res) {
  248. 246.  -     var obj = q2ajx(res);
  249. 247.  -     PhotosAdd.fetchGeo(obj);
  250. 248.  -     setTimeout(ajax.post.pbind('al_photos.php', extend({act: 'done_add', context: 2, geo: 1}, obj)), 0);
  251. 249.  -   },
  252. 250.  -   filesFail: function() {
  253. 251.  -     for (var i = 0; i < cur.files.length; ++i) {
  254. 252.  -       PhotosAdd.fileCancel(i);
  255. 253.  -     }
  256. 254.  -     cur.allcont.innerHTML = '';
  257. 255.  -     utilsNode.removeChild(cur.allcont);
  258. 256.  -     cur.allcont = false;
  259. 257.  -   },
  260. 258.  -
  261. 259.  -   chooseFlash: function() {
  262. 260.  -     if (browser.flash < 10) {
  263. 261.  -       return animate(ge('photo_flash_needed'), {backgroundColor: '#FFEFE8', borderBottomColor: '#E89B88', borderLeftColor: '#E89B88', borderRightColor: '#E89B88', borderTopColor: '#E89B88'}, 100, function() {
  264. 262.  -         animate(ge('photo_flash_needed'), {backgroundColor: '#FFFFFF', borderBottomColor: '#CCCCCC', borderLeftColor: '#CCCCCC', borderRightColor: '#CCCCCC', borderTopColor: '#CCCCCC'}, 500);
  265. 263.  -       });
  266. 264.  -     }
  267. 265.  -     show('photo_flash_upload');
  268. 266.  -     hide('photo_default_upload');
  269. 267.  -   },
  270. 268.  -   chooseDefault: function() {
  271. 269.  -     show('photo_default_upload');
  272. 270.  -     hide('photo_flash_upload');
  273. 271.  -   },
  274. 272.  -   flashWidth: function() {
  275. 273.  -     if (_ua.indexOf('Mac') != -1 && (_ua.indexOf('Opera') != -1 || _ua.indexOf('Firefox') != -1)) return '601';
  276. 274.  -     return '600';
  277. 275.  -   },
  278. 276.  -
  279. 277.  -   backupDesc: function(photo) {
  280. 278.  -     if (!cur.descs) cur.descs = {};
  281. 279.  -     cur.descs[photo] = trim(ge('photo_caption' + photo).value);
  282. 280.  -   },
  283. 281.  -   saveDesc: function(photo, hash) {
  284. 282.  -     var dsc = ge('photo_caption' + photo).value, old = (cur.descs || {})[photo];
  285. 283.  -     delete (cur.descs || {})[photo];
  286. 284.  -     if (trim(dsc) == old) return;
  287. 285.  -
  288. 286.  -     ajax.post('al_photos.php', {act: 'save_desc', photo: photo, hash: hash, text: dsc, edit: 1}, {onDone: function(text) {
  289. 287.  -       ge('photo_save_result' + photo).innerHTML = text;
  290. 288.  -     }, onFail: function(text) {
  291. 289.  -       ge('photo_save_result' + photo).innerHTML = '<div class="photo_save_error">' + text + '</div>';
  292. 290.  -       return true;
  293. 291.  -     }, showProgress: function() {
  294. 292.  -       ge('photo_save_result' + photo).innerHTML = getLang('photos_privacy_description');
  295. 293.  -       show('photo_save_progress' + photo);
  296. 294.  -     }, hideProgress: function() {
  297. 295.  -       hide('photo_save_progress' + photo);
  298. 296.  -     }});
  299. 297.  -   },
  300. 298.  -
  301. 299.  -   multiSel: function(ev) {
  302. 300.  -     alert(ev.target.files.length);
  303. 301.  -   },
  304. 302.  -
  305. 303.  -   activeTab: function(el) {
  306. 304.  -     var p = domPN(domPN(el));
  307. 305.  -     for (var i = domFC(p); i; i = domNS(i)) {
  308. 306.  -       removeClass(i, 'active_link');
  309. 307.  -     }
  310. 308.  -     addClass(domPN(el), 'active_link');
  311. 309.  -     var addTab = domFC(ge('photo_add_tab'));
  312. 310.  -     if (addTab !== el) re('photo_add_tab');
  313. 311.  -   },
  314. 312.  -
  315. 313.  -   initHtml5: function() {
  316. 314.  -     var scrollNode = browser.msie6 ? pageNode : window;
  317. 315.  -     addEvent(scrollNode, 'scroll', PhotosAdd.scrollHandler);
  318. 316.  -     cur.destroy.push(function() {
  319. 317.  -       removeEvent(scrollNode, 'scroll', PhotosAdd.scrollHandler);
  320. 318.  -     });
  321. 319.  -
  322. 320.  -     if (!cur.noSortPhotos && !browser.mobile) {
  323. 321.  -       sorter.init('photos_add_list', {onReorder: PhotosAdd.reorderPhoto, dh: 0});
  324. 322.  -     }
  325. 323.  -
  326. 324.  -     cur.photoAddUpdate = function(el) {
  327. 325.  -       if (!cur.noSortPhotos && !browser.mobile) {
  328. 326.  -         setTimeout(sorter.update.pbind(el), 0);
  329. 327.  -       }
  330. 328.  -     }
  331. 329.  -     cur.deleteAllToggle = function(obj) {
  332. 330.  -       cur.photoAddUpdate(obj.parentNode);
  333. 331.  -     }
  334. 332.  -   },
  335. 333.  -
  336. 334.  -   reorderPhoto: function(el, before, after) {
  337. 335.  -     var list = ge('photos_add_list');
  338. 336.  -     var first = list.firstChild;
  339. 337.  -     while(first && !hasClass(first, 'photos_add_upl_row')) {
  340. 338.  -       first = first.nextSibling;
  341. 339.  -     }
  342. 340.  -     if (!hasClass(first, 'photos_add_first_child')) {
  343. 341.  -       var last = geByClass('photos_add_first_child', list)[0];
  344. 342.  -       removeClass(last, 'photos_add_first_child');
  345. 343.  -       addClass(first, 'photos_add_first_child');
  346. 344.  -     }
  347. 345.  -
  348. 346.  -     ajax.post('al_photos.php', {
  349. 347.  -       act: 'reorder_photos',
  350. 348.  -       photo: el.id.substr(14),
  351. 349.  -       before: (before) ? before.id.substr(14) : '',
  352. 350.  -       after: (after) ? after.id.substr(14) : ''
  353. 351.  -     });
  354. 352.  -   },
  355. 353.  -
  356. 354.  -   wheelHandler: function(ev) {
  357. 355.  -     if (cur.album && !cur.scrollFixed) cur.scrollFixed = true;
  358. 356.  -   },
  359. 357.  -
  360. 358.  -   scrollHandler: function(ev) {
  361. 359.  -     if (cur.uplSelected) {
  362. 360.  -       if (ge('photos_add_bar')) {
  363. 361.  -         var y = scrollGetY();
  364. 362.  -         if (!cur.scrollBarFixedY) {
  365. 363.  -           cur.scrollBarFixedY = getXY(ge('photos_add_bar').parentNode)[1];
  366. 364.  -         }
  367. 365.  -         var bar = ge('photos_add_bar');
  368. 366.  -         if (y > cur.scrollBarFixedY && !cur.scrollBarFixed) {
  369. 367.  -           bar.className = 'photos_add_bar1';
  370. 368.  -           cur.scrollBarFixed = true;
  371. 369.  -           if (cur.introTooltipHide) {
  372. 370.  -             cur.introTooltipHide();
  373. 371.  -           }
  374. 372.  -         }
  375. 373.  -         if (y < cur.scrollBarFixedY && cur.scrollBarFixed) {
  376. 374.  -           bar.className = 'photos_add_bar0';
  377. 375.  -           cur.scrollBarFixed = false;
  378. 376.  -           if (cur.introTooltipShow) {
  379. 377.  -             cur.introTooltipShow();
  380. 378.  -           }
  381. 379.  -         }
  382. 380.  -       }
  383. 381.  -       if (isVisible('photos_go_to_album')) {
  384. 382.  -         var w = window, de = document.documentElement, ft = ge('photos_go_to_album');
  385. 383.  -         if (!w.pageNode) return;
  386. 384.  -         var xy = getXY(ft.parentNode), sz = getSize(ft),
  387. 385.  -           dheight = Math.max(intval(w.innerHeight), intval(de.clientHeight));
  388. 386.  -         if (y < xy[1] + sz[1] - dheight && !cur.scrollFooterFixed) {
  389. 387.  -           addClass(ft, 'fixed');
  390. 388.  -           cur.scrollFooterFixed = true;
  391. 389.  -         }
  392. 390.  -         if (y > xy[1] + sz[1] - dheight && cur.scrollFooterFixed) {
  393. 391.  -           removeClass(ft, 'fixed');
  394. 392.  -           cur.scrollFooterFixed = false;
  395. 393.  -         }
  396. 394.  -       }
  397. 395.  -     }
  398. 396.  -   },
  399. 397.  -
  400. 398.  -   setThumb: function(obj, control) {
  401. 399.  -     var img = geByClass1('photos_add_img', obj);
  402. 400.  -     var imgSize = getSize(img);
  403. 401.  -     control.mtop = 0;
  404. 402.  -     if (Math.abs(img.rotate) % 180 == 90 && this.transformAvailable()) {
  405. 403.  -       imgSize.reverse();
  406. 404.  -       if (imgSize[1] < imgSize[0]) {
  407. 405.  -         control.mtop = Math.floor((imgSize[1] - imgSize[0]) / 2);
  408. 406.  -       }
  409. 407.  -     }
  410. 408.  -     if (browser.opera) control.mtop = control.mtop - 2;
  411. 409.  -     setStyle(control, {
  412. 410.  -       width: imgSize[0],
  413. 411.  -       marginLeft: Math.floor((132 - imgSize[0]) / 2)
  414. 412.  -     });
  415. 413.  -   },
  416. 414.  -
  417. 415.  -   thumbOver: function(obj, photo) {
  418. 416.  -     var control = geByClass('photos_add_controls', obj)[0];
  419. 417.  -     if (!control) { // create controls
  420. 418.  -       control = ce('div', {
  421. 419.  -         id: 'photos_add_controls'+photo,
  422. 420.  -         className: 'photos_add_controls',
  423. 421.  -         innerHTML: '<div class="photos_add_c_bar"><a class="photos_add_rl" onclick="PhotosAdd.rotateAngle(\''+photo+'\', 90);"></a><a class="photos_add_rr" onclick="PhotosAdd.rotateAngle(\''+photo+'\', -90);"></a></div>'
  424. 422.  -       });
  425. 423.  -       obj.appendChild(control);
  426. 424.  -     }
  427. 425.  -
  428. 426.  -     PhotosAdd.setThumb(obj, control);
  429. 427.  -     show(control);
  430. 428.  -
  431. 429.  -     animate(control, {height: 24, marginTop: control.mtop-24}, {duration: 200, transition: Fx.Transitions.easeOutCirc});
  432. 430.  -   },
  433. 431.  -
  434. 432.  -   thumbOut: function(obj) {
  435. 433.  -     var control = geByClass('photos_add_controls', obj)[0];
  436. 434.  -     if (!control) {
  437. 435.  -       return;
  438. 436.  -     }
  439. 437.  -     animate(control, {height: 0, marginTop: control.mtop}, 200, function() {
  440. 438.  -       //hide(control);
  441. 439.  -     });
  442. 440.  -   },
  443. 441.  -
  444. 442.  -   transformAvailable: function() {
  445. 443.  -     return false;
  446. 444.  -     if (cur.transformAvailable !== undefined) return cur.transformAvailable;
  447. 445.  -     var prefixes = 'Webkit Moz ms'.split(' '),
  448. 446.  -     prefix,
  449. 447.  -     div = ce('div'),i=0,
  450. 448.  -     prop = 'transform',
  451. 449.  -     support = div.style[prop] != undefined;
  452. 450.  -
  453. 451.  -     prop = prop.charAt(0).toUpperCase() + prop.slice(1)
  454. 452.  -     while( !support && (prefix=prefixes[i++]) ){
  455. 453.  -       support = div.style[prefix+prop] != undefined;
  456. 454.  -     }
  457. 455.  -     cur.transformAvailable = support;
  458. 456.  -     return support;
  459. 457.  -   },
  460. 458.  -
  461. 459.  -   rotateAngle: function(photo, angle) {
  462. 460.  -     var obj = ge('photos_add_img'+photo);
  463. 461.  -     var control = ge('photos_add_controls'+photo);
  464. 462.  -     if (control.blocked) return;
  465. 463.  -
  466. 464.  -     var rotate = obj.rotate || 0;
  467. 465.  -     rotate += angle;
  468. 466.  -     obj.rotate = rotate;
  469. 467.  -
  470. 468.  -     var imgSize = getSize(obj);
  471. 469.  -
  472. 470.  -     var row = ge('photo_edit_row'+photo);
  473. 471.  -     var onUpdate = function() {
  474. 472.  -       if (!cur.noSortPhotos) sorter.update(row);
  475. 473.  -       clearInterval(updInt);
  476. 474.  -       if (Math.abs(rotate) % 180 != 90 && (imgSize[0] - imgSize[1] > 15)) {
  477. 475.  -         PhotosAdd.thumbOut(ge('photos_add_thumb'+photo));
  478. 476.  -       }
  479. 477.  -     };
  480. 478.  -
  481. 479.  -     if (imgSize[0] > imgSize[1] && this.transformAvailable()) {
  482. 480.  -       if (!cur.noSortPhotos) {
  483. 481.  -         var updInt = setInterval(sorter.update.pbind(row), 10);
  484. 482.  -       }
  485. 483.  -       if (Math.abs(rotate) % 180 == 90) {
  486. 484.  -         animate(obj.parentNode, {
  487. 485.  -           marginTop: ((imgSize[0] - imgSize[1]) / 2),
  488. 486.  -           marginBottom: ((imgSize[0] - imgSize[1]) / 2)
  489. 487.  -         }, 200, onUpdate);
  490. 488.  -       } else {
  491. 489.  -         animate(obj.parentNode, {
  492. 490.  -           marginTop: 0,
  493. 491.  -           marginBottom: 0
  494. 492.  -         }, 200, onUpdate);
  495. 493.  -       }
  496. 494.  -     }
  497. 495.  -     if (!cur.noSortPhotos) {
  498. 496.  -       sorter.update(row);
  499. 497.  -     }
  500. 498.  -     if (this.transformAvailable()) {
  501. 499.  -       obj.style.webkitTransform = 'rotate('+rotate+'deg)';
  502. 500.  -       obj.style.MozTransform = 'rotate('+rotate+'deg)';
  503. 501.  -       obj.style.msTransform = 'rotate('+rotate+'deg)';
  504. 502.  -       PhotosAdd.setThumb(ge('photos_add_thumb'+photo), control);
  505. 503.  -       animate(control, {marginTop: control.mtop - 24}, 200);
  506. 504.  -     } else {
  507. 505.  -       var imgDiv = obj.parentNode.parentNode, xy = getXY(imgDiv), sz = getSize(imgDiv), w = 46, h = 16, l = Math.floor((sz[0] - w) / 2), t = Math.floor((sz[1] - h) / 2);
  508. 506.  -       setStyle(imgDiv, {position: 'relative'});
  509. 507.  -       var el = ce('div', {innerHTML: '<div id="rotating_image'+photo+'" class="progress_inv_img" style="display: block; position: absolute; width: '+w+'px; height: '+h+'px; left: '+l+'px; top: '+t+'px;">'}).firstChild;
  510. 508.  -       obj.parentNode.insertBefore(el, obj);
  511. 509.  -     }
  512. 510.  -     control.blocked = true;
  513. 511.  -     cur.rotateTimers = cur.rotateTimers || {};
  514. 512.  -     cur.rotateTimers[photo] = setTimeout(PhotosAdd.rotateFailed.pbind(photo), 5000);
  515. 513.  -
  516. 514.  -     var ph = cur.photoData[photo];
  517. 515.  -     form = ge('photo_rotate_form'+photo);
  518. 516.  -     form.innerHTML = '';
  519. 517.  -     form.action = ph.rotate[0];
  520. 518.  -     var data = extend({
  521. 519.  -       act: 'do_rotate',
  522. 520.  -       to: (angle == 90) ? 1 : -1,
  523. 521.  -       fid: photo
  524. 522.  -     }, ph.rotate);
  525. 523.  -     if (data.act == 'rotate_photo') {
  526. 524.  -       data.angle = (data.angle + data.to + 4) % 4;
  527. 525.  -     }
  528. 526.  -     var to = (data.to + 4) % 4;
  529. 527.  -     if (data['rot'+to]) {
  530. 528.  -       data.act = 'done_rotate';
  531. 529.  -       data.complete = 1;
  532. 530.  -       ajax.post('/al_photos.php', data, {
  533. 531.  -         onDone: PhotosAdd.rotateDone,
  534. 532.  -         onFail: function() {
  535. 533.  -           PhotosAdd.rotateDone();
  536. 534.  -         }
  537. 535.  -       });
  538. 536.  -       return;
  539. 537.  -     }
  540. 538.  -     for (var i in data) {
  541. 539.  -       if (i != 0) {
  542. 540.  -         form.appendChild(ce('input', {type: 'hidden', name: i, value: data[i]}));
  543. 541.  -       }
  544. 542.  -     }
  545. 543.  -     form.submit();
  546. 544.  -
  547. 545.  -     obj.parentNode.onclick = function() {
  548. 546.  -       cur.photoData[photo].onRotateShow = true;
  549. 547.  -       return false;
  550. 548.  -     }
  551. 549.  -
  552. 550.  -     ajaxCache = {};
  553. 551.  -     delete cur.pvList;
  554. 552.  -     delete cur.pvData;
  555. 553.  -   },
  556. 554.  -
  557. 555.  -   rotateDone: function(data) {
  558. 556.  -     if (!data) {
  559. 557.  -       return;
  560. 558.  -     }
  561. 559.  -     var photo = data['photo_raw'];
  562. 560.  -     var obj = ge('photos_add_img'+photo);
  563. 561.  -     var control = ge('photos_add_controls'+photo);
  564. 562.  -     delete control.blocked;
  565. 563.  -     if (!PhotosAdd.transformAvailable()) {
  566. 564.  -       re('rotating_image'+photo);
  567. 565.  -       obj.src = data.o_src  || data.m_src;
  568. 566.  -       obj.onload = function() {
  569. 567.  -         PhotosAdd.setThumb(ge('photos_add_thumb'+photo), control);
  570. 568.  -         if (!cur.noSortPhotos) {
  571. 569.  -           sorter.update(ge('photo_edit_row'+photo));
  572. 570.  -         }
  573. 571.  -       };
  574. 572.  -       cur.rotateTimers = cur.rotateTimers || {};
  575. 573.  -       clearTimeout(cur.rotateTimers[photo]);
  576. 574.  -     }
  577. 575.  -     delete data.m_;
  578. 576.  -     delete data.o_;
  579. 577.  -
  580. 578.  -     var ph = cur.photoData[photo];
  581. 579.  -
  582. 580.  -     extend(ph.rotate, {photo: data.photo, hash: data.hash, rhash: data.rhash, angle: data.angle, rot1: data.rot1, rot3: data.rot3});
  583. 581.  -
  584. 582.  -     ajaxCache = {};
  585. 583.  -     delete cur.pvList;
  586. 584.  -     delete cur.pvData;
  587. 585.  -
  588. 586.  -     obj.parentNode.onclick = function(ev) {
  589. 587.  -       return showPhoto(photo, 'album' + ph['album'], {temp: {base: data['base'], x_: data['x_'], y_: data['y_'], z_: data['z_']}, dark: 1}, ev);
  590. 588.  -     }
  591. 589.  -
  592. 590.  -     if (cur.photoData[photo].onRotateShow) {
  593. 591.  -       obj.parentNode.onclick();
  594. 592.  -     }
  595. 593.  -     cur.photoData[photo].onRotateShow = false;
  596. 594.  -   },
  597. 595.  -
  598. 596.  -   rotateFailed: function(photo) {
  599. 597.  -     if (!PhotosAdd.transformAvailable()) {
  600. 598.  -       re('rotating_image'+photo);
  601. 599.  -     }
  602. 600.  -     var control = ge('photos_add_controls'+photo);
  603. 601.  -     delete control.blocked;
  604. 602.  -   },
  605. 603.  -
  606. 604.  -   deleteAddPhoto: function(i) {
  607. 605.  -     var obj = qsorter.remove(cur.uplBox, ge('photos_add_item'+i));
  608. 606.  -     cur.uploadPhotoCount -= 1;
  609. 607.  -     if (obj) {
  610. 608.  -       PhotosAdd.thumbOver(obj.id.substr(19), geByClass('photos_add_img', obj)[0]);
  611. 609.  -     }
  612. 610.  -     PhotosAdd.updateCount();
  613. 611.  -   },
  614. 612.  -
  615. 613.  -   correctThumb: function(i, rotate, obj) {
  616. 614.  -     if (Math.abs(rotate) % 180 == 90) {
  617. 615.  -       var w = Math.min(obj.firstChild.width, 98);
  618. 616.  -       setStyle(obj, {
  619. 617.  -         width: w,
  620. 618.  -         marginLeft: Math.ceil((130 - w) / 2)
  621. 619.  -       })
  622. 620.  -     } else {
  623. 621.  -       var w = obj.firstChild.width;
  624. 622.  -       setStyle(obj, {
  625. 623.  -         width: w,
  626. 624.  -         marginLeft: Math.ceil((130 - w) / 2)
  627. 625.  -       })
  628. 626.  -     }
  629. 627.  -
  630. 628.  -     var control = ge('photos_add_controls'+i);
  631. 629.  -     hide(control);
  632. 630.  -     setStyle(control, {
  633. 631.  -       height: 0,
  634. 632.  -       marginTop: '0px'
  635. 633.  -     });
  636. 634.  -     setTimeout(function() {
  637. 635.  -       var fileItem = Upload.fileList[cur.uplId][i];
  638. 636.  -       fileItem.animating = false;
  639. 637.  -       PhotosAdd.thumbOver(i, obj);
  640. 638.  -     }, 600);
  641. 639.  -   },
  642. 640.  -
  643. 641.  -   updateCount: function() {
  644. 642.  -     var save = ge('photos_add_save');
  645. 643.  -     save.innerHTML = langNumeric(cur.qsrt.count, cur.uploaderLang['photos_save_X_photos']);
  646. 644.  -     if (cur.qsrt.count == 0) {
  647. 645.  -       show('photos_add_empty');
  648. 646.  -       hide('photos_add_box');
  649. 647.  -       hide(ge('photos_add_bar').parentNode);
  650. 648.  -       Upload.fileList[cur.uplId] = false;
  651. 649.  -     }
  652. 650.  -   },
  653. 651.  -
  654. 652.  -   saveHtml5: function() {
  655. 653.  -     Upload.uploadPhotos(cur.uplId);
  656. 654.  -   },
  657. 655.  -
  658. 656.  -   scrollToBottom: function(el) {
  659. 657.  -     if (cur.scrollFixed) return;
  660. 658.  -     var w = window, de = document.documentElement;
  661. 659.  -     if (!el) el = cur.lastPhotoRow;
  662. 660.  -     if (!w.pageNode || !el) return;
  663. 661.  -     var xy = getXY(el), sz = getSize(el),
  664. 662.  -         dheight = Math.max(intval(w.innerHeight), intval(de.clientHeight));
  665. 663.  -     if (xy[1] <= 0) xy = getXY(el.parentNode);
  666. 664.  -     var scrollY = xy[1] + sz[1] - dheight;
  667. 665.  -     if (scrollY > 0) scrollToY(scrollY, 400);
  668. 666.  -   },
  669. 667.  -
  670. 668.  -   onUploadStart: function(info, res) {
  671. 669.  -     PhotosAdd.initBeforeUnload();
  672. 670.  -     if (cur.onPhotoAddStart) {
  673. 671.  -       cur.onPhotoAddStart();
  674. 672.  -     }
  675. 673.  -     if (cur.flash_lite && info.num === undefined) {
  676. 674.  -       info = res;
  677. 675.  -     }
  678. 676.  -     if (info.num == 0) {
  679. 677.  -       cur.errorCount = 0;
  680. 678.  -       if (!ge('photos_add_wrap')) {
  681. 679.  -         cur.count = 0;
  682. 680.  -         var pc = ge('photos_container') || ge('photos_albums_container'), pa = ge('photos_upload_area'), tab = ge('photo_add_tab');
  683. 681.  -         pc.parentNode.insertBefore(ce('div', {innerHTML: cur.photosAddWrap}).firstChild, pc);
  684. 682.  -         pa.parentNode.insertBefore(ce('div', {innerHTML: cur.photosAddBar}).firstChild, pa);
  685. 683.  -         setStyle(ge('lite_photo_uploader'), {width: '1px', height: '1px'});
  686. 684.  -         hide(pc, pa, 'add_album_link');
  687. 685.  -         re(pa);
  688. 686.  -         re('photos_container');
  689. 687.  -         re('photos_albums_container');
  690. 688.  -         re('albums_load_more');
  691. 689.  -         re('photos_load_more');
  692. 690.  -         re(geByClass1('summary_wrap', ge('photos_upload_area_wrap').parentNode));
  693. 691.  -         re(geByClass1('photos_summary', ge('photos_upload_area_wrap').parentNode));
  694. 692.  -         show(tab);
  695. 693.  -         var w = 180;
  696. 694.  -         while (tab.previousSibling && getXY(tab)[1] > getXY(tab.previousSibling)[1] && w > 100) {
  697. 695.  -           w -= 10;
  698. 696.  -           var tabW = geByClass1('tab_word', tab.previousSibling);
  699. 697.  -           if (!tabW) break;
  700. 698.  -           setStyle(tabW, {maxWidth: w});
  701. 699.  -         }
  702. 700.  -         PhotosAdd.activeTab(tab.firstChild);
  703. 701.  -         PhotosAdd.initHtml5();
  704. 702.  -         if (cur.albums) {
  705. 703.  -           cur.movedd = new Dropdown(ge('photos_move_dd'), cur.albums, {
  706. 704.  -             width: 200,
  707. 705.  -             multiselect: false,
  708. 706.  -             autocomplete: (cur.albums.length > 7),
  709. 707.  -             onChange: photos.movePhoto
  710. 708.  -           });
  711. 709.  -           cur.moveddc = ge('photos_movedd_container').firstChild;
  712. 710.  -         }
  713. 711.  -       }
  714. 712.  -       hide('photos_add_empty', 'photos_go_to_album');
  715. 713.  -       show('photos_add_box');
  716. 714.  -       addClass(ge('photos_add_wrap'), 'photos_add_selected');
  717. 715.  -       show(ge('photos_add_bar').parentNode);
  718. 716.  -       if (browser.msie) {
  719. 717.  -         setStyle(ge('photos_add_bar_form'), {position: 'absolute', top: '-5000px'});
  720. 718.  -       } else {
  721. 719.  -         setStyle(ge('photos_add_bar_form'), {visibility: 'hidden'});
  722. 720.  -       }
  723. 721.  -       if (browser.mozilla && ge('lite_photo_uploader')) {
  724. 722.  -         setStyle(ge('lite_photo_uploader'), {visibility: 'hidden'});
  725. 723.  -       }
  726. 724.  -       show('photos_add_bar_progress');
  727. 725.  -       if (info.totalCount > 1) {
  728. 726.  -         var txt = (cur.uploaderLang['photos_add_uploading_X'] || '').replace('%s', info.totalCount);
  729. 727.  -       } else {
  730. 728.  -         var txt = cur.uploaderLang['photos_add_uploading'];
  731. 729.  -       }
  732. 730.  -       ge('photos_add_p_text').innerHTML = txt;
  733. 731.  -       cur.scrollBarFixedY = false;
  734. 732.  -       cur.uploadStarted = true;
  735. 733.  -       setStyle(ge('photos_add_p_inner'), {width: '0px'});
  736. 734.  -       hide('photos_add_error');
  737. 735.  -     } else {
  738. 736.  -       var lng = langNumeric(info.num, cur.uploaderLang['photos_add_uploaded_X'])
  739. 737.  -       ge('photos_add_p_text').innerHTML = lng.replace('{count}', info.totalCount);
  740. 738.  -     }
  741. 739.  -     var classAdd = '';
  742. 740.  -
  743. 741.  -     if (!cur.photosAddFirst) {
  744. 742.  -       cur.photosAddFirst = true;
  745. 743.  -       classAdd = ' photos_add_first_child';
  746. 744.  -     }
  747. 745.  -     info.prepareCont = ce('div', {
  748. 746.  -       className: 'photos_add_upl_row'+classAdd,
  749. 747.  -       innerHTML: '<div class="photos_add_s_loading"></div>'
  750. 748.  -     });
  751. 749.  -     if (cur.flash_lite) {
  752. 750.  -       cur.flashPrepareCont = cur.flashPrepareCont || {};
  753. 751.  -       cur.flashPrepareCont[info.num] = cur.flashPrepareCont[info.num] || {};
  754. 752.  -       cur.flashPrepareCont[info.num][info.filename] = info.prepareCont;
  755. 753.  -     }
  756. 754.  -     var addList = ge('photos_add_list');
  757. 755.  -     addList.appendChild(info.prepareCont);
  758. 756.  -     cur.lastPhotoRow = info.prepareCont;
  759. 757.  -     PhotosAdd.makeTask(function() {
  760. 758.  -       show(info.prepareCont);
  761. 759.  -       PhotosAdd.scrollToBottom();
  762. 760.  -       return true; // need to flush
  763. 761.  -     });
  764. 762.  -     cur.uplSelected = true;
  765. 763.  -
  766. 764.  -     setStyle(ge('photos_add_p_inner'), {width: (info.loadedSize / info.totalSize  * 175)+'px'});
  767. 765.  -     ajax.post('al_photos.php', {act: 'start_add', hash: cur.statsPhotoAddHash});
  768. 766.  -   },
  769. 767.  -
  770. 768.  -   onUploadProgress: function(info, start, all) {
  771. 769.  -     if (cur.flash_lite) {
  772. 770.  -       info = {loadedSize: start, totalSize: all};
  773. 771.  -       start = 0;
  774. 772.  -     }
  775. 773.  -
  776. 774.  -     var allProgress = (info.loadedSize + start) / info.totalSize;
  777. 775.  -     var newWidth = allProgress * 175;
  778. 776.  -     var oldWidth = intval(ge('photos_add_p_inner').style.width);
  779. 777.  -     if (newWidth > oldWidth) {
  780. 778.  -       animate(ge('photos_add_p_inner'), {width: newWidth}, 200);
  781. 779.  -     }
  782. 780.  -   },
  783. 781.  -
  784. 782.  -   onUploadComplete: function(info, res) {
  785. 783.  -     if (cur.flash_lite) {
  786. 784.  -       info.prepareCont = cur.flashPrepareCont[info.num][info.filename];
  787. 785.  -     }
  788. 786.  -     var obj;
  789. 787.  -     try {
  790. 788.  -       obj = eval('(' + res + ')');
  791. 789.  -     } catch(e) {
  792. 790.  -       obj = q2ajx(res);
  793. 791.  -     }
  794. 792.  -     if (!obj.photos) {
  795. 793.  -       cur.errorCount++;
  796. 794.  -       re(info.prepareCont);
  797. 795.  -       if (info.prepareCont && info.prepareCont.helper) re(info.prepareCont.helper);
  798. 796.  -       ge('photos_add_error').innerHTML = cur.uploaderLang['photos_add_error'];
  799. 797.  -       show('photos_add_error');
  800. 798.  -       scrollToTop(200);
  801. 799.  -       PhotosAdd.makeTask();
  802. 800.  -       return;
  803. 801.  -     }
  804. 802.  -     if (obj.code) {
  805. 803.  -       Upload.onUploadError(cur.UplId, obj.code);
  806. 804.  -       return;
  807. 805.  -     }
  808. 806.  -     PhotosAdd.fetchGeo(obj);
  809. 807.  -     var params = extend({act: 'done_add', from: 'html5', context: 1, geo: 1}, obj);
  810. 808.  -     cur.lastPhotoRow = info.prepareCont;
  811. 809.  -     cur.photoSaveQ = cur.photoSaveQ || [];
  812. 810.  -     cur.photoSaveQ.push(function() {
  813. 811.  -       ajax.post('al_photos.php', params, {
  814. 812.  -         onDone: function(html, js, photoRaw) {
  815. 813.  -           cur.count++;
  816. 814.  -           info.prepareCont.innerHTML = html;
  817. 815.  -           eval(js);
  818. 816.  -           cur.savedPhotos = cur.savedPhotos || [];
  819. 817.  -           cur.savedPhotos.push(photoRaw);
  820. 818.  -           if (!cur.movedd) hide('photos_move_link'+photoRaw);
  821. 819.  -           show(info.prepareCont);
  822. 820.  -           info.prepareCont.id = 'photo_edit_row'+photoRaw;
  823. 821.  -           PhotosAdd.makeTask();
  824. 822.  -           setTimeout(function() {
  825. 823.  -             if (!cur.noSortPhotos) {
  826. 824.  -               sorter.added(info.prepareCont.parentNode);
  827. 825.  -             }
  828. 826.  -             setTimeout(PhotosAdd.scrollToBottom, 100);
  829. 827.  -           }, 0);
  830. 828.  -           cur.photoSaveQ.shift();
  831. 829.  -           if (cur.photoSaveQ[0]) cur.photoSaveQ[0]();
  832. 830.  -           if (cur.onPhotoFirstUploaded) cur.onPhotoFirstUploaded();
  833. 831.  -         },
  834. 832.  -         onFail: function(text) {
  835. 833.  -           if (text) {
  836. 834.  -             ge('photos_add_error').innerHTML = text;
  837. 835.  -             show('photos_add_error');
  838. 836.  -             scrollToTop(200);
  839. 837.  -           }
  840. 838.  -           cur.errorUpload = true;
  841. 839.  -           if (hasClass(info.prepareCont, 'photos_add_first_child')) {
  842. 840.  -             var next = info.prepareCont.nextSibling;
  843. 841.  -             while(next) {
  844. 842.  -               if (hasClass(next, 'photos_add_upl_row')) {
  845. 843.  -                 addClass(next, 'photos_add_first_child');
  846. 844.  -                 break;
  847. 845.  -               }
  848. 846.  -               next = next.nextSibling;
  849. 847.  -             }
  850. 848.  -             if (!next) {
  851. 849.  -               cur.photosAddFirst = false;
  852. 850.  -             }
  853. 851.  -           }
  854. 852.  -           re(info.prepareCont);
  855. 853.  -           cur.photoSaveQ.shift();
  856. 854.  -           if (cur.photoSaveQ[0]) cur.photoSaveQ[0]();
  857. 855.  -           PhotosAdd.makeTask();
  858. 856.  -           return true;
  859. 857.  -         }
  860. 858.  -       });
  861. 859.  -     });
  862. 860.  -     if (cur.photoSaveQ.length == 1) {
  863. 861.  -       cur.photoSaveQ[0]();
  864. 862.  -     }
  865. 863.  -   },
  866. 864.  -
  867. 865.  -   updateSorterRow: function(photo) {
  868. 866.  -     if (!cur.noSortPhotos) {
  869. 867.  -       setTimeout(function() {
  870. 868.  -         sorter.update(ge('photo_edit_row'+photo));
  871. 869.  -       }, 0)
  872. 870.  -     }
  873. 871.  -   },
  874. 872.  -
  875. 873.  -   onUploadCompleteAll: function(info, res) {
  876. 874.  -     cur.uploadStartProgress = 0;
  877. 875.  -     delete cur.uploadStarted;
  878. 876.  -     window.onbeforeunload = cur.prevBefUnload;
  879. 877.  -     delete cur.unloadInited;
  880. 878.  -     this.onUploadProgress({loadedSize: 100, totalSize: 100}, cur.flash_lite ? 100 : 0, 100);
  881. 879.  -     PhotosAdd.makeTask(function() {
  882. 880.  -       var infoCont = ge('photo_upload_area_label'), infoText = infoCont.innerHTML;
  883. 881.  -       hide('photos_add_more_info');
  884. 882.  -       if (!cur.errorUpload) {
  885. 883.  -         infoCont.innerHTML = langNumeric((info.totalCount || res.totalCount) - (cur.errorCount || 0), cur.uploaderLang['photos_successfully_added']);
  886. 884.  -       } else {
  887. 885.  -         infoCont.innerHTML = cur.uploaderLang['photos_add_error'];
  888. 886.  -         cur.errorUpload = false;
  889. 887.  -       }
  890. 888.  -       toggleClass(infoCont, "photos_upload_area_img", false);
  891. 889.  -       fadeIn(infoCont, 500, function() {
  892. 890.  -         setTimeout(function() {
  893. 891.  -           fadeOut(infoCont,300, function() {
  894. 892.  -             if ((cur.savedPhotos || []).length >= (cur.maxFiles || 200)) {
  895. 893.  -               slideUp('photos_upload_area_wrap', 200, function() {re('photos_upload_area_wrap')});
  896. 894.  -             } else {
  897. 895.  -               if (cur.flash_lite) {
  898. 896.  -                 re('lite_photo_uploader');
  899. 897.  -                 var par = ge('photos_upload_area'),
  900. 898.  -                     el = ce('div', {innerHTML: '<div id="lite_photo_uploader" style="position: absolute; height: 100%; width: 100%; z-index: 9999; cursor: pointer;"></div>'}).firstChild;
  901. 899.  -                 par.parentNode.insertBefore(el, par);
  902. 900.  -                 cur.initFlashLite();
  903. 901.  -               } else if (cur.html5AddLink){
  904. 902.  -                 var par = ge('photos_upload_area'), el = ce('div', {innerHTML: cur.html5AddLink}).firstChild;
  905. 903.  -                 par.id = 'remove_in_process';
  906. 904.  -                 par.parentNode.insertBefore(el, par);
  907. 905.  -                 re(par);
  908. 906.  -                 infoCont = ge('photo_upload_area_label');
  909. 907.  -               }
  910. 908.  -               toggleClass(infoCont, "photos_upload_area_img", true);
  911. 909.  -               infoCont.innerHTML = infoText;
  912. 910.  -               fadeIn(infoCont, 300);
  913. 911.  -             }
  914. 912.  -           })
  915. 913.  -         }, 2000);
  916. 914.  -       })
  917. 915.  -       show('photos_go_to_album');
  918. 916.  -       cur.lastPhotoRow = ge('photos_go_to_album');
  919. 917.  -       PhotosAdd.scrollToBottom();
  920. 918.  -       if (cur.flash_lite) {
  921. 919.  -         re('lite_photo_uploader');
  922. 920.  -       }
  923. 921.  -       fadeOut('photos_add_bar_progress', 500);
  924. 922.  -       if (browser.msie) {
  925. 923.  -         setStyle(ge('photos_add_bar_form'), {position: 'relative', top: '0px', display: 'none'});
  926. 924.  -       } else {
  927. 925.  -         setStyle(ge('photos_add_bar_form'), {visibility: 'visible', display: 'none'});
  928. 926.  -       }
  929. 927.  -       fadeIn('photos_add_bar_form', 500);
  930. 928.  -     });
  931. 929.  -   },
  932. 930.  -
  933. 931.  -   makeTask: function(task) {
  934. 932.  -     cur.photoAddQ = cur.photoAddQ || [];
  935. 933.  -     if (task) {
  936. 934.  -       cur.photoAddQ.push(task);
  937. 935.  -     } else {
  938. 936.  -       cur.photoAddSt = false;
  939. 937.  -     }
  940. 938.  -     if (!cur.photoAddSt) {
  941. 939.  -       var newTask = cur.photoAddQ.shift();
  942. 940.  -       if (newTask) {
  943. 941.  -         cur.photoAddSt = newTask();
  944. 942.  -       }
  945. 943.  -     }
  946. 944.  -   },
  947. 945.  -
  948. 946.  -   fetchGeo: function(obj) {
  949. 947.  -     if (!obj.photos) {
  950. 948.  -       return false;
  951. 949.  -     }
  952. 950.  -     var photos = parseJSON(obj.photos);
  953. 951.  -
  954. 952.  -     if (!photos) {
  955. 953.  -       return false;
  956. 954.  -     }
  957. 955.  -     var coords = {};
  958. 956.  -     var len = 0;
  959. 957.  -     for (var i in photos) {
  960. 958.  -       var lat = photos[i].latitude;
  961. 959.  -       var long = photos[i].longitude;
  962. 960.  -       if (lat && long) {
  963. 961.  -         coords[lat+','+long] = 1;
  964. 962.  -         len += 1;
  965. 963.  -       }
  966. 964.  -     }
  967. 965.  -     if (!len) {
  968. 966.  -       return false;
  969. 967.  -     }
  970. 968.  -     stManager.add(['maps.js'], function() {
  971. 969.  -       cur.placeMap = new vkMaps.VKMap(false, 'google');
  972. 970.  -       if (cur.placeMap.isLoaded('google')) {
  973. 971.  -         PhotosAdd.setGeo(coords);
  974. 972.  -       } else {
  975. 973.  -         cur.placeMap.load.addHandler(PhotosAdd.setGeo.pbind(coords));
  976. 974.  -       }
  977. 975.  -     });
  978. 976.  -   },
  979. 977.  -
  980. 978.  -   setGeo: function(coords) {
  981. 979.  -     var lngcode = cur.uploaderLang.geolang || 'en';
  982. 980.  -     for (var coord in coords) {
  983. 981.  -       coord = coord.split(',');
  984. 982.  -       var lat = coord[0];
  985. 983.  -       var long = coord[1];
  986. 984.  -       new vkMaps.Geocoder('google', function(place) {
  987. 985.  -         ajax.post('al_photos.php', {
  988. 986.  -           act: 'a_set_geo',
  989. 987.  -           lat: coord[0],
  990. 988.  -           long: coord[1],
  991. 989.  -           geo_country: place.country,
  992. 990.  -           geo_locality: place.locality,
  993. 991.  -           geo_region: place.region,
  994. 992.  -           geo_street: place.street,
  995. 993.  -           geo_place: place.place,
  996. 994.  -           geo_lang: lngcode,
  997. 995.  -           geo_code: place.countryCode
  998. 996.  -         });
  999. 997.  -       }).geocode({location: new google.maps.LatLng(lat, long), language: lngcode})
  1000. 998.  -     }
  1001. 999.  -   }
  1002. 1000.  -
  1003. 1001.  - }
  1004. 1002.  -
  1005. 1003.  - try{stManager.done('photos_add.js');}catch(e){}
  1006. ------
Advertisement
Add Comment
Please, Sign In to add comment