Hormold

VK Change (#1384794003)

Nov 18th, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.03 KB | None | 0 0
  1. Файл - phototag.js (Старый размер - 9371 | Новый - 0):
  2. 0.  - var Phototag = {
  3. 1.  -   startTag: function() {
  4. 2.  -     if (cur.pvTagger || !cur.pvPhoto.firstChild) return;
  5. 3.  -
  6. 4.  -     if (!cur.pvFriends) {
  7. 5.  -       cur.pvFriends = layer.appendChild(ce('div', {id: 'pv_friends', innerHTML: '\
  8. 6.  - <div class="box_title_wrap"><div class="box_x_button"></div>\
  9. 7.  -   <div class="box_title">' + getLang('photos_typename') + '</div>\
  10. 8.  - </div>\
  11. 9.  - <div class="name_input"><input onkeyup="Phototag.updateFriends()" onkeypress="if (event.keyCode == 10 || event.keyCode == 13) Phototag.addTag()" type="text" id="pv_friend_name" class="text" /></div>\
  12. 10.  - <div class="list_wrap"><a href="/" onclick="return Phototag.addTag(' + vk.id + ', event)">' + getLang('photos_tags_me') + '</a>\
  13. 11.  -   <div id="pv_friends_cont"><div class="progress"></div></div>\
  14. 12.  - </div>\
  15. 13.  - <div class="box_controls_wrap">\
  16. 14.  -   <div class="box_controls">\
  17. 15.  -     <table id="pv_tag_buttons" cellspacing="0" cellpadding="0">\
  18. 16.  -       <tr>\
  19. 17.  -         <td><div class="button_blue button_wide"><button id="pv_add_tag">' + getLang('global_add') + '</button></div></td>\
  20. 18.  -         <td><div class="button_gray button_wide"><button id="pv_cancel_tag">' + getLang('global_cancel') + '</button></div></td>\
  21. 19.  -       </tr>\
  22. 20.  -     </table>\
  23. 21.  -     <div id="pv_tag_progress" class="progress"></div>\
  24. 22.  -   </div>\
  25. 23.  - </div>\
  26. 24.  -       '}));
  27. 25.  -       extend(cur, {
  28. 26.  -         pvFriendName: ge('pv_friend_name'),
  29. 27.  -         pvFriendsCont: ge('pv_friends_cont')
  30. 28.  -       });
  31. 29.  -       addEvent(cur.pvFriends, 'click', function() {
  32. 30.  -         cur.pvClicked = true;
  33. 31.  -       });
  34. 32.  -       var xbtn = cur.pvFriends.firstChild.firstChild;
  35. 33.  -       addEvent(xbtn, 'mouseover', function() { animate(this, {backgroundColor: '#FFFFFF'}, 200); });
  36. 34.  -       addEvent(xbtn, 'mouseout', function() { animate(this, {backgroundColor: '#9CB8D4'}, 200); });
  37. 35.  -       addEvent(xbtn, 'click', Phototag.stopTag);
  38. 36.  -
  39. 37.  -       ge('pv_add_tag').onclick = Phototag.addTag;
  40. 38.  -       ge('pv_cancel_tag').onclick = Phototag.stopTag;
  41. 39.  -     }
  42. 40.  -     if (!cur.pvFriendsList) {
  43. 41.  -       ajax.post('al_friends.php', {act: 'pv_friends'}, {onDone: function(list) {
  44. 42.  -         cur.pvFriendsList = list;
  45. 43.  -         Phototag.cacheFriends();
  46. 44.  -         Phototag.updateFriends();
  47. 45.  -       }});
  48. 46.  -     } else {
  49. 47.  -       cur.pvFriendsQ = false;
  50. 48.  -       Phototag.updateFriends();
  51. 49.  -     }
  52. 50.  -     cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  53. 51.  -     cur.pvTagInfo.innerHTML = '<div class="msg"><a class="fl_r" onclick="Phototag.stopTag()">' + getLang('global_done') + '</a>' + getLang('photos_select_tag_area') + '</div>';
  54. 52.  -     show(cur.pvTagInfo);
  55. 53.  -     hide(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  56. 54.  -     Photoview.updateHeight();
  57. 55.  -
  58. 56.  -     layerWrap.scrollTop = 0;
  59. 57.  -     cur.pvTagger = 'loading';
  60. 58.  -
  61. 59.  -     if (!cur.pvTagger) return;
  62. 60.  -     var options = {
  63. 61.  -       minw: 30,
  64. 62.  -       minh: 30,
  65. 63.  -       onStart: (browser.msie || browser.mozilla) ? hide.pbind(cur.pvFriends) : fadeOut.pbind(cur.pvFriends, 200),
  66. 64.  -       onFinish: Phototag.showFriends
  67. 65.  -     }, ph = cur.pvData[cur.pvListId][cur.pvIndex];
  68. 66.  -
  69. 67.  -     cur.pvTagger = photoTagger(cur.pvPhoto.firstChild, extend(options, {
  70. 68.  -       zstart: 600
  71. 69.  -     }));
  72. 70.  -   },
  73. 71.  -   stopTag: function() {
  74. 72.  -     if (!cur.pvTagger || cur.pvTagger == 'loading') {
  75. 73.  -       cur.pvTagger = false;
  76. 74.  -       return;
  77. 75.  -     }
  78. 76.  -     hide(cur.pvFriends, cur.pvTagInfo);
  79. 77.  -     if (cur.pvListId && cur.pvData[cur.pvListId].length > 1) {
  80. 78.  -       show(cur.pvLeft, cur.pvClose, cur.pvLeftNav, cur.pvRightNav);
  81. 79.  -     }
  82. 80.  -     Photoview.updateHeight();
  83. 81.  -     if (cur.pvFriendName) {
  84. 82.  -       cur.pvFriendName.value = '';
  85. 83.  -       cur.pvFriendsQ = false;
  86. 84.  -       Phototag.updateFriends();
  87. 85.  -     }
  88. 86.  -     cur.pvTagger.destroy();
  89. 87.  -     cur.pvTagger = false;
  90. 88.  -   },
  91. 89.  -   addTag: function(mid, ev) {
  92. 90.  -     if (checkEvent(ev)) return true;
  93. 91.  -     if (!cur.pvTagger || cur.pvTagger == 'loading') return false;
  94. 92.  -     if (isVisible('pv_tag_progress')) return false;
  95. 93.  -
  96. 94.  -     var name = trim(cur.pvFriendName.value), rect = cur.pvTagger.result();
  97. 95.  -     if (!mid) {
  98. 96.  -       var list = cur.pvFriendsCont;
  99. 97.  -       if (name && list.firstChild && list.firstChild == list.lastChild && list.firstChild.tagName.toLowerCase() == 'a') {
  100. 98.  -         mid = list.firstChild.getAttribute('mid');
  101. 99.  -       }
  102. 100.  -     }
  103. 101.  -     if (!mid && !name || !rect[2]) {
  104. 102.  -       elfocus(cur.pvFriendName);
  105. 103.  -       return false;
  106. 104.  -     }
  107. 105.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  108. 106.  -     var xy = getSize(cur.pvPhoto.firstChild);
  109. 107.  -     var x = (rect[0] / xy[0] * 100), y = (rect[1] / xy[1] * 100);
  110. 108.  -     var x2 = ((rect[0] + rect[2]) / xy[0] * 100), y2 = ((rect[1] + rect[3]) / xy[1] * 100);
  111. 109.  -     ajax.post('al_photos.php', {act: 'add_tag', mid: mid, photo: ph.id, name: name, hash: ph.hash, x: x, y: y, x2: x2, y2: y2}, {onDone: function(tags, tagged, html) {
  112. 110.  -       ph.tags = tags;
  113. 111.  -       ph.tagged = tagged;
  114. 112.  -       ph.tagshtml = html;
  115. 113.  -       if (cur.pvListId == listId && cur.pvIndex == index) {
  116. 114.  -         re(Photoview.actionInfo());
  117. 115.  -         Photoview.setTags(html);
  118. 116.  -         ((!ph.taginfo && ph.actions.tag && tags[0] < cur.pvMaxTags) ? show : hide)(cur.pvTagLink);
  119. 117.  -         var resetFr = function() {
  120. 118.  -           cur.pvFriendName.value = '';
  121. 119.  -           Phototag.updateFriends();
  122. 120.  -         }
  123. 121.  -         if (browser.msie || browser.mozilla) {
  124. 122.  -           hide(cur.pvFriends);
  125. 123.  -           resetFr();
  126. 124.  -         } else {
  127. 125.  -           fadeOut(cur.pvFriends, 200, resetFr);
  128. 126.  -         }
  129. 127.  -         cur.pvTagger.reset();
  130. 128.  -       }
  131. 129.  -     }, showProgress: function() {
  132. 130.  -       hide('pv_tag_buttons');
  133. 131.  -       show('pv_tag_progress');
  134. 132.  -     }, hideProgress: function() {
  135. 133.  -       hide('pv_tag_progress');
  136. 134.  -       show('pv_tag_buttons');
  137. 135.  -     }});
  138. 136.  -     return false;
  139. 137.  -   },
  140. 138.  -
  141. 139.  -   updateFriends: function() {
  142. 140.  -     if (!cur.pvFriendsList || !cur.pvFriends) return;
  143. 141.  -
  144. 142.  -     var q = trim(cur.pvFriendName.value).toLowerCase().replace(/[]/, '�'), frs = [];
  145. 143.  -     if (q === cur.pvFriendsQ) return;
  146. 144.  -
  147. 145.  -     cur.pvFriendsQ = q;
  148. 146.  -     var lat = parseLatin(q);
  149. 147.  -     var toMatch = lat ? [escapeRE(q), escapeRE(lat)] : (q ? [escapeRE(q)] : false);
  150. 148.  -
  151. 149.  -     if (q.length > 1 && !cur.pvFriendsCache[q] || q.length == 1 && lat) {
  152. 150.  -       Phototag.cacheFriends(q);
  153. 151.  -     }
  154. 152.  -     var friends = q ? cur.pvFriendsCache[q] : cur.pvFriendsList, tagged = cur.pvData[cur.pvListId][cur.pvIndex].tagged;
  155. 153.  -
  156. 154.  -     for (var i in friends) {
  157. 155.  -       var fr = cur.pvFriendsList[i], mid = positive(i), name = fr[1];
  158. 156.  -       if (tagged[mid]) continue;
  159. 157.  -       if (toMatch) {
  160. 158.  -         each(toMatch, function() {
  161. 159.  -           var re = new RegExp('(?![^&;]+;)(?!<[^<>]*)(' + this + ')(?![^<>]*>)(?![^&;]+;)', 'gi');
  162. 160.  -           name = name.replace(re, '<em>$1</em>');
  163. 161.  -         });
  164. 162.  -       }
  165. 163.  -       frs.push('<a mid="' + mid + '" href="' + fr[0] + '" onclick="return Phototag.addTag(' + mid + ', event)">' + name + '</a>');
  166. 164.  -     }
  167. 165.  -     var st = (frs.length > 8) ? {height: '184px', overflow: 'auto'} : {height: '', overflow: ''};
  168. 166.  -     setStyle(cur.pvFriendsCont.parentNode, st);
  169. 167.  -     cur.pvFriendsCont.innerHTML = frs.join('');
  170. 168.  -     (q && !frs.length ? hide : show)(cur.pvFriendsCont.parentNode);
  171. 169.  -     (q || tagged[vk.id] ? hide : show)(cur.pvFriendsCont.parentNode.firstChild);
  172. 170.  -   },
  173. 171.  -   cacheFriends: function(q) {
  174. 172.  -     if (q) {
  175. 173.  -       if (!cur.pvFriendsCache[q]) cur.pvFriendsCache[q] = {};
  176. 174.  -
  177. 175.  -       var t = parseLatin(q);
  178. 176.  -       var queries = t ? [q, t] : [q];
  179. 177.  -       for (var i in queries) {
  180. 178.  -         query = queries[i];
  181. 179.  -         var searchIn = cur.pvFriendsCache[query.substr(0, 1).toLowerCase()];
  182. 180.  -         if (searchIn) {
  183. 181.  -           query = escapeRE(query);
  184. 182.  -           for (var i in searchIn) {
  185. 183.  -             var name = cur.pvFriendsList[i][1].replace(/[��]/, '�');
  186. 184.  -             if ((new RegExp('^' + query + '|\\s' + query + '|\\(' + query, 'gi')).test(name)) {
  187. 185.  -               cur.pvFriendsCache[q][i] = 1;
  188. 186.  -             }
  189. 187.  -           }
  190. 188.  -         }
  191. 189.  -       }
  192. 190.  -       return;
  193. 191.  -     }
  194. 192.  -     cur.pvFriendsCache = {};
  195. 193.  -     for (var i in cur.pvFriendsList) {
  196. 194.  -       var name = cur.pvFriendsList[i][1].replace(/[��]/, '�');
  197. 195.  -       var cursor = 0, letter;
  198. 196.  -       while (1) {
  199. 197.  -         letter = name.charAt(cursor).toLowerCase();
  200. 198.  -         if (!cur.pvFriendsCache[letter]) {
  201. 199.  -           cur.pvFriendsCache[letter] = {};
  202. 200.  -         }
  203. 201.  -         cur.pvFriendsCache[letter][i] = 1;
  204. 202.  -         cursor = name.indexOf(' ', cursor + 1);
  205. 203.  -         if (cursor == -1) break;
  206. 204.  -         ++cursor;
  207. 205.  -       }
  208. 206.  -     }
  209. 207.  -   },
  210. 208.  -   showFriends: function() {
  211. 209.  -     if (!cur.pvTagger || cur.pvTagger == 'loading') return;
  212. 210.  -
  213. 211.  -     var r = cur.pvTagger.result();
  214. 212.  -     var xy = getXY(cur.pvPhoto.firstChild), x = xy[0] + r[0] + r[2] + 20;
  215. 213.  -     if (lastWindowWidth <= x + 190 + sbWidth() + 5) {
  216. 214.  -       if (xy[0] + r[0] <= 190 + 25) {
  217. 215.  -         x = lastWindowWidth - 190 - sbWidth() - 5;
  218. 216.  -       } else {
  219. 217.  -         x = xy[0] + r[0] - 190 - 20;
  220. 218.  -       }
  221. 219.  -     }
  222. 220.  -     var h = getSize(cur.pvFriends)[1], y = xy[1] + layerWrap.scrollTop + r[1] - ((layerWrap.offsetParent || {}).scrollTop || bodyNode.scrollTop || htmlNode.scrollTop);
  223. 221.  -     if (layerWrap.scrollTop + lastWindowHeight <= y + h + 5) {
  224. 222.  -       y = layerWrap.scrollTop + lastWindowHeight - h - 5;
  225. 223.  -     }
  226. 224.  -     cur.pvFriends.style.left = x + 'px';
  227. 225.  -     cur.pvFriends.style.top = y + 'px';
  228. 226.  -     if (!isVisible(cur.pvFriends)) {
  229. 227.  -       if (browser.msie || browser.mozilla) {
  230. 228.  -         show(cur.pvFriends);
  231. 229.  -         setTimeout(elfocus.pbind(cur.pvFriendName, false, false), 1);
  232. 230.  -       } else {
  233. 231.  -         fadeIn(cur.pvFriends, 200, function() {
  234. 232.  -           setTimeout(elfocus.pbind(cur.pvFriendName, false, false), 1);
  235. 233.  -         });
  236. 234.  -       }
  237. 235.  -     } else {
  238. 236.  -       animate(cur.pvFriends, {opacity: 1}, 200, function() {
  239. 237.  -         setTimeout(elfocus.pbind(cur.pvFriendName, false, false), 1);
  240. 238.  -       });
  241. 239.  -     }
  242. 240.  -   }
  243. 241.  - };
  244. 242.  -
  245. 243.  - try{stManager.done('phototag.js');}catch(e){}
  246. ------
Advertisement
Add Comment
Please, Sign In to add comment