Hormold

VK Change (#1383306309)

Nov 1st, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 104.69 KB | None | 0 0
  1. Файл - ads.js (Старый размер - 83798 | Новый - 0):
  2. 0.  - var Ads = {};
  3. 1.  -
  4. 2.  - Ads.init = function() {
  5. 3.  -   showBackLink();
  6. 4.  - }
  7. 5.  -
  8. 6.  - Ads.initOfficesMenu = function(event) {
  9. 7.  -
  10. 8.  -   if (!window.DropdownMenu || !cur.mainNavigationOfficesItems) {
  11. 9.  -     return;
  12. 10.  -   }
  13. 11.  -
  14. 12.  -   if (cur.navigationOficesMenu) {
  15. 13.  -     return;
  16. 14.  -   }
  17. 15.  -
  18. 16.  -   ge('ads_navigation_offices_menu').removeAttribute('onmouseover');
  19. 17.  -
  20. 18.  -   function hideMenu() {
  21. 19.  -     cur.navigationOficesMenu.hide();
  22. 20.  -   }
  23. 21.  -
  24. 22.  -   var realLocation = '';
  25. 23.  -   if (location.hash.indexOf('#/') != -1 || location.hash.indexOf('#!') != -1) {
  26. 24.  -     realLocation = location.hash.replace('#/', '').replace('#!', '');
  27. 25.  -   } else {
  28. 26.  -     realLocation = location.pathname + location.search;
  29. 27.  -   }
  30. 28.  -
  31. 29.  -   var unionId;
  32. 30.  -   var unionIdReal;
  33. 31.  -   var unionIdParam = '';
  34. 32.  -   var curItems = [];
  35. 33.  -   for (var i in cur.mainNavigationOfficesItems) {
  36. 34.  -     curItems[i] = {};
  37. 35.  -     curItems[i].onClick = hideMenu;
  38. 36.  -     for (var j in cur.mainNavigationOfficesItems[i]) {
  39. 37.  -       curItems[i][j] = cur.mainNavigationOfficesItems[i][j];
  40. 38.  -     }
  41. 39.  -     if (curItems[i].i == 'all') {
  42. 40.  -       curItems[i].h = "/ads?act=offices_list";
  43. 41.  -     } else {
  44. 42.  -       unionId = '';
  45. 43.  -       unionIdReal = intval(curItems[i].i);
  46. 44.  -       unionIdParam = '';
  47. 45.  -       if (curItems[i].i.indexOf('default') == -1) {
  48. 46.  -         unionId = unionIdReal;
  49. 47.  -         unionIdParam = "&union_id=" + unionIdReal;
  50. 48.  -       }
  51. 49.  -
  52. 50.  -       var link = "/ads?act=office" + unionIdParam;
  53. 51.  -       if (!unionIdReal) {
  54. 52.  -         link = "/ads?act=no_office";
  55. 53.  -       } else if (cur.getOfficeLink) {
  56. 54.  -         link = cur.getOfficeLink(unionId);
  57. 55.  -       } else if (realLocation.match(/act=budget(&|$)/)) {
  58. 56.  -         link = "/ads?act=budget" + unionIdParam;
  59. 57.  -       } else if (realLocation.match(/act=export_stats(&|$)/)) {
  60. 58.  -         link = "/ads?act=export_stats" + unionIdParam;
  61. 59.  -       } else if (realLocation.match(/act=settings(&|$)/)) {
  62. 60.  -         link = "/ads?act=settings" + unionIdParam;
  63. 61.  -       }
  64. 62.  -
  65. 63.  -       curItems[i].h = link;
  66. 64.  -     }
  67. 65.  -   }
  68. 66.  -
  69. 67.  -   var options = {
  70. 68.  -     title: '<span id="ads_navigation_dd_menu_header_text">' + ge('ads_navigation_offices_menu_text').innerHTML + '</span>',
  71. 69.  -     containerClass: 'ads_navigation_dd_menu_header_wrap',
  72. 70.  -     target: ge('ads_navigation_offices_menu'),
  73. 71.  -     showHover: false,
  74. 72.  -     updateTarget: false,
  75. 73.  -     onSelect: function(e) {
  76. 74.  -     }
  77. 75.  -   };
  78. 76.  -   cur.navigationOficesMenu = new DropdownMenu(curItems, options);
  79. 77.  -   cur.destroy.push(function(){ cur.navigationOficesMenu.destroy(); });
  80. 78.  - }
  81. 79.  -
  82. 80.  - Ads.lock = function(lockKey, onLock, onUnlock) {
  83. 81.  -   if (!cur.locks) {
  84. 82.  -     cur.locks = {};
  85. 83.  -   }
  86. 84.  -   if (cur.locks[lockKey]) {
  87. 85.  -     return false;
  88. 86.  -   }
  89. 87.  -   cur.locks[lockKey] = {onLock: onLock, onUnlock: onUnlock};
  90. 88.  -   if (isFunction(cur.locks[lockKey].onLock)) {
  91. 89.  -     cur.locks[lockKey].onLock();
  92. 90.  -   }
  93. 91.  -   return true;
  94. 92.  - }
  95. 93.  -
  96. 94.  - Ads.unlock = function(lockKey) {
  97. 95.  -   if (!cur.locks) {
  98. 96.  -     cur.locks = {};
  99. 97.  -   }
  100. 98.  -   if (cur.locks[lockKey] && isFunction(cur.locks[lockKey].onUnlock)) {
  101. 99.  -     cur.locks[lockKey].onUnlock();
  102. 100.  -   }
  103. 101.  -   delete cur.locks[lockKey];
  104. 102.  - }
  105. 103.  -
  106. 104.  - Ads.simpleAjax = function(url, elem) {
  107. 105.  -   if (elem) {
  108. 106.  -     var elemRect = elem.getBoundingClientRect();
  109. 107.  -     var imgTop   = (elemRect.bottom - elemRect.top - 8) / 2;
  110. 108.  -     var span     = ce('span', {}, {position: 'relative'})
  111. 109.  -     var img      = ce('img', {src:'/images/upload.gif'}, {position: 'absolute', top: imgTop + 'px'});
  112. 110.  -     span.appendChild(img);
  113. 111.  -     elem.appendChild(span);
  114. 112.  -   }
  115. 113.  -
  116. 114.  -   ajax.post(url, {}, {onDone: onComplete, onFail: onComplete});
  117. 115.  -   function onComplete(response) {
  118. 116.  -     if (elem) {
  119. 117.  -       elem.removeChild(span);
  120. 118.  -     }
  121. 119.  -     if (response && response.html) {
  122. 120.  -       var boxOptions = {};
  123. 121.  -       boxOptions.title  = '���������';
  124. 122.  -       boxOptions.onHide = nav.reload;
  125. 123.  -       showFastBox(boxOptions, response.html);
  126. 124.  -     } else {
  127. 125.  -       nav.reload();
  128. 126.  -     }
  129. 127.  -     return true;
  130. 128.  -   }
  131. 129.  - }
  132. 130.  -
  133. 131.  - Ads.escapeValue = function(value) {
  134. 132.  -   return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  135. 133.  - }
  136. 134.  -
  137. 135.  - Ads.onInputEvent = function(event, func) {
  138. 136.  -   if (event.keyCode == KEY.RETURN) {
  139. 137.  -     func();
  140. 138.  -     return false;
  141. 139.  -   }
  142. 140.  -   return true;
  143. 141.  - }
  144. 142.  -
  145. 143.  - Ads.onSubLinkEvent = function(event) {
  146. 144.  -   event = normEvent(event);
  147. 145.  -   var elem = event.target
  148. 146.  -   var newLink = elem.getAttribute('href_');
  149. 147.  -   if (!newLink) {
  150. 148.  -     return;
  151. 149.  -   }
  152. 150.  -   var linkElem = elem;
  153. 151.  -   while (linkElem && linkElem.nodeName !== 'A') {
  154. 152.  -     linkElem = linkElem.parentNode;
  155. 153.  -   }
  156. 154.  -   if (!linkElem) {
  157. 155.  -     return;
  158. 156.  -   }
  159. 157.  -   if (event.type === 'mouseover') {
  160. 158.  -     elem.setAttribute('href_old', linkElem.href);
  161. 159.  -     linkElem.href = newLink;
  162. 160.  -   } else if (event.type === 'mouseout') {
  163. 161.  -     var oldLink = elem.getAttribute('href_old');
  164. 162.  -     if (oldLink) {
  165. 163.  -       linkElem.href = oldLink;
  166. 164.  -     } else {
  167. 165.  -       linkElem.removeAttribute('href');
  168. 166.  -     }
  169. 167.  -   }
  170. 168.  - }
  171. 169.  -
  172. 170.  - Ads.onBoxFail = function(message) {
  173. 171.  -   if (!message) {
  174. 172.  -     message = getLang('global_unknown_error');
  175. 173.  -   }
  176. 174.  -   setTimeout(function(){
  177. 175.  -     showFastBox(getLang('ads_error_box_title'), message);
  178. 176.  -   }, 1);
  179. 177.  -   return true;
  180. 178.  - }
  181. 179.  -
  182. 180.  - Ads.setLoginHandlers = function(onLoginDoneNew, onLoginFailedNew) {
  183. 181.  -   var restoreOnLoginDone = function(handler) {
  184. 182.  -     if (cur.onLoginDoneWindowOld && window.onLoginDone == handler) {
  185. 183.  -       window.onLoginDone = cur.onLoginDoneWindowOld;
  186. 184.  -       delete cur.onLoginDoneWindowOld;
  187. 185.  -     }
  188. 186.  -   }
  189. 187.  -   var restoreOnLoginFailed = function(handler) {
  190. 188.  -     if (cur.onLoginFailedWindowOld && window.onLoginFailed == handler) {
  191. 189.  -       window.onLoginFailed = cur.onLoginFailedWindowOld;
  192. 190.  -       delete cur.onLoginFailedWindowOld;
  193. 191.  -     }
  194. 192.  -   }
  195. 193.  -
  196. 194.  -   if (onLoginDoneNew) {
  197. 195.  -     if (window.onLoginDone != onLoginDoneNew) {
  198. 196.  -       cur.onLoginDoneWindowOld = window.onLoginDone;
  199. 197.  -       window.onLoginDone = onLoginDoneNew;
  200. 198.  -       cur.destroy.push(restoreOnLoginDone.pbind(onLoginDoneNew));
  201. 199.  -     }
  202. 200.  -   } else {
  203. 201.  -     restoreOnLoginDone(window.onLoginDone);
  204. 202.  -   }
  205. 203.  -
  206. 204.  -   if (onLoginFailedNew) {
  207. 205.  -     if (window.onLoginFailed != onLoginFailedNew) {
  208. 206.  -       cur.onLoginFailedWindowOld = window.onLoginFailed;
  209. 207.  -       window.onLoginFailed = onLoginFailedNew;
  210. 208.  -       cur.destroy.push(restoreOnLoginFailed.pbind(onLoginFailedNew));
  211. 209.  -     }
  212. 210.  -   } else {
  213. 211.  -     restoreOnLoginFailed(window.onLoginFailed);
  214. 212.  -   }
  215. 213.  - }
  216. 214.  -
  217. 215.  - Ads.scrollToError = function(errorElem) {
  218. 216.  -   errorElem = ge(errorElem);
  219. 217.  -   var scrollY = scrollGetY();
  220. 218.  -   var errorY = getXY(errorElem)[1];
  221. 219.  -   if (errorY < scrollY || errorY > (scrollY + lastWindowHeight / 2)) {
  222. 220.  -     errorY -= 15;
  223. 221.  -     scrollToY(errorY);
  224. 222.  -   }
  225. 223.  - }
  226. 224.  -
  227. 225.  - Ads.initFixed = function(elemWrap) {
  228. 226.  -   elemWrap = ge(elemWrap);
  229. 227.  -   if (!elemWrap) return;
  230. 228.  -   var elemFixed = elemWrap.firstChild;
  231. 229.  -   if (!elemFixed) return;
  232. 230.  -
  233. 231.  -   var scrolledNode = browser.msie6 ? pageNode : window;
  234. 232.  -   addEvent(scrolledNode, 'scroll', onScroll);
  235. 233.  -   cur.destroy.push(function() { removeEvent(scrolledNode, 'scroll', onScroll); });
  236. 234.  -
  237. 235.  -   var poistionTop = 20;
  238. 236.  -
  239. 237.  -   var elemWrapSize = getSize(elemWrap);
  240. 238.  -   setStyle(elemWrap, {width: elemWrapSize[0] + 'px', height: elemWrapSize[1] + 'px'});
  241. 239.  -
  242. 240.  -   onScroll();
  243. 241.  -
  244. 242.  -   function onScroll() {
  245. 243.  -     var elemWrapXY = getXY(elemWrap);
  246. 244.  -     var scrollY = scrollGetY();
  247. 245.  -     if (scrollY + poistionTop < elemWrapXY[1]) {
  248. 246.  -       setStyle(elemFixed, {position: 'static', top: 'auto', left: 'auto'});
  249. 247.  -     } else {
  250. 248.  -       setStyle(elemFixed, {position: 'fixed', top: poistionTop, left: elemWrapXY[0]});
  251. 249.  -     }
  252. 250.  -   }
  253. 251.  - }
  254. 252.  -
  255. 253.  - //////////////////////////////////////////////////////////////////////
  256. 254.  - // OLD
  257. 255.  - //////////////////////////////////////////////////////////////////////
  258. 256.  -
  259. 257.  - Ads.updateUnionName = function(unionId, unionName) {
  260. 258.  -   var elemsTitle = geByClass('title_union_name_' + unionId);
  261. 259.  -   for (var i in elemsTitle) {
  262. 260.  -     elemsTitle[i].innerHTML = Ads.escapeValue(unionName);
  263. 261.  -   }
  264. 262.  -
  265. 263.  -   var elemNavigation = ge('ads_navigation_union_' + unionId);
  266. 264.  -   if (elemNavigation) {
  267. 265.  -     unionName = replaceEntities(unionName);
  268. 266.  -     unionName = (unionName.length > 40 ? unionName.substr(0, 40) + '...' : unionName);
  269. 267.  -     elemNavigation.innerHTML = Ads.escapeValue(unionName);
  270. 268.  -   }
  271. 269.  -
  272. 270.  -   var elemGeneralInfoHeader = ge('general_info_header_name_' + unionId);
  273. 271.  -   if (elemGeneralInfoHeader) {
  274. 272.  -     elemGeneralInfoHeader.innerHTML = Ads.escapeValue(unionName);
  275. 273.  -   }
  276. 274.  - }
  277. 275.  -
  278. 276.  - Ads.openUnionsGeneralInfoBox = function(unionId, params) {
  279. 277.  -   var ajaxParams = {};
  280. 278.  -   ajaxParams.union_id = unionId;
  281. 279.  -   ajaxParams = extend({}, ajaxParams, params);
  282. 280.  -
  283. 281.  -   var showOptions = {params: {}};
  284. 282.  -   showOptions.onFail = Ads.onBoxFail;
  285. 283.  -   showOptions.params.width = 300;
  286. 284.  -
  287. 285.  -   showBox('/ads?act=a_unions_general_info_box', ajaxParams, showOptions);
  288. 286.  - }
  289. 287.  -
  290. 288.  - Ads.openUnionCreateBox = function(unionId) {
  291. 289.  -   var ajaxParams = {}
  292. 290.  -   ajaxParams.union_id = unionId;
  293. 291.  -
  294. 292.  -   var showOptions = {params: {}};
  295. 293.  -   showOptions.onFail = Ads.onBoxFail;
  296. 294.  -   showOptions.params.width = 250;
  297. 295.  -
  298. 296.  -   showBox('/ads?act=a_union_create_box', ajaxParams, showOptions);
  299. 297.  - }
  300. 298.  -
  301. 299.  - Ads.openDeleteUnionBox = function(unionType, unionId, hash, lock, unlock, updateStatus, newclass) {
  302. 300.  -   var boxTitle = '';
  303. 301.  -   var boxContent = '';
  304. 302.  -   switch (unionType) {
  305. 303.  -     case 'ad':
  306. 304.  -       boxTitle = getLang('ads_archive_box_ad_title');
  307. 305.  -       boxContent = getLang('ads_archive_box_ad_warning');
  308. 306.  -       break;
  309. 307.  -     case 'campaign':
  310. 308.  -       boxTitle = getLang('ads_archive_box_campaign_title');
  311. 309.  -       boxContent = getLang('ads_archive_box_campaign_warning');
  312. 310.  -       break;
  313. 311.  -     case 'client':
  314. 312.  -       boxTitle = getLang('ads_archive_box_client_title');
  315. 313.  -       boxContent = getLang('ads_archive_box_client_warning');
  316. 314.  -       break;
  317. 315.  -   }
  318. 316.  -
  319. 317.  -   var boxOptions = {};
  320. 318.  -   boxOptions.title = boxTitle;
  321. 319.  -   boxOptions.bodyStyle = 'line-height: 160%;';
  322. 320.  -
  323. 321.  -   cur.deleteConfirmBox = new MessageBox();
  324. 322.  -   cur.deleteConfirmBox.setOptions(boxOptions);
  325. 323.  -   cur.deleteConfirmBox.content(boxContent);
  326. 324.  -   cur.deleteConfirmBox.removeButtons();
  327. 325.  -   cur.deleteConfirmBox.addButton(getLang('box_cancel'), false, 'no');
  328. 326.  -   cur.deleteConfirmBox.addButton(getLang('ads_archive_box_action'), function() { Ads.deleteUnion(unionType, unionId, hash, lock, unlock, updateStatus, newclass); });
  329. 327.  -   cur.deleteConfirmBox.setControlsText('<img id="delete_union_progress" src="/images/upload.gif" style="top: 1px; display: none;">');
  330. 328.  -   cur.deleteConfirmBox.show();
  331. 329.  - }
  332. 330.  -
  333. 331.  - Ads.deleteUnion = function(unionType, unionId, hash, lock, unlock, updateStatus, newclass) {
  334. 332.  -   if (!lockDeletion()) {
  335. 333.  -     return;
  336. 334.  -   }
  337. 335.  -
  338. 336.  -   var ajaxParams = {};
  339. 337.  -   ajaxParams.union_id = unionId;
  340. 338.  -   ajaxParams.hash = hash;
  341. 339.  -   if (newclass) ajaxParams.newclass = 1;
  342. 340.  -
  343. 341.  -   ajax.post('/ads?act=a_union_delete', ajaxParams, {onDone: onRequestComplete, onFail: onRequestComplete});
  344. 342.  -
  345. 343.  -   function onRequestComplete(response) {
  346. 344.  -     unlockDeletion();
  347. 345.  -     if (!isObject(response) || response.error) {
  348. 346.  -       if (!isObject(response)) {
  349. 347.  -         showMessage(getLang('ads_error_unexpected_error_try_later'));
  350. 348.  -       } else {
  351. 349.  -         showMessage(response.error);
  352. 350.  -       }
  353. 351.  -       return true;
  354. 352.  -     }
  355. 353.  -     if (response && (response.ok || newclass == 2)) {
  356. 354.  -       var completeMessage = '';
  357. 355.  -       switch (unionType) {
  358. 356.  -         case 'ad':       completeMessage = getLang('ads_archive_box_ad_complete'); break;
  359. 357.  -         case 'campaign': completeMessage = getLang('ads_archive_box_campaign_complete'); break;
  360. 358.  -         case 'client':   completeMessage = getLang('ads_archive_box_client_complete'); break;
  361. 359.  -       }
  362. 360.  -       if (updateStatus) {
  363. 361.  -         if (newclass == 2) {
  364. 362.  -           updateStatus(response);
  365. 363.  -         } else {
  366. 364.  -           updateStatus(response.status, response.status_class, response.status_type, response.status_variants);
  367. 365.  -         }
  368. 366.  -       } else {
  369. 367.  -         showMessage(completeMessage, true, function() { nav.reload(); }, unionType);
  370. 368.  -       }
  371. 369.  -     }
  372. 370.  -     return true;
  373. 371.  -   }
  374. 372.  -
  375. 373.  -   function showMessage(message, isSuccess, onHide, unionType) {
  376. 374.  -     var boxTitle = '';
  377. 375.  -     switch (unionType) {
  378. 376.  -       case 'ad':       boxTitle = getLang('ads_archive_box_ad_title'); break;
  379. 377.  -       case 'campaign': boxTitle = getLang('ads_archive_box_campaign_title'); break;
  380. 378.  -       case 'client':   boxTitle = getLang('ads_archive_box_client_title'); break;
  381. 379.  -     }
  382. 380.  -
  383. 381.  -     var boxOptions = {};
  384. 382.  -     boxOptions.title = (isSuccess ? boxTitle : '������');
  385. 383.  -     boxOptions.width = 350;
  386. 384.  -     boxOptions.onHide = onHide;
  387. 385.  -     showFastBox(boxOptions, message);
  388. 386.  -   }
  389. 387.  -
  390. 388.  -   function lockDeletion() {
  391. 389.  -     if (lock) {
  392. 390.  -       if (!lock()) {
  393. 391.  -         return false;
  394. 392.  -       }
  395. 393.  -       cur.deleteConfirmBox.hide();
  396. 394.  -     } else {
  397. 395.  -       if (cur.deleteUnionLocked) {
  398. 396.  -         return false;
  399. 397.  -       }
  400. 398.  -       cur.deleteUnionLocked = true;
  401. 399.  -       show('delete_union_progress');
  402. 400.  -     }
  403. 401.  -     return true;
  404. 402.  -   }
  405. 403.  -   function unlockDeletion() {
  406. 404.  -     if (unlock) {
  407. 405.  -       unlock()
  408. 406.  -     } else {
  409. 407.  -       cur.deleteUnionLocked = false;
  410. 408.  -       hide('delete_union_progress');
  411. 409.  -     }
  412. 410.  -   }
  413. 411.  - }
  414. 412.  -
  415. 413.  - Ads.openHelpBox = function(type, unionId) {
  416. 414.  -   var ajaxParams = {}
  417. 415.  -   ajaxParams.type = type;
  418. 416.  -   ajaxParams.union_id = unionId;
  419. 417.  -
  420. 418.  -   var showOptions = {params: {}};
  421. 419.  -   showOptions.onFail = Ads.onBoxFail;
  422. 420.  -   showOptions.cache = 1;
  423. 421.  -   showOptions.params.width = 450;
  424. 422.  -
  425. 423.  -   showBox('/ads?act=a_help_text', ajaxParams, showOptions);
  426. 424.  - }
  427. 425.  -
  428. 426.  - Ads.openCreateOfficeBox = function() {
  429. 427.  -   var ajaxParams = {};
  430. 428.  -
  431. 429.  -   var showOptions = {params: {}};
  432. 430.  -   showOptions.onFail = Ads.onBoxFail;
  433. 431.  -   showOptions.params.width = 350;
  434. 432.  -
  435. 433.  -   showBox('/ads?act=a_create_office_box', ajaxParams, showOptions);
  436. 434.  - }
  437. 435.  -
  438. 436.  - Ads.openDisableOfficeBox = function(unionId, hash, isCompany) {
  439. 437.  -   cur.lang.ads_disable_office_box_title       = '�������� ���������� ��������';
  440. 438.  -   cur.lang.ads_disable_office_box_button      = '������� �������';
  441. 439.  -   cur.lang.ads_disable_office_confirm_message = '�� ������� ��� ������ ������� ��������� �������?<br><br>����� �������� �������� � ��� ��������� ������ � ����������, �� ����� �������� �������� ����� ����������.';
  442. 440.  -   if (isCompany) {
  443. 441.  -     cur.lang.ads_disable_office_confirm_message += '<br><br>������ ����� �������� �������� ���� �������� ������ ���������� �����, ������������ � ����� ��������.';
  444. 442.  -   }
  445. 443.  -   var messageBox = showFastBox(getLang('ads_disable_office_box_title'), getLang('ads_disable_office_confirm_message'), getLang('ads_disable_office_box_button'), function() { Ads.disableOffice(unionId, hash, messageBox); }, getLang('box_cancel'));
  446. 444.  - }
  447. 445.  -
  448. 446.  - Ads.disableOffice = function(unionId, hash, box) {
  449. 447.  -   var ajaxParams = {};
  450. 448.  -   ajaxParams.union_id = unionId;
  451. 449.  -   ajaxParams.hash = hash;
  452. 450.  -
  453. 451.  -   ajax.post('/adsmoder?act=a_disable_office', ajaxParams, {onDone: onRequestComplete, onFail: onRequestComplete});
  454. 452.  -
  455. 453.  -   function onRequestComplete(response) {
  456. 454.  -     if (response && response.redirect) {
  457. 455.  -       nav.reload();
  458. 456.  -     } else {
  459. 457.  -       box.hide();
  460. 458.  -       showFastBox(getLang('ads_error_box_title'), getLang('ads_error_text'));
  461. 459.  -     }
  462. 460.  -     return true;
  463. 461.  -   }
  464. 462.  - }
  465. 463.  -
  466. 464.  - Ads.createExportSubmitButton = function(elem, bindingId, topUnionId) {
  467. 465.  -   var postIframe = ce((browser.msie && browser.version < 9.0) ? '<iframe name="secret_iframe">' : 'iframe', {name: 'secret_iframe', id: 'secret_iframe'});
  468. 466.  -   postIframe.style.display = 'none';
  469. 467.  -   document.body.appendChild(postIframe);
  470. 468.  -   var topUnionIdParam = (topUnionId ? '&union_id=' + topUnionId : '');
  471. 469.  -   var postForm = ce('form', {method: 'post', action: '/ads?act=get_export_stats' + topUnionIdParam, target: 'secret_iframe'});
  472. 470.  -   document.body.appendChild(postForm);
  473. 471.  -   var valueNames = [
  474. 472.  -     'group_time',
  475. 473.  -     'group_ads',
  476. 474.  -     'method',
  477. 475.  -     'stats_type',
  478. 476.  -     'from_day',
  479. 477.  -     'from_month',
  480. 478.  -     'from_year',
  481. 479.  -     'to_day',
  482. 480.  -     'to_month',
  483. 481.  -     'to_year',
  484. 482.  -     'Ids'
  485. 483.  -   ];
  486. 484.  -   var valueContainers = {};
  487. 485.  -   for (var i = 0; i < valueNames.length; i++) {
  488. 486.  -     var curName = valueNames[i];
  489. 487.  -     valueContainers[curName] = ce('input', {
  490. 488.  -       type: 'hidden',
  491. 489.  -       id: curName + '_container_' + bindingId,
  492. 490.  -       name: curName
  493. 491.  -     });
  494. 492.  -     postForm.appendChild(valueContainers[curName]);
  495. 493.  -   }
  496. 494.  -
  497. 495.  -   var errorBox;
  498. 496.  -   var action = function() {
  499. 497.  -     var postData = {}, elem, day;
  500. 498.  -     elem = geByClass('grouping_time_' + bindingId)[0];
  501. 499.  -     if (!elem) return;
  502. 500.  -     valueContainers.group_time.value = elem.getIndex();
  503. 501.  -
  504. 502.  -     elem = geByClass('grouping_ads_' + bindingId)[0];
  505. 503.  -     if (!elem) return;
  506. 504.  -     valueContainers.group_ads.value = elem.getIndex();
  507. 505.  -
  508. 506.  -     elem = geByClass('client_choose_' + bindingId);
  509. 507.  -     if (elem.length > 0) {
  510. 508.  -       elem = elem[0];
  511. 509.  -       var curClientId = elem.getIndex();
  512. 510.  -     }
  513. 511.  -
  514. 512.  -     elem = geByClass('export_method_' + bindingId)[0];
  515. 513.  -     if (!elem) return;
  516. 514.  -     valueContainers.method.value = elem.getIndex();
  517. 515.  -     if (valueContainers.method.value == 3/*Web-interface*/) {
  518. 516.  -       postForm.target = '';
  519. 517.  -     }
  520. 518.  -
  521. 519.  -     elem = geByClass('stats_type_' + bindingId)[0];
  522. 520.  -     if (!elem) return;
  523. 521.  -     valueContainers.stats_type.value = elem.getIndex();
  524. 522.  -
  525. 523.  -     day = cur.exportParamsData.start_time;
  526. 524.  -     valueContainers.from_day.value = day.day;
  527. 525.  -     valueContainers.from_month.value = day.month;
  528. 526.  -     valueContainers.from_year.value = day.year;
  529. 527.  -
  530. 528.  -     day = cur.exportParamsData.stop_time;
  531. 529.  -     valueContainers.to_day.value = day.day;
  532. 530.  -     valueContainers.to_month.value = day.month;
  533. 531.  -     valueContainers.to_year.value = day.year;
  534. 532.  -
  535. 533.  -     if ((new Date(valueContainers.to_year.value,   valueContainers.to_month.value,   valueContainers.to_day.value)) <
  536. 534.  -         (new Date(valueContainers.from_year.value, valueContainers.from_month.value, valueContainers.from_day.value))) {
  537. 535.  -       showFastBox(getLang('ads_error_box_title'), getLang('ads_error_export_stat_invalid_period'));
  538. 536.  -       return;
  539. 537.  -     }
  540. 538.  -
  541. 539.  -     var ids = [];
  542. 540.  -
  543. 541.  -     elem = ge('paginated_table');
  544. 542.  -     var pt = elem.tableObj;
  545. 543.  -     var selection = pt.getSelection(0);
  546. 544.  -     switch (parseInt(valueContainers.group_ads.value)) {
  547. 545.  -       case 0:
  548. 546.  -         ids.push(elem.topId);
  549. 547.  -         break;
  550. 548.  -       case 1:
  551. 549.  -         for (var j = 0; j < selection.length; j++) {
  552. 550.  -           var clId = pt.content.extra['union_id'][selection[j]];
  553. 551.  -           ids.push(clId);
  554. 552.  -         }
  555. 553.  -         break;
  556. 554.  -       case 2:
  557. 555.  -         if (curClientId == 'aca') {
  558. 556.  -           for (var p in elem.contentDep) {
  559. 557.  -             if (!isNaN(Number(p))) {
  560. 558.  -               for (var i in elem.contentDep[p].extra['union_id']) {
  561. 559.  -                 ids.push(elem.contentDep[p].extra['union_id'][i]);
  562. 560.  -               }
  563. 561.  -             }
  564. 562.  -           }
  565. 563.  -         } else {
  566. 564.  -           for (var i = 0; i < selection.length; i++) {
  567. 565.  -             ids.push(pt.content.extra['union_id'][selection[i]]);
  568. 566.  -           }
  569. 567.  -         }
  570. 568.  -         break;
  571. 569.  -       case 3:
  572. 570.  -         for (var i = 0; i < selection.length; i++) {
  573. 571.  -           ids.push(pt.content.extra['union_id'][selection[i]]);
  574. 572.  -         }
  575. 573.  -         break;
  576. 574.  -       default:
  577. 575.  -         return;
  578. 576.  -     }
  579. 577.  -
  580. 578.  -     if (ids.length == 0) {
  581. 579.  -       showFastBox(getLang('ads_error_box_title'), getLang('ads_error_export_stat_no_campaigns_selected'));
  582. 580.  -       return;
  583. 581.  -
  584. 582.  -     }
  585. 583.  -
  586. 584.  -     valueContainers.Ids.value = '' + ids.join(',');
  587. 585.  -
  588. 586.  -     postForm.submit();
  589. 587.  -   };
  590. 588.  -
  591. 589.  -   createButton(elem, action);
  592. 590.  - }
  593. 591.  -
  594. 592.  - Ads.createStaticDatePicker = function(elem, bindingId, classid, defaultDate) {
  595. 593.  -   elem = ge(elem);
  596. 594.  -   if (classid) elem.className = classid + '_' + bindingId;
  597. 595.  -
  598. 596.  -   var spanDay   = ce('span', {id: elem.id + '_day'}),
  599. 597.  -       spanMonth = ce('span', {id: elem.id + '_month'});
  600. 598.  -
  601. 599.  -   if (!cur.exportParamsData) {
  602. 600.  -     cur.exportParamsData = {};
  603. 601.  -   }
  604. 602.  -   cur.exportParamsData[classid] = defaultDate;
  605. 603.  -
  606. 604.  -   var params = {
  607. 605.  -     mode: 'd',
  608. 606.  -     day: defaultDate.day,
  609. 607.  -     month: defaultDate.month,
  610. 608.  -     year: defaultDate.year,
  611. 609.  -     width: 124,
  612. 610.  -     pastActive: true,
  613. 611.  -     onUpdate: function(d, m) {
  614. 612.  -       if (m == 'h') {
  615. 613.  -         cur.exportParamsData[classid].day = defaultDate.day;
  616. 614.  -         cur.exportParamsData[classid].month = defaultDate.month;
  617. 615.  -         cur.exportParamsData[classid].year = defaultDate.year;
  618. 616.  -         return;
  619. 617.  -       }
  620. 618.  -       if (m == 'd') {
  621. 619.  -         cur.exportParamsData[classid].day = d.d;
  622. 620.  -       } else if (m == 'm') {
  623. 621.  -         cur.exportParamsData[classid].day = 1;
  624. 622.  -       }
  625. 623.  -       cur.exportParamsData[classid].month = d.m;
  626. 624.  -       cur.exportParamsData[classid].year = d.y;
  627. 625.  -     }
  628. 626.  -   };
  629. 627.  -
  630. 628.  -   if (!cur.exportUi) {
  631. 629.  -     cur.exportUi = {};
  632. 630.  -   }
  633. 631.  -   cur.exportUi[classid] = new Datepicker(elem, params);
  634. 632.  - }
  635. 633.  -
  636. 634.  - Ads.openInnerTable = function(id, bindingId) {
  637. 635.  -   if (!id) id = 'acl';
  638. 636.  -
  639. 637.  -   var tab = ge('paginated_table');
  640. 638.  -
  641. 639.  -   var newOptions;
  642. 640.  -   switch (id) {
  643. 641.  -     case 'cli':
  644. 642.  -       newOptions = tab.optionsDep['cli'];
  645. 643.  -       break;
  646. 644.  -     case 'aca':
  647. 645.  -     case 'acl':
  648. 646.  -       newOptions = tab.optionsDep['default'];
  649. 647.  -       break;
  650. 648.  -     default:
  651. 649.  -       newOptions = tab.optionsDep['cam'];
  652. 650.  -       break;
  653. 651.  -   }
  654. 652.  -
  655. 653.  -   if (id in tab.contentDep && tab.contentDep[id]) {
  656. 654.  -     var newContent = tab.contentDep[id];
  657. 655.  -     tab.tableObj.setOptions(newOptions);
  658. 656.  -     tab.tableObj.setContent(newContent);
  659. 657.  -     tab.tableObj.applyData();
  660. 658.  -   } else {
  661. 659.  -     function onDone(data) {
  662. 660.  -       var newContent = data;
  663. 661.  -       tab.contentDep[id] = newContent;
  664. 662.  -       tab.tableObj.setOptions(newOptions);
  665. 663.  -       tab.tableObj.setContent(newContent);
  666. 664.  -       tab.tableObj.applyData();
  667. 665.  -       hide('getting_campaigns_upload');
  668. 666.  -     }
  669. 667.  -     function onFail() {
  670. 668.  -       hide('getting_campaigns_upload');
  671. 669.  -       return true;
  672. 670.  -     };
  673. 671.  -     show('getting_campaigns_upload');
  674. 672.  -     ajax.post('/ads?act=a_get_client_children', {client_id: id}, {onDone: onDone, onFail: onFail});
  675. 673.  -   }
  676. 674.  - }
  677. 675.  -
  678. 676.  - Ads.createStaticDropdownMenuAds = function(elem, bindingId, values, params) {
  679. 677.  -   elem = ge(elem);
  680. 678.  -
  681. 679.  -   if (params.classname) elem.className = params.classname + '_' + bindingId;
  682. 680.  -   elem.className = elem.className + ' dd_link';
  683. 681.  -
  684. 682.  -   elem.valueList = values;
  685. 683.  -   elem.getValue = function() {return elem.value;}
  686. 684.  -   elem.getIndex = function() {
  687. 685.  -     if (elem.index !== undefined) return elem.index;
  688. 686.  -
  689. 687.  -     for (var i = 0; i < elem.valueList.length; i++) {
  690. 688.  -       if (elem.valueList[i][1] == elem.value) {
  691. 689.  -         return elem.valueList[i][0];
  692. 690.  -       }
  693. 691.  -     }
  694. 692.  -     return -1;
  695. 693.  -   }
  696. 694.  -
  697. 695.  -   if (params.classname == 'client_choose') {
  698. 696.  -     onDomReady(function() {
  699. 697.  -       hide(geByClass('client_choose_row_' + bindingId)[0]);
  700. 698.  -     });
  701. 699.  -   }
  702. 700.  -   params.updateHeader = function(i, t) {
  703. 701.  -     if (!i) i = 'aca';
  704. 702.  -     Ads.openInnerTable(i, bindingId);
  705. 703.  -     elem.index = i;
  706. 704.  -     elem.value = t;
  707. 705.  -     return t;
  708. 706.  -   }
  709. 707.  -   params.onSelect = function(value) {
  710. 708.  -     if (value === undefined) value = uiDropdown.val();
  711. 709.  -     elem.value = value;
  712. 710.  -     elem.innerHTML = value;
  713. 711.  -   };
  714. 712.  -   params.target = elem;
  715. 713.  -   params.showHover = true;
  716. 714.  -   //params.alwaysMenuToUp = true;
  717. 715.  -
  718. 716.  -   params.onSelect(values[0][1]);
  719. 717.  -
  720. 718.  -   elem.uiDropdown = new DropdownMenu(values, params);
  721. 719.  -   Ads.makeDDScrollable(elem.uiDropdown);
  722. 720.  - }
  723. 721.  -
  724. 722.  - // threshold is height of container
  725. 723.  - Ads.makeDDScrollable = function(dd, threshold) {
  726. 724.  -   if (!dd) return;
  727. 725.  -   if (threshold === undefined) {
  728. 726.  -     threshold = 300;
  729. 727.  -   }
  730. 728.  -
  731. 729.  -   var uiBody = dd.body,
  732. 730.  -       uiTable = geByClass('dd_menu_rows', uiBody)[0].firstChild,
  733. 731.  -       uiTableS = getSize(uiBody),
  734. 732.  -       uiTableW = uiTableS[0],
  735. 733.  -       uiTableH = uiTableS[1] - 4, // dont understand why
  736. 734.  -       barW = 6,
  737. 735.  -       barH = Math.max(20, intval(threshold * threshold / uiTableH)),
  738. 736.  -       scrollBar = ce('div', {className: 'ads_dropdown_menu_scrollbar'}, {
  739. 737.  -         top: barH / 10,
  740. 738.  -         right: 3,
  741. 739.  -         width: barW,
  742. 740.  -         height: barH
  743. 741.  -       });
  744. 742.  -
  745. 743.  -   if (uiTableH < threshold) {
  746. 744.  -     return;
  747. 745.  -   }
  748. 746.  -
  749. 747.  -   setStyle(uiTable.parentNode, {
  750. 748.  -     overflowY: 'hidden',
  751. 749.  -     height: threshold
  752. 750.  -   });
  753. 751.  -   uiBody.appendChild(scrollBar);
  754. 752.  -   setStyle(uiTable, 'position', 'relative');
  755. 753.  -
  756. 754.  -   var startY = null,
  757. 755.  -       startTop = 0,
  758. 756.  -       hoverState = 0,
  759. 757.  -       hoverTimer = null;
  760. 758.  -   var onScroll = function(e) {
  761. 759.  -     var oldTop = parseFloat(getStyle(uiTable, 'top'));
  762. 760.  -     if (isNaN(oldTop)) {
  763. 761.  -       oldTop = 0;
  764. 762.  -     }
  765. 763.  -
  766. 764.  -     var delta = e.wheelDelta ? e.wheelDelta / 120 : -e.detail / 3;
  767. 765.  -     scrollBody(oldTop + delta * 20);
  768. 766.  -
  769. 767.  -     if (hoverTimer) {
  770. 768.  -       clearTimeout(hoverTimer);
  771. 769.  -     } else {
  772. 770.  -       doHover(1);
  773. 771.  -     }
  774. 772.  -     hoverTimer = setTimeout(function() {
  775. 773.  -       hoverTimer = null;
  776. 774.  -       doHover(-1);
  777. 775.  -       }, 200);
  778. 776.  -
  779. 777.  -     cancelEvent(e);
  780. 778.  -     return false;
  781. 779.  -   }
  782. 780.  -   var onMouseMove = function(e) {
  783. 781.  -     if (startY === null) return;
  784. 782.  -     var y = e.pageY;
  785. 783.  -     var localD = startY - y,
  786. 784.  -         delta = 1.0 * localD * (uiTableH - threshold) / (threshold - barH - 5);
  787. 785.  -     scrollBody(startTop + delta);
  788. 786.  -   }
  789. 787.  -   var scrollBody = function(newTop) {
  790. 788.  -     newTop = Math.min(0, newTop);
  791. 789.  -     newTop = Math.max(-uiTableH + threshold, newTop);
  792. 790.  -
  793. 791.  -     var barTop = 3 - 1.0 * newTop / (uiTableH - threshold) * (threshold - barH - 5);
  794. 792.  -     setStyle(uiTable, 'top', newTop);
  795. 793.  -     setStyle(scrollBar, 'top', barTop);
  796. 794.  -   }
  797. 795.  -   var onDown = function(e) {
  798. 796.  -     startY = e.pageY;
  799. 797.  -     startTop = parseFloat(getStyle(uiTable, 'top'));
  800. 798.  -     if (isNaN(startTop)) startTop = 0;
  801. 799.  -
  802. 800.  -     doHover(1);
  803. 801.  -     cancelEvent(e);
  804. 802.  -   }
  805. 803.  -   var onUp = function(e) {
  806. 804.  -     if (startY !== null) {
  807. 805.  -       doHover(-1);
  808. 806.  -     }
  809. 807.  -     startY = null;
  810. 808.  -   }
  811. 809.  -   var doHover = function(dh) {
  812. 810.  -     hoverState += dh;
  813. 811.  -     if (hoverState == 0) removeClass(scrollBar, 'hovered');
  814. 812.  -     if (hoverState == 1) addClass(scrollBar, 'hovered');
  815. 813.  -   }
  816. 814.  -
  817. 815.  -   dd.options.onShow = function() {
  818. 816.  -     scrollBody(100000);
  819. 817.  -   }
  820. 818.  -   addEvent(uiBody, 'mousewheel DOMMouseScroll', onScroll);
  821. 819.  -   addEvent(scrollBar, 'mousedown', onDown);
  822. 820.  -   addEvent(document.body, 'mouseup dragend', onUp);
  823. 821.  -   addEvent(uiBody, 'mousemove', onMouseMove);
  824. 822.  -
  825. 823.  -   cur.destroy.push(function() {
  826. 824.  -     removeEvent(uiBody, 'mousewheel DOMMouseScroll', onScroll);
  827. 825.  -     removeEvent(scrollBar, 'mousedown', onDown);
  828. 826.  -     removeEvent(document.body, 'mouseup dragend', onUp);
  829. 827.  -     removeEvent(uiBody, 'mousemove', onMouseMove);
  830. 828.  -   });
  831. 829.  - }
  832. 830.  -
  833. 831.  - // params must be ready to go to contructor
  834. 832.  - Ads.createStaticDropdown = function(elem, bindingId, values, params) {
  835. 833.  -   elem = ge(elem);
  836. 834.  -   if (params.classname) elem.className = params.classname + '_' + bindingId;
  837. 835.  -   elem.className = elem.className + ' dd_link';
  838. 836.  -
  839. 837.  -   elem.valueList = values;
  840. 838.  -   elem.getValue = function() {return elem.value;}
  841. 839.  -   elem.getIndex = function() {
  842. 840.  -     if (elem.index !== undefined) return elem.index;
  843. 841.  -
  844. 842.  -     for (var i = 0; i < elem.valueList.length; i++) {
  845. 843.  -       if (elem.valueList[i][1] == elem.value) {
  846. 844.  -         return elem.valueList[i][0];
  847. 845.  -       }
  848. 846.  -     }
  849. 847.  -     return -1;
  850. 848.  -   }
  851. 849.  -
  852. 850.  -   if (params.classname == 'client_choose') {
  853. 851.  -     onDomReady(function() {
  854. 852.  -       hide(geByClass('client_choose_row_' + bindingId)[0]);
  855. 853.  -     });
  856. 854.  -   }
  857. 855.  -
  858. 856.  -   params.updateHeader = function(i, t) {
  859. 857.  -     if (!i) i = 0;
  860. 858.  -     //
  861. 859.  -     // grouping_time
  862. 860.  -     //
  863. 861.  -     if (elem.className.substring(0, 'grouping_time'.length) == 'grouping_time') {
  864. 862.  -       var modes = ['d', 'm', 'h'];
  865. 863.  -       cur.exportUi['start_time'].setMode(modes[i]);
  866. 864.  -       cur.exportUi['stop_time'].setMode(modes[i]);
  867. 865.  -     } else
  868. 866.  -     //
  869. 867.  -     // client_choose
  870. 868.  -     //
  871. 869.  -     if (elem.className.substring(0, 'client_choose'.length) == 'client_choose') {
  872. 870.  -       if (!i) i = 'aca';
  873. 871.  -       Ads.openInnerTable(i, bindingId);
  874. 872.  -     } else
  875. 873.  -     //
  876. 874.  -     // grouping_ads
  877. 875.  -     //
  878. 876.  -     if (elem.className.substring(0, 'grouping_ads'.length) == 'grouping_ads') {
  879. 877.  -       var label_el;
  880. 878.  -       switch (i) {
  881. 879.  -         case 0:
  882. 880.  -           hide(geByClass('client_choose_row_' + bindingId)[0]);
  883. 881.  -           Ads.openInnerTable('acl', bindingId);
  884. 882.  -
  885. 883.  -           label_el = ge('unions_table_label_' + bindingId);
  886. 884.  -           label_el.innerHTML = getLang('ads_export_stat_data_title_campaigns');
  887. 885.  -           break;
  888. 886.  -         case 1:
  889. 887.  -           hide(geByClass('client_choose_row_' + bindingId)[0]);
  890. 888.  -           Ads.openInnerTable('cli', bindingId);
  891. 889.  -
  892. 890.  -           label_el = ge('unions_table_label_' + bindingId);
  893. 891.  -           label_el.innerHTML = getLang('ads_export_stat_data_title_clients');
  894. 892.  -           break;
  895. 893.  -         case 2:
  896. 894.  -           var chser = geByClass('client_choose_' + bindingId)[0];
  897. 895.  -           var dd = chser.uiDropdown;
  898. 896.  -
  899. 897.  -           var text = dd.options.updateHeader(0, chser.valueList[0][1]);
  900. 898.  -           dd.header.innerHTML = '<div>' + text + '</div>';
  901. 899.  -           if (dd.options.target) dd.options.target.innerHTML = text;
  902. 900.  -
  903. 901.  -           show(geByClass('client_choose_row_' + bindingId)[0]);
  904. 902.  -           Ads.openInnerTable('aca', bindingId);
  905. 903.  -
  906. 904.  -           label_el = ge('unions_table_label_' + bindingId);
  907. 905.  -           label_el.innerHTML = getLang('ads_export_stat_data_title_campaigns');
  908. 906.  -           break;
  909. 907.  -         case 3:
  910. 908.  -           Ads.openInnerTable('cam', bindingId);
  911. 909.  -         default:
  912. 910.  -           break;
  913. 911.  -       }
  914. 912.  -     }
  915. 913.  -
  916. 914.  -     elem.index = i;
  917. 915.  -     elem.value = t;
  918. 916.  -     return t;
  919. 917.  -   }
  920. 918.  -   params.onSelect = function(value) {
  921. 919.  -     if (value === undefined) value = uiDropdown.val();
  922. 920.  -     elem.value = value;
  923. 921.  -     elem.innerHTML = value;
  924. 922.  -   };
  925. 923.  -   params.target = elem;
  926. 924.  -   params.showHover = true;
  927. 925.  -   //params.alwaysMenuToUp = true;
  928. 926.  -
  929. 927.  -   params.onSelect(values[0][1]);
  930. 928.  -
  931. 929.  -   elem.uiDropdown = new DropdownMenu(values, params);
  932. 930.  - }
  933. 931.  -
  934. 932.  - Ads.createInlineStaticEdit = function(editElem, bindingId, params) {
  935. 933.  -   if (!params) params = {};
  936. 934.  -   editElem = ge(editElem);
  937. 935.  -   if (params.classname) editElem.className = params.classname + '_' + bindingId;
  938. 936.  -
  939. 937.  -   var uiTimeDay, uiTimeMonth, uiTimeYear, uiAbstractDropdown;
  940. 938.  -
  941. 939.  -   if (!params['type'] && !params['values']) return false;
  942. 940.  -
  943. 941.  -   var defaultValue;
  944. 942.  -   if (params['default']) {
  945. 943.  -     defaultValue = params['default'];
  946. 944.  -   }
  947. 945.  -
  948. 946.  -   var type = params['type'] || 'dropdown';
  949. 947.  -
  950. 948.  -   switch (type) {
  951. 949.  -     case 'dropdown':
  952. 950.  -       if (params['values'] === undefined) {
  953. 951.  -         return false;
  954. 952.  -       }
  955. 953.  -       if (defaultValue === undefined) {
  956. 954.  -         defaultValue = 0;
  957. 955.  -       }
  958. 956.  -       break;
  959. 957.  -     case 'time':
  960. 958.  -       break;
  961. 959.  -     default:
  962. 960.  -       break;
  963. 961.  -   }
  964. 962.  -
  965. 963.  -   monthNames = [
  966. 964.  -     getLang('ads_jan'),
  967. 965.  -     getLang('ads_feb'),
  968. 966.  -     getLang('ads_mar'),
  969. 967.  -     getLang('ads_apr'),
  970. 968.  -     getLang('ads_may'),
  971. 969.  -     getLang('ads_jun'),
  972. 970.  -     getLang('ads_jul'),
  973. 971.  -     getLang('ads_aug'),
  974. 972.  -     getLang('ads_sep'),
  975. 973.  -     getLang('ads_oct'),
  976. 974.  -     getLang('ads_nov'),
  977. 975.  -     getLang('ads_dec')
  978. 976.  -   ];
  979. 977.  -   saveValue(defaultValue);
  980. 978.  -
  981. 979.  -   function saveValue(newValue) {
  982. 980.  -     editElem.value = newValue;
  983. 981.  -
  984. 982.  -     var newText = '';
  985. 983.  -     switch (type) {
  986. 984.  -       case 'time':
  987. 985.  -         if (newValue && newValue.day && newValue.month && newValue.year) {
  988. 986.  -           newText = newValue.day + ' ' + monthNames[newValue.month - 1] + ' ' + newValue.year;
  989. 987.  -         }
  990. 988.  -         break;
  991. 989.  -       case 'dropdown':
  992. 990.  -         if (parseInt(newValue) !== undefined) {
  993. 991.  -           newText = params['values'][parseInt(newValue)];
  994. 992.  -         } else
  995. 993.  -         if (typeof newValue == 'string') {
  996. 994.  -           newText = newValue;
  997. 995.  -         }  else {
  998. 996.  -           for (var index in newValue) {
  999. 997.  -             saveValue.call(this, newValue[index]);
  1000. 998.  -             return;
  1001. 999.  -           }
  1002. 1000.  -         }
  1003. 1001.  -         break;
  1004. 1002.  -       default:
  1005. 1003.  -         break;
  1006. 1004.  -     }
  1007. 1005.  -
  1008. 1006.  -     applyNewValue.call(this, newValue, newText);
  1009. 1007.  -   }
  1010. 1008.  -   function applyNewValue(newValue, newText) {
  1011. 1009.  -     editElem.value = newValue;
  1012. 1010.  -     editElem.innerHTML = newText;
  1013. 1011.  -   }
  1014. 1012.  -   function checkValue(value) {
  1015. 1013.  -     return true;
  1016. 1014.  -   }
  1017. 1015.  -   function showLongError(error) {
  1018. 1016.  -     showFastBox(getLang('ads_error_box_title'), error);
  1019. 1017.  -   }
  1020. 1018.  -   function updateTimeDays(month) {
  1021. 1019.  -     uiTimeDay.setData(getDays(month));
  1022. 1020.  -   }
  1023. 1021.  -
  1024. 1022.  -   //
  1025. 1023.  -   // Helpers
  1026. 1024.  -   //
  1027. 1025.  -   function getDays(month, year) {
  1028. 1026.  -     var ret = [], days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1029. 1027.  -     if (!year) year = (new Date()).getFullYear();
  1030. 1028.  -     if (month == 2 && year % 4 == 0) {
  1031. 1029.  -       days[2] = 29
  1032. 1030.  -     }
  1033. 1031.  -     for (var i = 1, days = days[month]; i <= days; i++) {
  1034. 1032.  -       ret.push(i);
  1035. 1033.  -     }
  1036. 1034.  -     return ret;
  1037. 1035.  -   }
  1038. 1036.  -   function getMonths() {
  1039. 1037.  -     var months = [];
  1040. 1038.  -     for (var i = 1; i <= 12; i++) {
  1041. 1039.  -       months.push([i, monthNames[i - 1]]);
  1042. 1040.  -     }
  1043. 1041.  -     return months;
  1044. 1042.  -   }
  1045. 1043.  -   function getYears() {
  1046. 1044.  -     var ret = [];
  1047. 1045.  -     var curY = (new Date()).getFullYear();
  1048. 1046.  -     for (var i = curY; i >= curY - 10; i--) {
  1049. 1047.  -       ret.push(i);
  1050. 1048.  -     }
  1051. 1049.  -     return ret;
  1052. 1050.  -   }
  1053. 1051.  -   function getAssocFromValues(array) {
  1054. 1052.  -     var res = [];
  1055. 1053.  -     for (var i = 0; i < array.length; i++) {
  1056. 1054.  -       res.push([i, array[i]]);
  1057. 1055.  -     }
  1058. 1056.  -     return res;
  1059. 1057.  -   }
  1060. 1058.  -
  1061. 1059.  -   //
  1062. 1060.  -   // Events
  1063. 1061.  -   //
  1064. 1062.  -   function afterInit() {
  1065. 1063.  -     var self = this;
  1066. 1064.  -
  1067. 1065.  -     switch (type) {
  1068. 1066.  -       case 'time':
  1069. 1067.  -         uiTimeDay = new Dropdown(
  1070. 1068.  -           geByClass('inline_time_day', this.contentTable)[0],
  1071. 1069.  -           getDays(1),
  1072. 1070.  -           {width: 45, height: 150, selectedItem: 1}
  1073. 1071.  -         );
  1074. 1072.  -         uiTimeMonth = new Dropdown(
  1075. 1073.  -           geByClass('inline_time_month', this.contentTable)[0],
  1076. 1074.  -           getMonths(),
  1077. 1075.  -           {width: 80, height: 150, selectedItem: 1, onChange: function(value) { updateTimeDays.call(this, value); }}
  1078. 1076.  -         );
  1079. 1077.  -         uiTimeYear = new Dropdown(
  1080. 1078.  -           geByClass('inline_time_year', this.contentTable)[0],
  1081. 1079.  -           getYears(),
  1082. 1080.  -           {width: 65, height: 150, selectedItem: (new Date()).getFullYear()}
  1083. 1081.  -         );
  1084. 1082.  -         break;
  1085. 1083.  -
  1086. 1084.  -       case 'dropdown':
  1087. 1085.  -         uiAbstractDropdown = new Dropdown(
  1088. 1086.  -           geByClass('ads_inline_dropdown', this.contentTable)[0],
  1089. 1087.  -           getAssocFromValues(params['values']),
  1090. 1088.  -           {height: 150, selectedItem: 0}
  1091. 1089.  -         );
  1092. 1090.  -         break;
  1093. 1091.  -
  1094. 1092.  -       default:
  1095. 1093.  -         break;
  1096. 1094.  -     }
  1097. 1095.  -   }
  1098. 1096.  -   function onBeforeShow() {
  1099. 1097.  -     switch (type) {
  1100. 1098.  -       case 'time':
  1101. 1099.  -         if (defaultValue && defaultValue.day && defaultValue.month && defaultValue.year) {
  1102. 1100.  -           uiTimeDay.val(defaultValue.day);
  1103. 1101.  -           uiTimeMonth.val(defaultValue.month);
  1104. 1102.  -           uiTimeYear.val(defaultValue.year);
  1105. 1103.  -         } else {
  1106. 1104.  -           editElem.innerHTML = "�� ������";
  1107. 1105.  -         }
  1108. 1106.  -         break;
  1109. 1107.  -
  1110. 1108.  -       case 'dropdown':
  1111. 1109.  -         uiAbstractDropdown.val(defaultValue);
  1112. 1110.  -         break;
  1113. 1111.  -
  1114. 1112.  -       default:
  1115. 1113.  -         break;
  1116. 1114.  -     }
  1117. 1115.  -   }
  1118. 1116.  -   function onShow() {
  1119. 1117.  -   }
  1120. 1118.  -   function onConfirm() {
  1121. 1119.  -     var newValue;
  1122. 1120.  -     if (type == 'time') {
  1123. 1121.  -       newValue = {};
  1124. 1122.  -       newValue.day   = uiTimeDay.val();
  1125. 1123.  -       newValue.month = uiTimeMonth.val();
  1126. 1124.  -       newValue.year  = uiTimeYear.val();
  1127. 1125.  -     } else
  1128. 1126.  -     if (type == 'dropdown') {
  1129. 1127.  -       newValue = uiAbstractDropdown.val();
  1130. 1128.  -     }
  1131. 1129.  -
  1132. 1130.  -     saveValue.call(this, newValue);
  1133. 1131.  -     return true;
  1134. 1132.  -   }
  1135. 1133.  -
  1136. 1134.  -   var options = {
  1137. 1135.  -     afterInit: afterInit,
  1138. 1136.  -     onBeforeShow: onBeforeShow,
  1139. 1137.  -     onShow: onShow,
  1140. 1138.  -     onConfirm: onConfirm
  1141. 1139.  -   };
  1142. 1140.  -
  1143. 1141.  -   switch (type) {
  1144. 1142.  -     case 'time':
  1145. 1143.  -       options.contentHTML =
  1146. 1144.  -         '<tr>' +
  1147. 1145.  -         '<td colspan="2">' +
  1148. 1146.  -         '<table class="ads_inline_edit_table">' +
  1149. 1147.  -         '<tr>' +
  1150. 1148.  -           '<td style="white-space: nowrap; width: 200px;">' +
  1151. 1149.  -             '<table class="ads_inline_edit_table">' +
  1152. 1150.  -             '<tr>' +
  1153. 1151.  -               '<td style="padding-right: 5px;"><input type="text" class="inline_time_day text" style="width: 30px;" /></td>' +
  1154. 1152.  -               '<td style="padding-right: 5px;"><input type="text" class="inline_time_month text" style="width: 30px;" /></td>' +
  1155. 1153.  -               '<td style="padding-right: 5px;"><input type="text" class="inline_time_year text" style="width: 30px;" /></td>' +
  1156. 1154.  -             '</tr>' +
  1157. 1155.  -             '</table>' +
  1158. 1156.  -           '</td>' +
  1159. 1157.  -         '</tr>' +
  1160. 1158.  -         '</table>' +
  1161. 1159.  -         '</td>' +
  1162. 1160.  -         '</tr>';
  1163. 1161.  -       break;
  1164. 1162.  -     case 'dropdown':
  1165. 1163.  -       options.contentHTML =
  1166. 1164.  -         '<tr>' +
  1167. 1165.  -         '<td colspan="2">' +
  1168. 1166.  -         '<table class="ads_inline_edit_table" style="width: 100%;">' +
  1169. 1167.  -           '<tr><td><input type="text" class="ads_inline_dropdown text" /></td></tr>' +
  1170. 1168.  -         '</table>' +
  1171. 1169.  -         '</td>' +
  1172. 1170.  -         '</tr>';
  1173. 1171.  -       break;
  1174. 1172.  -     default:
  1175. 1173.  -       break;
  1176. 1174.  -   }
  1177. 1175.  -
  1178. 1176.  -   new InlineEdit(editElem, options);
  1179. 1177.  - }
  1180. 1178.  -
  1181. 1179.  - Ads.onInlineEditClick = function(elem, callback, rown, coln) {
  1182. 1180.  -   var _t = this;
  1183. 1181.  -
  1184. 1182.  -   var editElem = elem,
  1185. 1183.  -       progressElem = _t.content.extra.progress_elem[rown][coln],
  1186. 1184.  -       unionId = _t.content.extra.union_id[rown][coln],
  1187. 1185.  -       unionType = _t.content.extra.union_type[rown][coln],
  1188. 1186.  -       valueType = _t.content.extra.value_type[rown][coln],
  1189. 1187.  -       initValue = _t.content.extra.init_value[rown][coln],
  1190. 1188.  -       hash = _t.content.extra.hash[rown][coln],
  1191. 1189.  -       additionalParams = extend(_t.content.extra.additional_params[rown][coln], {
  1192. 1190.  -         valCallback: function(val) {
  1193. 1191.  -           callback({
  1194. 1192.  -             value: val,
  1195. 1193.  -             extra: {
  1196. 1194.  -               init_value: val
  1197. 1195.  -             }
  1198. 1196.  -           });
  1199. 1197.  -         }
  1200. 1198.  -       });
  1201. 1199.  -
  1202. 1200.  -   var ret = Ads.createInlineEdit(editElem, progressElem, unionType, unionId, valueType, initValue, hash, additionalParams);
  1203. 1201.  -   ret.obj.show();
  1204. 1202.  - }
  1205. 1203.  -
  1206. 1204.  - Ads.createInlineEdit = function(editElem, progressElem, unionType, unionId, valueType, initValue, hash, additionalParams) {
  1207. 1205.  -   editElem     = ge(editElem);
  1208. 1206.  -   progressElem = ge(progressElem);
  1209. 1207.  -   var defaultValue = initValue;
  1210. 1208.  -   var bad_this = this;
  1211. 1209.  -
  1212. 1210.  -   var uiTimeDay, uiTimeMonth, uiTimeHour;
  1213. 1211.  -
  1214. 1212.  -   var valueGeneralType;
  1215. 1213.  -   switch (valueType) {
  1216. 1214.  -     case 'cost_per_click':
  1217. 1215.  -       valueGeneralType = 'cost_per_click';
  1218. 1216.  -       break;
  1219. 1217.  -     case 'day_limit':
  1220. 1218.  -     case 'month_limit':
  1221. 1219.  -     case 'all_limit':
  1222. 1220.  -     case 'contract_limit':
  1223. 1221.  -       valueGeneralType = 'limit';
  1224. 1222.  -       break;
  1225. 1223.  -     case 'start_time':
  1226. 1224.  -     case 'stop_time':
  1227. 1225.  -       valueGeneralType = 'time';
  1228. 1226.  -       break;
  1229. 1227.  -     default:
  1230. 1228.  -       valueGeneralType = 'text';
  1231. 1229.  -       break;
  1232. 1230.  -   }
  1233. 1231.  -
  1234. 1232.  -   function saveValue(newValue, isRemoveValue) {
  1235. 1233.  -
  1236. 1234.  -     if (valueGeneralType == 'limit') {
  1237. 1235.  -       if ((!isRemoveValue && defaultValue == newValue) || (isRemoveValue && defaultValue == 0)) {
  1238. 1236.  -         if (isRemoveValue) {
  1239. 1237.  -           this.hide();
  1240. 1238.  -         }
  1241. 1239.  -         return;
  1242. 1240.  -       }
  1243. 1241.  -     } else {
  1244. 1242.  -       if (defaultValue == newValue) {
  1245. 1243.  -         return;
  1246. 1244.  -       }
  1247. 1245.  -     }
  1248. 1246.  -
  1249. 1247.  -     var unknownError = getLang('ads_error_unexpected_error_try_later');
  1250. 1248.  -
  1251. 1249.  -     var params = {};
  1252. 1250.  -     params.union_id = unionId;
  1253. 1251.  -     params.hash = hash;
  1254. 1252.  -     extend(params, additionalParams);
  1255. 1253.  -
  1256. 1254.  -     if (isRemoveValue) {
  1257. 1255.  -       params[valueType] = 0;
  1258. 1256.  -     } else {
  1259. 1257.  -       if (valueGeneralType == 'time') {
  1260. 1258.  -         params[valueType + '_day'] = newValue.day;
  1261. 1259.  -         params[valueType + '_month'] = newValue.month;
  1262. 1260.  -         params[valueType + '_hour'] = newValue.hour;
  1263. 1261.  -       } else {
  1264. 1262.  -         params[valueType] = newValue;
  1265. 1263.  -       }
  1266. 1264.  -     }
  1267. 1265.  -
  1268. 1266.  -     var self = this;
  1269. 1267.  -
  1270. 1268.  -     function onAjaxComplete(response) {
  1271. 1269.  -       if (isObject(response)) {
  1272. 1270.  -         if (response.error) {
  1273. 1271.  -           showLongError.call(self, response.error);
  1274. 1272.  -         } else if (!response.not_changed) {
  1275. 1273.  -           if ((valueType + '_value') in response) {
  1276. 1274.  -             applyNewValue.call(self, response[valueType + '_value'], response[valueType + '_text']);
  1277. 1275.  -           } else if (response[valueType + '_value_day']) {
  1278. 1276.  -             var newValue = {};
  1279. 1277.  -             newValue.day   = response[valueType + '_value_day'];
  1280. 1278.  -             newValue.month = response[valueType + '_value_month'];
  1281. 1279.  -             newValue.hour  = response[valueType + '_value_hour'];
  1282. 1280.  -             applyNewValue.call(self, newValue, response[valueType + '_text']);
  1283. 1281.  -           } else {
  1284. 1282.  -             showLongError.call(self, unknownError);
  1285. 1283.  -           }
  1286. 1284.  -         }
  1287. 1285.  -       } else {
  1288. 1286.  -         showLongError.call(self, unknownError);
  1289. 1287.  -       }
  1290. 1288.  -
  1291. 1289.  -       hide(progressElem);
  1292. 1290.  -       show(editElem);
  1293. 1291.  -
  1294. 1292.  -       return true;
  1295. 1293.  -     }
  1296. 1294.  -     ajax.post('/ads?act=a_unions_general_info_save', params, {onDone: onAjaxComplete, onFail: onAjaxComplete});
  1297. 1295.  -
  1298. 1296.  -     hide(editElem);
  1299. 1297.  -     show(progressElem);
  1300. 1298.  -     if (isRemoveValue) {
  1301. 1299.  -       this.hide();
  1302. 1300.  -     }
  1303. 1301.  -   }
  1304. 1302.  -   function applyNewValue(newValue, newText) {
  1305. 1303.  -     if (valueType == 'name') {
  1306. 1304.  -       Ads.updateUnionName(unionId, newText);
  1307. 1305.  -     }
  1308. 1306.  -     defaultValue = newValue;
  1309. 1307.  -     if (additionalParams.valCallback) {
  1310. 1308.  -       additionalParams.valCallback(newValue);
  1311. 1309.  -     } else {
  1312. 1310.  -       editElem.innerHTML = newText;
  1313. 1311.  -     }
  1314. 1312.  -   }
  1315. 1313.  -   function checkValue(value) {
  1316. 1314.  -     switch (valueGeneralType) {
  1317. 1315.  -       case 'cost_per_click':
  1318. 1316.  -         if (value == '' || value == '0' || value == 0) {
  1319. 1317.  -           return (additionalParams.is_cost_per_click ? getLang('ads_error_cost_per_click_no_value') : getLang('ads_error_cost_per_views_no_value'));
  1320. 1318.  -         }
  1321. 1319.  -         if (!value.match(/[0-9.,]/)) {
  1322. 1320.  -           return (additionalParams.is_cost_per_click ? getLang('ads_error_cost_per_click_invalid_value') : getLang('ads_error_cost_per_views_invalid_value'));
  1323. 1321.  -         }
  1324. 1322.  -         value = value.replace(',', '.');
  1325. 1323.  -
  1326. 1324.  -         var valueFloat      = parseFloat(value);
  1327. 1325.  -         var suffixesAll     = '';
  1328. 1326.  -         suffixesAll        += (additionalParams.is_cost_per_click ? '_click' : '_views');
  1329. 1327.  -         suffixesAll        += (additionalParams.is_exclusive_ad ? '_exclusive' : '');
  1330. 1328.  -         suffixesAll        += (additionalParams.is_app_admin ? '_app' : '');
  1331. 1329.  -         var minValue        = cur.unionsLimits['cost_per' + suffixesAll + '_min'];
  1332. 1330.  -         var maxValue        = cur.unionsLimits['cost_per' + suffixesAll + '_max'];
  1333. 1331.  -         var minErrorLangKey = (additionalParams.is_cost_per_click ? 'ads_error_cost_per_click_min_value' : 'ads_error_cost_per_views_min_value');
  1334. 1332.  -         var maxErrorLangKey = (additionalParams.is_cost_per_click ? 'ads_error_cost_per_click_max_value' : 'ads_error_cost_per_views_max_value');
  1335. 1333.  -         if (valueFloat < minValue) {
  1336. 1334.  -           return getLang(minErrorLangKey).replace('{money}', getLang('global_money_amount_rub', minValue));
  1337. 1335.  -         }
  1338. 1336.  -         if (valueFloat > maxValue) {
  1339. 1337.  -           return getLang(maxErrorLangKey).replace('{money}', getLang('global_money_amount_rub', maxValue));
  1340. 1338.  -         }
  1341. 1339.  -
  1342. 1340.  -         if (!value.match(cur.unionsLimits.cost_per_click_pattern)) {
  1343. 1341.  -           return (additionalParams.is_cost_per_click ? getLang('ads_error_cost_per_click_invalid_value') : getLang('ads_error_cost_per_views_invalid_value'));
  1344. 1342.  -         }
  1345. 1343.  -         return true;
  1346. 1344.  -       case 'limit':
  1347. 1345.  -         if (value == '' || value == '0' || value == 0) {
  1348. 1346.  -           return getLang('ads_error_limit_no_value');
  1349. 1347.  -         }
  1350. 1348.  -         if (!value.match(/[0-9.,]/)) {
  1351. 1349.  -           return getLang('ads_error_limit_invalid_value');
  1352. 1350.  -         }
  1353. 1351.  -         if (value.indexOf('.') != -1 || value.indexOf(',') != -1) {
  1354. 1352.  -           return getLang('ads_error_limit_integer_value');
  1355. 1353.  -         }
  1356. 1354.  -         if (parseInt(value) < cur.unionsLimits.limit_min) {
  1357. 1355.  -           return getLang('ads_error_limit_min_value').replace('{money}', getLang('global_money_amount_rub', cur.unionsLimits.limit_min));
  1358. 1356.  -         }
  1359. 1357.  -         if (parseInt(value) > cur.unionsLimits.limit_max) {
  1360. 1358.  -           return getLang('ads_error_limit_large_value');
  1361. 1359.  -         }
  1362. 1360.  -         if (!value.match(cur.unionsLimits.limit_pattern)) {
  1363. 1361.  -           return getLang('ads_error_limit_invalid_value');
  1364. 1362.  -         }
  1365. 1363.  -         return true;
  1366. 1364.  -     }
  1367. 1365.  -     switch (valueType) {
  1368. 1366.  -       case 'name':
  1369. 1367.  -         if (value == '') {
  1370. 1368.  -           if (unionType == 4) { // Top union
  1371. 1369.  -             // Nothing
  1372. 1370.  -           } else if (unionType == 2) {
  1373. 1371.  -             return getLang('ads_error_client_name_no_value');
  1374. 1372.  -           } else if (unionType == 1) {
  1375. 1373.  -             return getLang('ads_error_campaign_name_no_value');
  1376. 1374.  -           }
  1377. 1375.  -         }
  1378. 1376.  -         return true;
  1379. 1377.  -     }
  1380. 1378.  -     if (additionalParams.server_check) {
  1381. 1379.  -       return true;
  1382. 1380.  -     } else {
  1383. 1381.  -       return false;
  1384. 1382.  -     }
  1385. 1383.  -   }
  1386. 1384.  -
  1387. 1385.  -   function showFastError(error) {
  1388. 1386.  -     geByClass('ads_inline_fast_error', this.fastErrorRow)[0].innerHTML = error;
  1389. 1387.  -     show(this.fastErrorRow);
  1390. 1388.  -   }
  1391. 1389.  -   function hideFastError() {
  1392. 1390.  -     hide(this.fastErrorRow);
  1393. 1391.  -     geByClass('ads_inline_fast_error', this.fastErrorRow)[0].innerHTML = '';
  1394. 1392.  -   }
  1395. 1393.  -   function showLongError(error) {
  1396. 1394.  -     showFastBox(getLang('ads_error_box_title'), error);
  1397. 1395.  -   }
  1398. 1396.  -   function removeValue() {
  1399. 1397.  -     saveValue.call(this, false, true);
  1400. 1398.  -     return true;
  1401. 1399.  -   }
  1402. 1400.  -   function updateTimeDays(month) {
  1403. 1401.  -     uiTimeDay.setData(getDays(month));
  1404. 1402.  -   }
  1405. 1403.  -
  1406. 1404.  -   //
  1407. 1405.  -   // Helpers
  1408. 1406.  -   //
  1409. 1407.  -   function getDays(month) {
  1410. 1408.  -     var ret = [], days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1411. 1409.  -     if (month == 2 && (new Date()).getFullYear() % 4 == 0) {
  1412. 1410.  -       days[2] = 29
  1413. 1411.  -     }
  1414. 1412.  -     for (var i = 1, days = days[month]; i <= days; i++) {
  1415. 1413.  -       ret.push(i);
  1416. 1414.  -     }
  1417. 1415.  -     return ret;
  1418. 1416.  -   }
  1419. 1417.  -   function getMonths() {
  1420. 1418.  -     var months = [];
  1421. 1419.  -     months.push([1,  getLang('ads_jan')]);
  1422. 1420.  -     months.push([2,  getLang('ads_feb')]);
  1423. 1421.  -     months.push([3,  getLang('ads_mar')]);
  1424. 1422.  -     months.push([4,  getLang('ads_apr')]);
  1425. 1423.  -     months.push([5,  getLang('ads_may')]);
  1426. 1424.  -     months.push([6,  getLang('ads_jun')]);
  1427. 1425.  -     months.push([7,  getLang('ads_jul')]);
  1428. 1426.  -     months.push([8,  getLang('ads_aug')]);
  1429. 1427.  -     months.push([9,  getLang('ads_sep')]);
  1430. 1428.  -     months.push([10, getLang('ads_oct')]);
  1431. 1429.  -     months.push([11, getLang('ads_nov')]);
  1432. 1430.  -     months.push([12, getLang('ads_dec')]);
  1433. 1431.  -     return months;
  1434. 1432.  -   }
  1435. 1433.  -   function getHours() {
  1436. 1434.  -     var ret = [];
  1437. 1435.  -     for (var i = 0; i < 24; i++) {
  1438. 1436.  -       ret.push([i, i + ':00']);
  1439. 1437.  -     }
  1440. 1438.  -     return ret;
  1441. 1439.  -   }
  1442. 1440.  -
  1443. 1441.  -   //
  1444. 1442.  -   // Events
  1445. 1443.  -   //
  1446. 1444.  -   function afterInit() {
  1447. 1445.  -     var self = this;
  1448. 1446.  -
  1449. 1447.  -     if (valueGeneralType == 'limit' || valueGeneralType == 'time') {
  1450. 1448.  -       this.removeValueAnchor = geByClass('ads_inline_edit_remove_value', this.contentTable)[0];
  1451. 1449.  -       addEvent(this.removeValueAnchor, 'click', function() { removeValue.call(self); return false; });
  1452. 1450.  -     }
  1453. 1451.  -
  1454. 1452.  -     if (valueGeneralType == 'time') {
  1455. 1453.  -       uiTimeDay = new Dropdown(
  1456. 1454.  -         geByClass('inline_time_day', this.contentTable)[0],
  1457. 1455.  -         getDays(1),
  1458. 1456.  -         {width: 45, height: 150, selectedItem: 1}
  1459. 1457.  -       );
  1460. 1458.  -       uiTimeMonth = new Dropdown(
  1461. 1459.  -         geByClass('inline_time_month', this.contentTable)[0],
  1462. 1460.  -         getMonths(),
  1463. 1461.  -         {width: 80, height: 150, selectedItem: 1, onChange: function(value) { updateTimeDays.call(this, value); }}
  1464. 1462.  -       );
  1465. 1463.  -       uiTimeHour = new Dropdown(
  1466. 1464.  -         geByClass('inline_time_hour', this.contentTable)[0],
  1467. 1465.  -         getHours(),
  1468. 1466.  -         {width: 65, height: 150, selectedItem: 0}
  1469. 1467.  -       );
  1470. 1468.  -     }
  1471. 1469.  -
  1472. 1470.  -     this.fastErrorRow = geByClass('ads_inline_fast_error_row', this.contentTable)[0];
  1473. 1471.  -
  1474. 1472.  -     if (this.input) {
  1475. 1473.  -       this.is_user_action = true;
  1476. 1474.  -       addEvent(this.input, 'keyup', function(event) {
  1477. 1475.  -           if (event.keyCode != 13) {
  1478. 1476.  -             hideFastError.call(self);
  1479. 1477.  -           }
  1480. 1478.  -         }
  1481. 1479.  -       );
  1482. 1480.  -     }
  1483. 1481.  -   }
  1484. 1482.  -   function onBeforeShow() {
  1485. 1483.  -     if (this.input) {
  1486. 1484.  -       this.input.value = defaultValue;
  1487. 1485.  -     }
  1488. 1486.  -
  1489. 1487.  -     if (valueGeneralType == 'time') {
  1490. 1488.  -       uiTimeDay.val(defaultValue.day);
  1491. 1489.  -       uiTimeMonth.val(defaultValue.month);
  1492. 1490.  -       uiTimeHour.val(defaultValue.hour);
  1493. 1491.  -     }
  1494. 1492.  -
  1495. 1493.  -     hideFastError.call(this);
  1496. 1494.  -
  1497. 1495.  -     var self = this;
  1498. 1496.  -     if (valueGeneralType == 'cost_per_click' && !this.recommended_cost_loaded) {
  1499. 1497.  -       var recommendedCostProgress = geByClass('inline_recommended_cost_progress', this.contentTable)[0];
  1500. 1498.  -       var recommendedCostText     = geByClass('ads_inline_recommended_cost_text',     this.contentTable)[0];
  1501. 1499.  -
  1502. 1500.  -       function onDone(response) {
  1503. 1501.  -         if (response && response.recommended_costs && response.recommended_costs.cost_text) {
  1504. 1502.  -           recommendedCostText.innerHTML = response.recommended_costs.cost_text;
  1505. 1503.  -           hide(recommendedCostProgress);
  1506. 1504.  -           show(recommendedCostText);
  1507. 1505.  -           if (!this.is_user_action && self.input.value == '0') {
  1508. 1506.  -             self.input.value = response.recommended_costs.cost_value;
  1509. 1507.  -           }
  1510. 1508.  -           self.recommended_cost_loaded = true;
  1511. 1509.  -         }
  1512. 1510.  -       };
  1513. 1511.  -       var ajaxParams = {ad_id: unionId};
  1514. 1512.  -       ajax.post('/ads?act=a_get_recommended_cost', ajaxParams, {onDone: onDone});
  1515. 1513.  -     }
  1516. 1514.  -   }
  1517. 1515.  -   function onShow() {
  1518. 1516.  -     if (this.input) {
  1519. 1517.  -       elfocus(this.input);
  1520. 1518.  -     }
  1521. 1519.  -   }
  1522. 1520.  -   function onConfirm() {
  1523. 1521.  -     var newValue;
  1524. 1522.  -     if (valueGeneralType == 'time') {
  1525. 1523.  -       newValue = {};
  1526. 1524.  -       newValue.day   = uiTimeDay.val();
  1527. 1525.  -       newValue.month = uiTimeMonth.val();
  1528. 1526.  -       newValue.hour  = uiTimeHour.val();
  1529. 1527.  -     } else {
  1530. 1528.  -       newValue = this.input.value;
  1531. 1529.  -
  1532. 1530.  -       var checkResult = checkValue.call(this, newValue, valueType);
  1533. 1531.  -       if (typeof(checkResult) == 'string') {
  1534. 1532.  -         showFastError.call(this, checkResult);
  1535. 1533.  -         return false;
  1536. 1534.  -       }
  1537. 1535.  -       if (checkResult !== true) {
  1538. 1536.  -         showFastError.call(this, getLang('ads_error_unknown_error'));
  1539. 1537.  -         return false;
  1540. 1538.  -       }
  1541. 1539.  -     }
  1542. 1540.  -
  1543. 1541.  -     saveValue.call(this, newValue, false);
  1544. 1542.  -     return true;
  1545. 1543.  -   }
  1546. 1544.  -
  1547. 1545.  -   var options = {
  1548. 1546.  -     afterInit: afterInit,
  1549. 1547.  -     onBeforeShow: onBeforeShow,
  1550. 1548.  -     onShow: onShow,
  1551. 1549.  -     onConfirm: onConfirm
  1552. 1550.  -   };
  1553. 1551.  -
  1554. 1552.  -   switch (valueGeneralType) {
  1555. 1553.  -     case 'cost_per_click':
  1556. 1554.  -       options.contentHTML =
  1557. 1555.  -         '<tr>' +
  1558. 1556.  -         '<td colspan="2">' +
  1559. 1557.  -         '<table class="ads_inline_edit_table" style="width: 100%;">' +
  1560. 1558.  -         '<tr><td><input class="inlInput text" type="text" /></td></tr>' +
  1561. 1559.  -         '<tr><td style="padding-top: 7px; height: 22px;">' +
  1562. 1560.  -           '<img class="inline_recommended_cost_progress" src="/images/upload.gif" />' +
  1563. 1561.  -           '<span class="ads_inline_recommended_cost_text"></span>' +
  1564. 1562.  -           '<div style="width: 275px; height: 1px;"></div>' +
  1565. 1563.  -           '</td></tr>' +
  1566. 1564.  -         '<tr class="ads_inline_fast_error_row"><td><div class="ads_inline_fast_error"></div></td></tr>' +
  1567. 1565.  -         '</table>' +
  1568. 1566.  -         '</td>' +
  1569. 1567.  -         '</tr>';
  1570. 1568.  -       break;
  1571. 1569.  -     case 'limit':
  1572. 1570.  -       options.contentHTML =
  1573. 1571.  -         '<tr>' +
  1574. 1572.  -         '<td colspan="2">' +
  1575. 1573.  -         '<table class="ads_inline_edit_table">' +
  1576. 1574.  -         '<tr>' +
  1577. 1575.  -         '<td><input class="inlInput text" type="text" /></td>' +
  1578. 1576.  -         '<td><a class="ads_inline_edit_remove_value" href="#">' + getLang('ads_inline_edit_remove_limit') + '</a></td>' +
  1579. 1577.  -         '</tr>' +
  1580. 1578.  -         '<tr class="ads_inline_fast_error_row"><td colspan="2"><div class="ads_inline_fast_error"></div></td></tr>' +
  1581. 1579.  -         '</table>' +
  1582. 1580.  -         '</td>' +
  1583. 1581.  -         '</tr>';
  1584. 1582.  -       break;
  1585. 1583.  -     case 'time':
  1586. 1584.  -       var removeValueText;
  1587. 1585.  -       switch (valueType) {
  1588. 1586.  -         case 'start_time': removeValueText = getLang('ads_inline_edit_remove_start_time'); break;
  1589. 1587.  -         case 'stop_time': removeValueText = getLang('ads_inline_edit_remove_stop_time'); break;
  1590. 1588.  -       }
  1591. 1589.  -       options.contentHTML =
  1592. 1590.  -         '<tr>' +
  1593. 1591.  -         '<td colspan="2">' +
  1594. 1592.  -         '<table class="ads_inline_edit_table">' +
  1595. 1593.  -         '<tr>' +
  1596. 1594.  -           '<td style="white-space: nowrap; width: 200px;">' +
  1597. 1595.  -             '<table class="ads_inline_edit_table">' +
  1598. 1596.  -             '<tr>' +
  1599. 1597.  -               '<td style="padding-right: 5px;"><input type="text" class="inline_time_day text" style="width: 30px;" /></td>' +
  1600. 1598.  -               '<td style="padding-right: 5px;"><input type="text" class="inline_time_month text" style="width: 30px;" /></td>' +
  1601. 1599.  -               '<td style="padding-right: 5px;"><input type="text" class="inline_time_hour text" style="width: 30px;" /></td>' +
  1602. 1600.  -             '</tr>' +
  1603. 1601.  -             '</table>' +
  1604. 1602.  -           '</td>' +
  1605. 1603.  -         '</tr>' +
  1606. 1604.  -         '<tr><td style="padding-top: 7px;"><a class="ads_inline_edit_remove_value" style="padding-left: 0;" href="#">' + removeValueText + '</a></td></tr>' +
  1607. 1605.  -         '<tr class="ads_inline_fast_error_row"><td colspan="2"><div class="ads_inline_fast_error"></div></td></tr>' +
  1608. 1606.  -         '</table>' +
  1609. 1607.  -         '</td>' +
  1610. 1608.  -         '</tr>';
  1611. 1609.  -       break;
  1612. 1610.  -     case 'text':
  1613. 1611.  -       options.contentHTML =
  1614. 1612.  -         '<tr>' +
  1615. 1613.  -         '<td colspan="2">' +
  1616. 1614.  -         '<table class="ads_inline_edit_table" style="width: 100%;">' +
  1617. 1615.  -         '<tr><td><input class="inlInput text" type="text" /></td></tr>' +
  1618. 1616.  -         '<tr class="ads_inline_fast_error_row"><td><div class="ads_inline_fast_error"></div></td></tr>' +
  1619. 1617.  -         '</table>' +
  1620. 1618.  -         '</td>' +
  1621. 1619.  -         '</tr>';
  1622. 1620.  -       break;
  1623. 1621.  -   }
  1624. 1622.  -
  1625. 1623.  -   var ret = {
  1626. 1624.  -     target: editElem,
  1627. 1625.  -     options: options
  1628. 1626.  -   };
  1629. 1627.  -   if (this.getOptionsOnly) { // dirty hack.
  1630. 1628.  -     return ret;
  1631. 1629.  -   }
  1632. 1630.  -   ret.obj = new InlineEdit(editElem, options);
  1633. 1631.  -
  1634. 1632.  -   var accessFunctions = {
  1635. 1633.  -     applyNewValue: applyNewValue
  1636. 1634.  -   }
  1637. 1635.  -
  1638. 1636.  -   if (!cur.inlineEditControls) {
  1639. 1637.  -     cur.inlineEditControls = {};
  1640. 1638.  -   }
  1641. 1639.  -   cur.inlineEditControls[valueType + '_' + unionId] = accessFunctions;
  1642. 1640.  -
  1643. 1641.  -   return ret;
  1644. 1642.  - }
  1645. 1643.  -
  1646. 1644.  - Ads.createInlineDropdownMenu = function(menuElem, boxElem, progressElem, unionId, valueType, items, initValue, hash, additionalParams) {
  1647. 1645.  -   menuElem     = ge(menuElem);
  1648. 1646.  -   boxElem      = ge(boxElem);
  1649. 1647.  -   progressElem = ge(progressElem);
  1650. 1648.  -   var defaultValue = initValue;
  1651. 1649.  -
  1652. 1650.  -   var self;
  1653. 1651.  -
  1654. 1652.  -   function saveValue(newValue) {
  1655. 1653.  -
  1656. 1654.  -     if (newValue == defaultValue) {
  1657. 1655.  -       return;
  1658. 1656.  -     }
  1659. 1657.  -
  1660. 1658.  -     var unknownError = getLang('ads_error_unexpected_error_try_later');
  1661. 1659.  -
  1662. 1660.  -     var params = {};
  1663. 1661.  -     params.union_id = unionId;
  1664. 1662.  -     params.hash = hash;
  1665. 1663.  -     extend(params, additionalParams);
  1666. 1664.  -     params[valueType] = newValue;
  1667. 1665.  -
  1668. 1666.  -     function onAjaxComplete(response) {
  1669. 1667.  -       if (isObject(response)) {
  1670. 1668.  -         if (response.error) {
  1671. 1669.  -           showLongError.call(self, response.error);
  1672. 1670.  -         } else if (!response.not_changed) {
  1673. 1671.  -           if (response[valueType + '_value'] !== undefined) {
  1674. 1672.  -             applyNewValue(response[valueType + '_value'], response[valueType + '_text']);
  1675. 1673.  -             if (additionalParams.reload) {
  1676. 1674.  -               nav.reload();
  1677. 1675.  -             }
  1678. 1676.  -           } else {
  1679. 1677.  -             showLongError.call(self, unknownError);
  1680. 1678.  -           }
  1681. 1679.  -         }
  1682. 1680.  -       } else {
  1683. 1681.  -         showLongError.call(self, unknownError);
  1684. 1682.  -       }
  1685. 1683.  -
  1686. 1684.  -       hide(progressElem);
  1687. 1685.  -       show(boxElem);
  1688. 1686.  -
  1689. 1687.  -       return true;
  1690. 1688.  -     }
  1691. 1689.  -     ajax.post('/ads?act=a_unions_general_info_save', params, {onDone: onAjaxComplete, onFail: onAjaxComplete});
  1692. 1690.  -
  1693. 1691.  -     hide(boxElem);
  1694. 1692.  -     show(progressElem);
  1695. 1693.  -   }
  1696. 1694.  -
  1697. 1695.  -   function applyNewValue(newValue, newText) {
  1698. 1696.  -     defaultValue = newValue;
  1699. 1697.  -     self.setOptions({title: newText});
  1700. 1698.  -     menuElem.innerHTML = newText;
  1701. 1699.  -   }
  1702. 1700.  -   function showLongError(error) {
  1703. 1701.  -     showFastBox(getLang('ads_error_box_title'), error);
  1704. 1702.  -   }
  1705. 1703.  -
  1706. 1704.  -   function onMenuChange(event) {
  1707. 1705.  -     var newValue = event.target.index;
  1708. 1706.  -     saveValue(newValue);
  1709. 1707.  -   }
  1710. 1708.  -
  1711. 1709.  -   var options = {};
  1712. 1710.  -   options.target = menuElem;
  1713. 1711.  -   options.onSelect = onMenuChange;
  1714. 1712.  -   options.showHover = false;
  1715. 1713.  -   options.updateTarget = false;
  1716. 1714.  -   self = new DropdownMenu(items, options);
  1717. 1715.  - }
  1718. 1716.  -
  1719. 1717.  - Ads.MultiDropdownMenu = function(items, options) {
  1720. 1718.  -   var dropdownMenu;
  1721. 1719.  -   var selectedItems = {};
  1722. 1720.  -   var curItems = [];
  1723. 1721.  -
  1724. 1722.  -   function onItemClick(e) {
  1725. 1723.  -     if (e.target.className == 'ads_dd_menu_item_checkbox_on') {
  1726. 1724.  -       selectedItems[e.target.index] = false;
  1727. 1725.  -       e.target.className = 'ads_dd_menu_item_checkbox_off';
  1728. 1726.  -     } else {
  1729. 1727.  -       selectedItems[e.target.index] = true;
  1730. 1728.  -       e.target.className = 'ads_dd_menu_item_checkbox_on';
  1731. 1729.  -     }
  1732. 1730.  -     return false;
  1733. 1731.  -   }
  1734. 1732.  -
  1735. 1733.  -   for (var i in items) {
  1736. 1734.  -     curItems[i] = {};
  1737. 1735.  -     for (var j in items[i]) {
  1738. 1736.  -       curItems[i][j] = items[i][j];
  1739. 1737.  -     }
  1740. 1738.  -     curItems[i].onClick = onItemClick;
  1741. 1739.  -     curItems[i].c = 'ads_dd_menu_item_checkbox_off';
  1742. 1740.  -     selectedItems[curItems[i].i] = false;
  1743. 1741.  -   }
  1744. 1742.  -
  1745. 1743.  -   dropdownMenu = new DropdownMenu(curItems, options);
  1746. 1744.  -   dropdownMenu.getSelectedItems = function() {
  1747. 1745.  -     var selectedItemsResult = [];
  1748. 1746.  -     for (var i in selectedItems) {
  1749. 1747.  -       if (selectedItems[i]) {
  1750. 1748.  -         selectedItemsResult.push(i);
  1751. 1749.  -       }
  1752. 1750.  -     }
  1753. 1751.  -     return selectedItemsResult;
  1754. 1752.  -   }
  1755. 1753.  -
  1756. 1754.  -   return dropdownMenu;
  1757. 1755.  - }
  1758. 1756.  -
  1759. 1757.  - Ads.getCampaignsTotalLabel = function(total) {
  1760. 1758.  -   var type = this._curFilter;
  1761. 1759.  -   if (typeof type == 'object') type = type[0];
  1762. 1760.  -   if (!this._curSearchString || this._curSearchString == '') {
  1763. 1761.  -     switch (type) {
  1764. 1762.  -       case 0: return getLang('ads_stopped_campaigns_total', total);
  1765. 1763.  -       case 1: return getLang('ads_running_campaigns_total', total);
  1766. 1764.  -       case 3: return getLang('ads_planned_campaigns_total', total);
  1767. 1765.  -       case 4: return getLang('ads_archived_campaigns_total', total);
  1768. 1766.  -       default: return getLang('ads_active_campaigns_total', total);
  1769. 1767.  -     }
  1770. 1768.  -   } else {
  1771. 1769.  -     switch (type) {
  1772. 1770.  -       case 0: return getLang('ads_stopped_campaigns_found', total);
  1773. 1771.  -       case 1: return getLang('ads_running_campaigns_found', total);
  1774. 1772.  -       case 3: return getLang('ads_planned_campaigns_found', total);
  1775. 1773.  -       case 4: return getLang('ads_archived_campaigns_found', total);
  1776. 1774.  -       default: return getLang('ads_active_campaigns_found', total);
  1777. 1775.  -     }
  1778. 1776.  -   }
  1779. 1777.  - }
  1780. 1778.  -
  1781. 1779.  - Ads.getNoCampaignsLabel = function() {
  1782. 1780.  -   var type = this._curFilter;
  1783. 1781.  -   if (typeof type == 'object') type = type[0];
  1784. 1782.  -   if (!this._curSearchString || this._curSearchString == '') {
  1785. 1783.  -     switch (type) {
  1786. 1784.  -       case 0: return getLang('ads_no_stopped_campaigns');
  1787. 1785.  -       case 1: return getLang('ads_no_running_campaigns');
  1788. 1786.  -       case 3: return getLang('ads_no_planned_campaigns');
  1789. 1787.  -       case 4: return getLang('ads_no_archived_campaigns');
  1790. 1788.  -       default: return getLang('ads_no_active_campaigns');
  1791. 1789.  -     }
  1792. 1790.  -   } else {
  1793. 1791.  -     switch (type) {
  1794. 1792.  -       case 0: return getLang('ads_no_stopped_campaigns_found');
  1795. 1793.  -       case 1: return getLang('ads_no_running_campaigns_found');
  1796. 1794.  -       case 3: return getLang('ads_no_planned_campaigns_found');
  1797. 1795.  -       case 4: return getLang('ads_no_archived_campaigns_found');
  1798. 1796.  -       default: return getLang('ads_no_active_campaigns_found');
  1799. 1797.  -     }
  1800. 1798.  -   }
  1801. 1799.  - }
  1802. 1800.  -
  1803. 1801.  - Ads.getAdsTotalLabel = function(total) {
  1804. 1802.  -   var type = this._curFilter;
  1805. 1803.  -   if (typeof type == 'object') type = type[0];
  1806. 1804.  -   if (!this._curSearchString || this._curSearchString == '') {
  1807. 1805.  -     switch (type) {
  1808. 1806.  -       case 0: return getLang('ads_stopped_ads_total', total);
  1809. 1807.  -       case 1: return getLang('ads_running_ads_total', total);
  1810. 1808.  -       case 3: return getLang('ads_planned_ads_total', total);
  1811. 1809.  -       case 4: return getLang('ads_archived_ads_total', total);
  1812. 1810.  -       default: return getLang('ads_active_ads_total', total);
  1813. 1811.  -     }
  1814. 1812.  -   } else {
  1815. 1813.  -     switch (type) {
  1816. 1814.  -       case 0: return getLang('ads_stopped_ads_found', total);
  1817. 1815.  -       case 1: return getLang('ads_running_ads_found', total);
  1818. 1816.  -       case 3: return getLang('ads_planned_ads_found', total);
  1819. 1817.  -       case 4: return getLang('ads_archived_ads_found', total);
  1820. 1818.  -       default: return getLang('ads_active_ads_found', total);
  1821. 1819.  -     }
  1822. 1820.  -   }
  1823. 1821.  - }
  1824. 1822.  -
  1825. 1823.  - Ads.getNoAdsLabel = function() {
  1826. 1824.  -   var type = this._curFilter;
  1827. 1825.  -   if (typeof type == 'object') type = type[0];
  1828. 1826.  -   if (!this._curSearchString || this._curSearchString == '') {
  1829. 1827.  -     switch (type) {
  1830. 1828.  -       case 0: return getLang('ads_no_stopped_ads');
  1831. 1829.  -       case 1: return getLang('ads_no_running_ads');
  1832. 1830.  -       case 3: return getLang('ads_no_planned_ads');
  1833. 1831.  -       case 4: return getLang('ads_no_archived_ads');
  1834. 1832.  -       default: return getLang('ads_no_active_ads');
  1835. 1833.  -     }
  1836. 1834.  -   } else {
  1837. 1835.  -     switch (type) {
  1838. 1836.  -       case 0: return getLang('ads_no_stopped_ads_found');
  1839. 1837.  -       case 1: return getLang('ads_no_running_ads_found');
  1840. 1838.  -       case 3: return getLang('ads_no_planned_ads_found');
  1841. 1839.  -       case 4: return getLang('ads_no_archived_ads_found');
  1842. 1840.  -       default: return getLang('ads_no_active_ads_found');
  1843. 1841.  -     }
  1844. 1842.  -   }
  1845. 1843.  - }
  1846. 1844.  -
  1847. 1845.  - Ads.getClientsTotalLabel = function(total) {
  1848. 1846.  -   var type = this._curFilter;
  1849. 1847.  -   if (typeof type == 'object') type = type[0];
  1850. 1848.  -   if (!this._curSearchString || this._curSearchString == '') {
  1851. 1849.  -     switch (type) {
  1852. 1850.  -       case 4: return getLang('ads_archived_clients_total', total);
  1853. 1851.  -       default: return getLang('ads_active_clients_total', total);
  1854. 1852.  -     }
  1855. 1853.  -   } else {
  1856. 1854.  -     switch (type) {
  1857. 1855.  -       case 4: return getLang('ads_archived_clients_found', total);
  1858. 1856.  -       default: return getLang('ads_active_clients_found', total);
  1859. 1857.  -     }
  1860. 1858.  -   }
  1861. 1859.  - }
  1862. 1860.  -
  1863. 1861.  - Ads.getNoClientsLabel = function() {
  1864. 1862.  -   var type = this._curFilter;
  1865. 1863.  -   if (typeof type == 'object') type = type[0];
  1866. 1864.  -   if (!this._curSearchString || this._curSearchString == '') {
  1867. 1865.  -     switch (type) {
  1868. 1866.  -       case 4: return getLang('ads_no_archived_clients');
  1869. 1867.  -       default: return getLang('ads_no_active_clients');
  1870. 1868.  -     }
  1871. 1869.  -   } else {
  1872. 1870.  -     switch (type) {
  1873. 1871.  -       case 4: return getLang('ads_no_archived_clients_found');
  1874. 1872.  -       default: return getLang('ads_no_active_clients_found');
  1875. 1873.  -     }
  1876. 1874.  -   }
  1877. 1875.  - }
  1878. 1876.  -
  1879. 1877.  - Ads.addOfficeFormatFunctions = function(options) {
  1880. 1878.  -   var arrFind = function(arr, val) {
  1881. 1879.  -     var i = 0;
  1882. 1880.  -     for (; i < arr.length; i++) {
  1883. 1881.  -       if (arr[i] === val) {
  1884. 1882.  -         return i;
  1885. 1883.  -       }
  1886. 1884.  -     }
  1887. 1885.  -     return -1;
  1888. 1886.  -   }
  1889. 1887.  -
  1890. 1888.  -   var ind = arrFind(options.columnClasses, 'column_name_view');
  1891. 1889.  -   options.columnFormatting[ind] = function(data, rown) {
  1892. 1890.  -     if (rown == -1) return data;
  1893. 1891.  -     var unionId = this.content.extra.unionId[rown];
  1894. 1892.  -     return '<div class="ads_paginated_table_name"><a href="/ads?act=office&union_id=' + unionId + '">' + data + '</a></div>';
  1895. 1893.  -   }
  1896. 1894.  -
  1897. 1895.  -   var limitFormat = function(data, rown, coln) {
  1898. 1896.  -     if (rown == -1) return data;
  1899. 1897.  -     var wrap;
  1900. 1898.  -     try {
  1901. 1899.  -       var uid = this.content.extra.uid[rown][coln];
  1902. 1900.  -       if (uid) {
  1903. 1901.  -         wrap = "<img id=\"inline_edit_progress" + uid + "\" src=\"/images/upload.gif\" style=\"display: none;\" /><a id=\"inline_edit_value" + uid + "\" >{value}</a>";
  1904. 1902.  -       }
  1905. 1903.  -     } catch (e) {
  1906. 1904.  -       // Nothing
  1907. 1905.  -     }
  1908. 1906.  -     if (!wrap) {
  1909. 1907.  -       wrap = '{value}';
  1910. 1908.  -     }
  1911. 1909.  -     var value = data;
  1912. 1910.  -     if (data == 0) {
  1913. 1911.  -       value = getLang('ads_no_money_limit');
  1914. 1912.  -     } else {
  1915. 1913.  -       value = this._formatData(data, 'currency_int');
  1916. 1914.  -     }
  1917. 1915.  -     return wrap.replace('{value}', value);
  1918. 1916.  -   }
  1919. 1917.  -   ind = arrFind(options.columnClasses, 'column_day_limit_view');
  1920. 1918.  -   if (ind != -1) options.columnFormatting[ind] = limitFormat;
  1921. 1919.  -   ind = arrFind(options.columnClasses, 'column_month_limit_view');
  1922. 1920.  -   if (ind != -1) options.columnFormatting[ind] = limitFormat;
  1923. 1921.  -   ind = arrFind(options.columnClasses, 'column_all_limit_view');
  1924. 1922.  -   if (ind != -1) options.columnFormatting[ind] = limitFormat;
  1925. 1923.  -
  1926. 1924.  -   return options;
  1927. 1925.  - }
  1928. 1926.  -
  1929. 1927.  - Ads.createOfficePaginatedTable = function(container, options, content) {
  1930. 1928.  -   var getButton = function(label, callback) {
  1931. 1929.  -     var div = ce('div', {className: 'button_blue'});
  1932. 1930.  -     var butt = ce('button', {innerHTML: label, onclick: callback});
  1933. 1931.  -     div.appendChild(butt);
  1934. 1932.  -     return div;
  1935. 1933.  -   }
  1936. 1934.  -
  1937. 1935.  -   var statusCol = 1;
  1938. 1936.  -
  1939. 1937.  -   var selected;
  1940. 1938.  -
  1941. 1939.  -   var buttons = [],
  1942. 1940.  -       labels = [getLang('ads_status_do_disable'),
  1943. 1941.  -                 getLang('ads_status_do_enable'),
  1944. 1942.  -                 getLang('ads_status_do_archive')];
  1945. 1943.  -
  1946. 1944.  -
  1947. 1945.  -   var changeStatus = function(val) {
  1948. 1946.  -     return function() {
  1949. 1947.  -       var unionIds = [],
  1950. 1948.  -           hashes = [],
  1951. 1949.  -           hashesDel = [],
  1952. 1950.  -           enable = val; // 1 - on, 0 - off, 2 - delete
  1953. 1951.  -       var i;
  1954. 1952.  -       for (i in selected) {
  1955. 1953.  -         unionIds.push(pt.content.extra.union_id[selected[i]][statusCol]);
  1956. 1954.  -         hashes.push(pt.content.extra.hash[selected[i]][statusCol]);
  1957. 1955.  -         hashesDel.push(pt.content.extra.hash_delete[selected[i]][statusCol]);
  1958. 1956.  -       }
  1959. 1957.  -
  1960. 1958.  -       unionIds = unionIds.join(',');
  1961. 1959.  -       hashes = hashes.join(',');
  1962. 1960.  -       hashesDel = hashesDel.join(',');
  1963. 1961.  -
  1964. 1962.  -       if (val == 2) { // delete
  1965. 1963.  -         Ads.openDeleteUnionBox(cur.tableUnionTypeForDelete, unionIds, hashesDel, lockChangeStatus, unlockChangeStatus, updateStatusInTable, 2);
  1966. 1964.  -         return;
  1967. 1965.  -       }
  1968. 1966.  -
  1969. 1967.  -       var params = {
  1970. 1968.  -         union_id: unionIds,
  1971. 1969.  -         hash: hashes,
  1972. 1970.  -         newclass: 1,
  1973. 1971.  -         enable: val
  1974. 1972.  -       };
  1975. 1973.  -
  1976. 1974.  -       lockChangeStatus();
  1977. 1975.  -
  1978. 1976.  -       function lockChangeStatus() {
  1979. 1977.  -         lockButton(buttons[val]);
  1980. 1978.  -         return true;
  1981. 1979.  -       };
  1982. 1980.  -       function unlockChangeStatus() {
  1983. 1981.  -         unlockButton(buttons[val]);
  1984. 1982.  -       }
  1985. 1983.  -       function updateStatusInTable(ans) {
  1986. 1984.  -         if (ans['status_class']) ans = [ans];
  1987. 1985.  -
  1988. 1986.  -         var errored = 0;
  1989. 1987.  -         for (var i in selected) {
  1990. 1988.  -           if (!ans[i]) continue;
  1991. 1989.  -           if (!ans[i]['status_class']) {
  1992. 1990.  -             if (ans[i]['error'] && !errored) {
  1993. 1991.  -               errored = 1;
  1994. 1992.  -               showFastBox(getLang('ads_cant_start_ad_box_title'), ans[i]['error']);
  1995. 1993.  -             }
  1996. 1994.  -             continue;
  1997. 1995.  -           }
  1998. 1996.  -           pt.content.types[selected[i]] = ans[i]['status_type'];
  1999. 1997.  -           pt.content.extra.status_text[selected[i]][statusCol] = ans[i]['status'];
  2000. 1998.  -           pt.content.extra.status_variants[selected[i]][statusCol] = ans[i]['status_variants'];
  2001. 1999.  -           pt._updateValue(selected[i], statusCol, ans[i]['status_class']);
  2002. 2000.  -         }
  2003. 2001.  -         updateButtons.apply(pt);
  2004. 2002.  -       }
  2005. 2003.  -
  2006. 2004.  -       function onRequestComplete(response) {
  2007. 2005.  -         // response may be object or array
  2008. 2006.  -
  2009. 2007.  -         unlockChangeStatus();
  2010. 2008.  -
  2011. 2009.  -         if (!response || response.error) { // no isObject or isArray check here
  2012. 2010.  -           debugLog('onFail change status');
  2013. 2011.  -           var errorMessage = ((response && response.error) ? response.error : getLang('ads_error_unexpected_error_try_later'));
  2014. 2012.  -           showFastBox(getLang('ads_cant_start_ad_box_title'), errorMessage);
  2015. 2013.  -           return true;
  2016. 2014.  -         }
  2017. 2015.  -
  2018. 2016.  -         var info = '';
  2019. 2017.  -         if (response && response.info) {
  2020. 2018.  -           info = response.info;
  2021. 2019.  -         }
  2022. 2020.  -         debugLog('onDone change status, ' + info);
  2023. 2021.  -
  2024. 2022.  -         updateStatusInTable(response);
  2025. 2023.  -         return true;
  2026. 2024.  -       }
  2027. 2025.  -
  2028. 2026.  -       ajax.post('/ads?act=a_union_change_status', params, {onDone: onRequestComplete, onFail: onRequestComplete});
  2029. 2027.  -     };
  2030. 2028.  -   }
  2031. 2029.  -
  2032. 2030.  -   var updateButtons = function() {
  2033. 2031.  -     selected = this.getSelection(0, 1);
  2034. 2032.  -     var i;
  2035. 2033.  -     for (i in buttons) {
  2036. 2034.  -       hide(buttons[i]);
  2037. 2035.  -     }
  2038. 2036.  -     if (selected.length == 0) {
  2039. 2037.  -     } else {
  2040. 2038.  -       var was = [false, false];
  2041. 2039.  -       var on = {on: 1, pending: 1},
  2042. 2040.  -           off = {off: 1, off_red: 1, cross: 1};
  2043. 2041.  -       for (i in selected) {
  2044. 2042.  -         var stat = this.content.data[selected[i]][statusCol];
  2045. 2043.  -         if (on[stat]) was[0] = 1;
  2046. 2044.  -         if (off[stat]) was[1] = 1;
  2047. 2045.  -       }
  2048. 2046.  -       if (was[0]) show(buttons[0]);
  2049. 2047.  -       if (was[1]) show(buttons[1]);
  2050. 2048.  -       show(buttons[2]);
  2051. 2049.  -     }
  2052. 2050.  -   }
  2053. 2051.  -
  2054. 2052.  -   options.onCheckboxPick = updateButtons;
  2055. 2053.  -   options.onRefresh = updateButtons;
  2056. 2054.  -
  2057. 2055.  -   options = Ads.addOfficeFormatFunctions(options);
  2058. 2056.  -
  2059. 2057.  -   var i;
  2060. 2058.  -   for (i = 0; i < 3; i++) {
  2061. 2059.  -     buttons[i] = getButton(labels[i], changeStatus(i));
  2062. 2060.  -   }
  2063. 2061.  -
  2064. 2062.  -   var pt = new PaginatedTable(container, options, content);
  2065. 2063.  - //  pt.getData('/ads?act=a_unions_table&union_id=1000157403&period_key=20111018&sort_key=default_r&offset={offset}&limit={limit}');
  2066. 2064.  -
  2067. 2065.  -   // mass actions
  2068. 2066.  -   var container = ge('pt_' + pt.globalNum + '_mass_act_default_container');
  2069. 2067.  -   if (container) {
  2070. 2068.  -     addClass(container, 'ads_mass_act_container');
  2071. 2069.  -     container.appendChild(buttons[1]);
  2072. 2070.  -     container.appendChild(buttons[0]);
  2073. 2071.  -     container.appendChild(buttons[2]);
  2074. 2072.  -     for (i in buttons) {
  2075. 2073.  -       hide(buttons[i]);
  2076. 2074.  -     }
  2077. 2075.  -     show(container);
  2078. 2076.  -   }
  2079. 2077.  -
  2080. 2078.  -   // selecting subclasses
  2081. 2079.  -   var selectSubclass = function(classes) {
  2082. 2080.  -     return function() {
  2083. 2081.  -       var corr = 1;
  2084. 2082.  -       for (i = 0; i < pt.tableSize; i++) {
  2085. 2083.  -         if (i < pt.curFrom || i > pt.curTo) continue;
  2086. 2084.  -         var j = pt.permutation[i];
  2087. 2085.  -         var curClass = pt.content.data[j][statusCol];
  2088. 2086.  -         corr &= ((pt.selection[j] == 1) == (classes[curClass] == 1));
  2089. 2087.  -       }
  2090. 2088.  -       var checked = 1 ^ corr;
  2091. 2089.  -       for (i = 0; i < pt.tableSize; i++) {
  2092. 2090.  -         if (i < pt.curFrom || i > pt.curTo) continue;
  2093. 2091.  -         var j = pt.permutation[i];
  2094. 2092.  -         var curClass = pt.content.data[j][statusCol];
  2095. 2093.  -         var curToggle = classes[curClass] ? checked : 0;
  2096. 2094.  -         var el = ge('cb_row_' + j + '_' + pt.globalNum);
  2097. 2095.  -         if (el) {
  2098. 2096.  -           window[curToggle ? 'addClass' : 'removeClass'](el, 'on');
  2099. 2097.  -         }
  2100. 2098.  -         pt.toggleCheckbox(false, j, curToggle);
  2101. 2099.  -       }
  2102. 2100.  -     };
  2103. 2101.  -   }
  2104. 2102.  -   container = ge('select_all_link');
  2105. 2103.  -   if (container) {
  2106. 2104.  -     container.onclick = selectSubclass({on: 1, off: 1, off_red: 1, cross: 1, pending: 1});
  2107. 2105.  -   }
  2108. 2106.  -   container = ge('select_running_link');
  2109. 2107.  -   if (container) {
  2110. 2108.  -     container.onclick = selectSubclass({on: 1});
  2111. 2109.  -   }
  2112. 2110.  -   container = ge('select_stopped_link');
  2113. 2111.  -   if (container) {
  2114. 2112.  -     container.onclick = selectSubclass({off: 1, off_red: 1, cross: 1});
  2115. 2113.  -   }
  2116. 2114.  - }
  2117. 2115.  -
  2118. 2116.  - Ads.onStatusHover = function(elem, callback, rown, coln) {
  2119. 2117.  -   var _t = this;
  2120. 2118.  -   var options = {
  2121. 2119.  -     status: {type: this.content.data[rown][coln], title: this.content.extra.status_text[rown][coln]},
  2122. 2120.  -     items: this.content.extra.status_variants[rown][coln],
  2123. 2121.  -     popupTime: -1,
  2124. 2122.  -     onSelect: function(event) { // copypasted
  2125. 2123.  -       var index = event.target.index,
  2126. 2124.  -           unionId = _t.content.extra.union_id[rown][coln],
  2127. 2125.  -           hash = _t.content.extra.hash[rown][coln],
  2128. 2126.  -           hashDelete = _t.content.extra.hash_delete[rown][coln];
  2129. 2127.  -
  2130. 2128.  -       if (index == 'archived') {
  2131. 2129.  -         setTimeout(function(){
  2132. 2130.  -           Ads.openDeleteUnionBox(cur.tableUnionTypeForDelete, unionId, hashDelete, lockChangeStatus, unlockChangeStatus, updateStatusInTable, 1);
  2133. 2131.  -         }, 1);
  2134. 2132.  -         return;
  2135. 2133.  -       }
  2136. 2134.  -
  2137. 2135.  -       var params = {};
  2138. 2136.  -       params.union_id = unionId;
  2139. 2137.  -       params.hash = hash;
  2140. 2138.  -       params.newclass = 1;
  2141. 2139.  -
  2142. 2140.  -       params.enable = ((index == 'on') ? 1 : 0);
  2143. 2141.  -
  2144. 2142.  -       lockChangeStatus();
  2145. 2143.  -
  2146. 2144.  -       function lockChangeStatus() {
  2147. 2145.  -         var selectorBox   = ge('union_' + unionId + '_status_selector_box');
  2148. 2146.  -         var progress      = ge('union_' + unionId + '_status_progress');
  2149. 2147.  -         hide(selectorBox);
  2150. 2148.  -         show(progress);
  2151. 2149.  -         return true;
  2152. 2150.  -       };
  2153. 2151.  -       function unlockChangeStatus() {
  2154. 2152.  -         var selectorBox   = ge('union_' + unionId + '_status_selector_box');
  2155. 2153.  -         var progress      = ge('union_' + unionId + '_status_progress');
  2156. 2154.  -         hide(progress)
  2157. 2155.  -         show(selectorBox);
  2158. 2156.  -       }
  2159. 2157.  -       function updateStatusInTable(status, status_class, status_type, status_variants) {
  2160. 2158.  -         if (!status && !status_class) return;
  2161. 2159.  -
  2162. 2160.  -         var ret = {
  2163. 2161.  -           value: status_class,
  2164. 2162.  -           extra: {
  2165. 2163.  -             status_text: status,
  2166. 2164.  -             status_variants: status_variants
  2167. 2165.  -           },
  2168. 2166.  -           type: status_type
  2169. 2167.  -         };
  2170. 2168.  -
  2171. 2169.  -         if (status_class == 'deleted') {
  2172. 2170.  -           ret.listeners = false;
  2173. 2171.  -           ret.extra.link_class = '';
  2174. 2172.  -         }
  2175. 2173.  -         callback(ret);
  2176. 2174.  -       }
  2177. 2175.  -
  2178. 2176.  -       function onRequestComplete(response) {
  2179. 2177.  -         unlockChangeStatus();
  2180. 2178.  -
  2181. 2179.  -         if (!isObject(response) || response.error) {
  2182. 2180.  -           debugLog('onFail change status');
  2183. 2181.  -           var errorMessage = (isObject(response) ? response.error : getLang('ads_error_unexpected_error_try_later'));
  2184. 2182.  -           showFastBox(getLang('ads_cant_start_ad_box_title'), errorMessage);
  2185. 2183.  -           return true;
  2186. 2184.  -         }
  2187. 2185.  -
  2188. 2186.  -         var info = '';
  2189. 2187.  -         if (response && response.info) {
  2190. 2188.  -           info = response.info;
  2191. 2189.  -         }
  2192. 2190.  -         debugLog('onDone change status, ' + info);
  2193. 2191.  -
  2194. 2192.  -         updateStatusInTable(response.status, response.status_class, response.status_type, response.status_variants);
  2195. 2193.  -         return true;
  2196. 2194.  -       }
  2197. 2195.  -
  2198. 2196.  -       ajax.post('/ads?act=a_union_change_status', params, {onDone: onRequestComplete, onFail: onRequestComplete});
  2199. 2197.  -     }
  2200. 2198.  -   };
  2201. 2199.  -
  2202. 2200.  -   var sdd;
  2203. 2201.  -   if (!cur._statusDropdown) {
  2204. 2202.  -     var handler = elem.getAttribute('onclick');
  2205. 2203.  -     sdd = cur._statusDropdown = Ads.statusDropdown(elem, options);
  2206. 2204.  -     elem.setAttribute('onclick', handler);
  2207. 2205.  -     elem.onclick = function(){eval(handler);};
  2208. 2206.  -   } else {
  2209. 2207.  -     sdd = cur._statusDropdown;
  2210. 2208.  -     sdd.hideHeader();
  2211. 2209.  -     clearTimeout(sdd.timer);
  2212. 2210.  -     sdd.setContainer(elem);
  2213. 2211.  -     sdd.setStatus(options.status);
  2214. 2212.  -     sdd.setItems(options.items);
  2215. 2213.  -     sdd.setHandler(options.onSelect);
  2216. 2214.  -   }
  2217. 2215.  -
  2218. 2216.  -   sdd.onOver();
  2219. 2217.  - }
  2220. 2218.  -
  2221. 2219.  - Ads.statusDropdown = function(container, options) {
  2222. 2220.  -   container = ge(container);
  2223. 2221.  -   if (!container) return false;
  2224. 2222.  -
  2225. 2223.  -   options = extend({
  2226. 2224.  -     popupTime: 200,   // -1 means 'always show entire body'
  2227. 2225.  -     status: {type: 'off', title: 'Disabled'},
  2228. 2226.  -     onSelect: function() {}
  2229. 2227.  -   }, options);
  2230. 2228.  -
  2231. 2229.  -   var compareTypes = function(type1, type2) {
  2232. 2230.  -     var same = {
  2233. 2231.  -       on: {
  2234. 2232.  -         on: 1,
  2235. 2233.  -         pending: 1
  2236. 2234.  -       },
  2237. 2235.  -       off: {
  2238. 2236.  -         off: 1,
  2239. 2237.  -         off_red: 1,
  2240. 2238.  -         cross: 1
  2241. 2239.  -       },
  2242. 2240.  -       archived: {
  2243. 2241.  -         deleted: 1
  2244. 2242.  -       }
  2245. 2243.  -     };
  2246. 2244.  -     if (!same[type1]) return 0;
  2247. 2245.  -     return same[type1][type2] || 0;
  2248. 2246.  -   }
  2249. 2247.  -
  2250. 2248.  -   var items = clone(options.items);
  2251. 2249.  -   for (var i in items) {
  2252. 2250.  -     if (compareTypes(items[i]['i'], options.status.type)) {
  2253. 2251.  -       delete items[i];
  2254. 2252.  -     }
  2255. 2253.  -   }
  2256. 2254.  -
  2257. 2255.  -   var imgSpanFake = {className: geByClass('ads_status_image_span', container)[0].className};
  2258. 2256.  -   var imgSpanHTML = '<span class="' + imgSpanFake.className + '"></span>';
  2259. 2257.  -
  2260. 2258.  -   var deltaTop = 0, deltaLeft = 0;
  2261. 2259.  -   if (browser.opera) deltaTop += -1;
  2262. 2260.  -   if (browser.mozilla) deltaTop += -1;
  2263. 2261.  -   if (browser.msie) { deltaTop += -1; deltaLeft += 1; }
  2264. 2262.  -
  2265. 2263.  -   var dd = new DropdownMenu(items, {
  2266. 2264.  -     title: imgSpanHTML + options.status.title,
  2267. 2265.  -     target: container,
  2268. 2266.  -     onSelect: options.onSelect,
  2269. 2267.  -     showHover: false,
  2270. 2268.  -     updateTarget: false,
  2271. 2269.  -     offsetTop: -2 + deltaTop,
  2272. 2270.  -     offsetLeft: -1 + deltaLeft
  2273. 2271.  -   });
  2274. 2272.  -   dd.hide();
  2275. 2273.  -   addClass(dd.header, 'ads_dd_wide');
  2276. 2274.  -   addClass(dd.body, 'ads_dd_wide');
  2277. 2275.  -
  2278. 2276.  -   var showTimer, hideTimer;
  2279. 2277.  -   var overListener = function() {
  2280. 2278.  -     if (hideTimer) {
  2281. 2279.  -       clearTimeout(hideTimer);
  2282. 2280.  -       hideTimer = false;
  2283. 2281.  -     }
  2284. 2282.  -     if (options.popupTime == -1) {
  2285. 2283.  -       dd.show();
  2286. 2284.  -       return true;
  2287. 2285.  -     }
  2288. 2286.  -     showTimer = setTimeout(function() {
  2289. 2287.  -       showTimer = false;
  2290. 2288.  -       ret.showHeader();
  2291. 2289.  -     }, options.popupTime);
  2292. 2290.  -   };
  2293. 2291.  -   var outListenerSoft = function() {
  2294. 2292.  -     if (showTimer) {
  2295. 2293.  -       clearTimeout(showTimer);
  2296. 2294.  -       showTimer = false;
  2297. 2295.  -     } else {
  2298. 2296.  -       hideTimer = setTimeout(function() {
  2299. 2297.  -         hideTimer = false;
  2300. 2298.  -         ret.hideHeader();
  2301. 2299.  -       }, 500);
  2302. 2300.  -     }
  2303. 2301.  -   };
  2304. 2302.  -   var outListenerHard = function() {
  2305. 2303.  -     hideTimer = setTimeout(function() {
  2306. 2304.  -       hideTimer = false;
  2307. 2305.  -       ret.hideHeader();
  2308. 2306.  -     }, 500);
  2309. 2307.  -   };
  2310. 2308.  -
  2311. 2309.  -   if (options.popupTime != -1) {
  2312. 2310.  -     addEvent(dd.header, 'click', function() {removeClass(dd.header, 'ads_dd_header_popup');});
  2313. 2311.  -     addEvent(container, 'click', function() {ret.showBody();});
  2314. 2312.  -
  2315. 2313.  -     addEvent(container, 'mouseover', overListener);
  2316. 2314.  -     addEvent(container, 'mouseout', outListenerSoft);
  2317. 2315.  -     addEvent(dd.header, 'mouseover', overListener);
  2318. 2316.  -     addEvent(dd.header, 'mouseout', outListenerHard);
  2319. 2317.  -     addEvent(dd.body, 'mouseover', overListener);
  2320. 2318.  -     addEvent(dd.body, 'mouseout', outListenerHard);
  2321. 2319.  -   }
  2322. 2320.  -
  2323. 2321.  -   var clearTimers = function() {
  2324. 2322.  -     if (showTimer) {
  2325. 2323.  -       clearTimeout(showTimer);
  2326. 2324.  -       showTimer = false;
  2327. 2325.  -     }
  2328. 2326.  -     if (hideTimer) {
  2329. 2327.  -       clearTimeout(hideTimer);
  2330. 2328.  -       hideTimer = false;
  2331. 2329.  -     }
  2332. 2330.  -   }
  2333. 2331.  -
  2334. 2332.  -   var ret = {
  2335. 2333.  -     getStatus: function() {
  2336. 2334.  -       return options.status;
  2337. 2335.  -     },
  2338. 2336.  -     setStatus: function(status) {
  2339. 2337.  -       removeClass(imgSpanFake, 'status_' + options.status.type);
  2340. 2338.  -       options.status = status;
  2341. 2339.  -       addClass(imgSpanFake, 'status_' + options.status.type);
  2342. 2340.  -       dd.setOptions({title: '<span class="' + imgSpanFake.className + '"></span>' + options.status.title});
  2343. 2341.  -     },
  2344. 2342.  -     setContainer: function(newContainer) {
  2345. 2343.  -       if (!newContainer) return false;
  2346. 2344.  -       clearTimers();
  2347. 2345.  -       if (options.popupTime != -1) {
  2348. 2346.  -         removeEvent(container, 'mouseover', overListener);
  2349. 2347.  -         removeEvent(container, 'mouseout', outListenerSoft);
  2350. 2348.  -         removeEvent(dd.header, 'mouseover', overListener);
  2351. 2349.  -         removeEvent(dd.header, 'mouseout', outListenerHard);
  2352. 2350.  -         removeEvent(dd.body, 'mouseover', overListener);
  2353. 2351.  -         removeEvent(dd.body, 'mouseout', outListenerHard);
  2354. 2352.  -       }
  2355. 2353.  -       container = newContainer;
  2356. 2354.  -       dd.setOptions({target: container});
  2357. 2355.  -       dd.moveToTarget();
  2358. 2356.  -       if (options.popupTime != -1) {
  2359. 2357.  -         addEvent(container, 'mouseover', overListener);
  2360. 2358.  -         addEvent(container, 'mouseout', outListenerSoft);
  2361. 2359.  -         addEvent(dd.header, 'mouseover', overListener);
  2362. 2360.  -         addEvent(dd.header, 'mouseout', outListenerHard);
  2363. 2361.  -         addEvent(dd.body, 'mouseover', overListener);
  2364. 2362.  -         addEvent(dd.body, 'mouseout', outListenerHard);
  2365. 2363.  -       }
  2366. 2364.  -     },
  2367. 2365.  -     setItems: function(newItems) {
  2368. 2366.  -       var items = clone(newItems);
  2369. 2367.  -       for (var i in items) {
  2370. 2368.  -         if (compareTypes(items[i]['i'], options.status.type)) {
  2371. 2369.  -           delete items[i];
  2372. 2370.  -         }
  2373. 2371.  -       }
  2374. 2372.  -       dd.setData(items);
  2375. 2373.  -     },
  2376. 2374.  -     setHandler: function(handler) {
  2377. 2375.  -       dd.setOptions({onSelect: handler});
  2378. 2376.  -     },
  2379. 2377.  -     showHeader: function() {
  2380. 2378.  -       if (!dd.visible) {
  2381. 2379.  -         addClass(dd.header, 'ads_dd_header_popup');
  2382. 2380.  -       }
  2383. 2381.  -       dd.moveToTarget();
  2384. 2382.  -       show(dd.header);
  2385. 2383.  -     },
  2386. 2384.  -     hideHeader: function() {
  2387. 2385.  -       dd.hide();
  2388. 2386.  -       hide(dd.header);
  2389. 2387.  -       removeClass(dd.header, 'ads_dd_header_popup');
  2390. 2388.  -     },
  2391. 2389.  -     showBody: function() {
  2392. 2390.  -       removeClass(dd.header, 'ads_dd_header_popup');
  2393. 2391.  -       dd.show();
  2394. 2392.  -     },
  2395. 2393.  -     hideBody: function() {
  2396. 2394.  -       dd.hide();
  2397. 2395.  -     },
  2398. 2396.  -     onOver: overListener,
  2399. 2397.  -     onOut: outListenerHard
  2400. 2398.  -   };
  2401. 2399.  -
  2402. 2400.  -   return ret;
  2403. 2401.  - }
  2404. 2402.  -
  2405. 2403.  - Ads.changeDemographyView = function(name, unionId, updateOnly) {
  2406. 2404.  -
  2407. 2405.  -   // Change navigation
  2408. 2406.  -   var navCur = ge('ads_demography_navigation_tab_' + name);
  2409. 2407.  -   if (!navCur) {
  2410. 2408.  -     return;
  2411. 2409.  -   }
  2412. 2410.  -   navCur = navCur.parentNode;
  2413. 2411.  -   var navCurSelected = hasClass(navCur, 'summary_tab_sel');
  2414. 2412.  -   if (navCurSelected && !updateOnly || !navCurSelected && updateOnly) {
  2415. 2413.  -     return;
  2416. 2414.  -   }
  2417. 2415.  -   var navElems = [
  2418. 2416.  -     ge('ads_demography_navigation_tab_bars_all').parentNode,
  2419. 2417.  -     ge('ads_demography_navigation_tab_graphs').parentNode
  2420. 2418.  -   ];
  2421. 2419.  -   for (var i in navElems) {
  2422. 2420.  -     var navElem = navElems[i];
  2423. 2421.  -     addClass(navElem, 'summary_tab');
  2424. 2422.  -     removeClass(navElem, 'summary_tab_sel');
  2425. 2423.  -   }
  2426. 2424.  -   addClass(navCur, 'summary_tab_sel');
  2427. 2425.  -   removeClass(navCur, 'summary_tab');
  2428. 2426.  -
  2429. 2427.  -   // Change graph
  2430. 2428.  -   var bars1   = ge('ads_demography_bars_all_wrap1');
  2431. 2429.  -   var bars2   = ge('ads_demography_bars_all_wrap2');
  2432. 2430.  -   var graphs1 = ge('ads_demography_graphs_wrap1');
  2433. 2431.  -   var graphs2 = ge('ads_demography_graphs_wrap2');
  2434. 2432.  -
  2435. 2433.  -   if (name === 'bars_all') {
  2436. 2434.  -     setStyle(bars1,   {visibility: 'visible', height: getSize(bars2)[1] + 'px'})
  2437. 2435.  -     setStyle(bars2,   {top: '0'})
  2438. 2436.  -     setStyle(graphs1, {visibility: 'hidden', height: '0'});
  2439. 2437.  -   } else if (name === 'graphs') {
  2440. 2438.  -     if (!Ads.loadDemography(unionId)) {
  2441. 2439.  -       return;
  2442. 2440.  -     }
  2443. 2441.  -
  2444. 2442.  -     !cur.graphUsersStatsSexEmpty && cur.pageGraphs['ads_graph_users_stats_day_sex'].loadGraph(intval(cur.lastDemographySourceOffset));
  2445. 2443.  -     !cur.graphUsersStatsAgeEmpty && cur.pageGraphs['ads_graph_users_stats_day_age'].loadGraph(intval(cur.lastDemographySourceOffset) * 3 + intval(cur.lastDemographyAgeOffset));
  2446. 2444.  -     !cur.graphUsersStatsCitiesEmpty && cur.pageGraphs['ads_graph_users_stats_day_cities'].loadGraph(intval(cur.lastDemographySourceOffset));
  2447. 2445.  -
  2448. 2446.  -     setStyle(graphs2, {width: getSize(graphs1)[0] + 'px'});
  2449. 2447.  -     setStyle(graphs1, {visibility: 'visible', height: getSize(graphs2)[1] + 'px'});
  2450. 2448.  -     setStyle(bars1,   {visibility: 'hidden', height: '0'});
  2451. 2449.  -     setStyle(bars2,   {position: 'absolute', top: '-100000px'});
  2452. 2450.  -   }
  2453. 2451.  - }
  2454. 2452.  -
  2455. 2453.  - Ads.changeDemographySource = function(name) {
  2456. 2454.  -
  2457. 2455.  -   // Change navigation
  2458. 2456.  -   var clicksSideNav = ge('ads_demography_navigation_clicks');
  2459. 2457.  -   var viewsSideNav  = ge('ads_demography_navigation_views');
  2460. 2458.  -   var clicksTabNav = ge('ads_demography_navigation_tab_clicks');
  2461. 2459.  -   var viewsTabNav  = ge('ads_demography_navigation_tab_views');
  2462. 2460.  -   if (clicksTabNav) {
  2463. 2461.  -     clicksTabNav = clicksTabNav.parentNode;
  2464. 2462.  -     viewsTabNav  = viewsTabNav.parentNode;
  2465. 2463.  -   }
  2466. 2464.  -   if (name == 'clicks') {
  2467. 2465.  -     if (clicksSideNav) {
  2468. 2466.  -       if (hasClass(clicksSideNav, 'nav_selected')) {
  2469. 2467.  -         return;
  2470. 2468.  -       }
  2471. 2469.  -       addClass(clicksSideNav, 'nav_selected');
  2472. 2470.  -       removeClass(viewsSideNav, 'nav_selected');
  2473. 2471.  -     }
  2474. 2472.  -     if (clicksTabNav) {
  2475. 2473.  -       if (hasClass(clicksTabNav, 'summary_tab_sel')) {
  2476. 2474.  -         return;
  2477. 2475.  -       }
  2478. 2476.  -       addClass(clicksTabNav, 'summary_tab_sel');
  2479. 2477.  -       addClass(viewsTabNav, 'summary_tab');
  2480. 2478.  -       removeClass(clicksTabNav, 'summary_tab');
  2481. 2479.  -       removeClass(viewsTabNav, 'summary_tab_sel');
  2482. 2480.  -     }
  2483. 2481.  -   } else {
  2484. 2482.  -     if (clicksSideNav) {
  2485. 2483.  -       if (hasClass(viewsSideNav, 'nav_selected')) {
  2486. 2484.  -         return;
  2487. 2485.  -       }
  2488. 2486.  -       addClass(viewsSideNav, 'nav_selected');
  2489. 2487.  -       removeClass(clicksSideNav, 'nav_selected');
  2490. 2488.  -     }
  2491. 2489.  -     if (clicksTabNav) {
  2492. 2490.  -       if (hasClass(viewsTabNav, 'summary_tab_sel')) {
  2493. 2491.  -         return;
  2494. 2492.  -       }
  2495. 2493.  -       addClass(viewsTabNav, 'summary_tab_sel');
  2496. 2494.  -       addClass(clicksTabNav, 'summary_tab');
  2497. 2495.  -       removeClass(viewsTabNav, 'summary_tab');
  2498. 2496.  -       removeClass(clicksTabNav, 'summary_tab_sel');
  2499. 2497.  -     }
  2500. 2498.  -   }
  2501. 2499.  -
  2502. 2500.  -   // Change graph
  2503. 2501.  -   if (name == 'clicks') {
  2504. 2502.  -     cur.lastDemographySourceOffset = 0;
  2505. 2503.  -     if (cur.isDemographySvg) {
  2506. 2504.  -       each(geByClass('ads_demography_bars_clicks'), function(i, el) { el.style.visibility = 'visible'; el.style.position = 'relative'; });
  2507. 2505.  -       each(geByClass('ads_demography_bars_views'),  function(i, el) { el.style.visibility = 'hidden';  el.style.position = 'absolute'; });
  2508. 2506.  -     } else {
  2509. 2507.  -       each(geByClass('ads_demography_bars_clicks'), show);
  2510. 2508.  -       each(geByClass('ads_demography_bars_views'),  hide);
  2511. 2509.  -     }
  2512. 2510.  -     try { cur.pageGraphs['ads_graph_users_stats_day_sex'].loadGraph(intval(cur.lastDemographySourceOffset)); } catch(e) {}
  2513. 2511.  -     try { cur.pageGraphs['ads_graph_users_stats_day_age'].loadGraph(intval(cur.lastDemographySourceOffset) * 3 + intval(cur.lastDemographyAgeOffset)); } catch(e) {}
  2514. 2512.  -     try { cur.pageGraphs['ads_graph_users_stats_day_cities'].loadGraph(intval(cur.lastDemographySourceOffset)); } catch(e) {}
  2515. 2513.  -   } else {
  2516. 2514.  -     cur.lastDemographySourceOffset = 1;
  2517. 2515.  -     if (cur.isDemographySvg) {
  2518. 2516.  -       each(geByClass('ads_demography_bars_views'),  function(i, el) { el.style.visibility = 'visible'; el.style.position = 'relative'; });
  2519. 2517.  -       each(geByClass('ads_demography_bars_clicks'), function(i, el) { el.style.visibility = 'hidden';  el.style.position = 'absolute'; });
  2520. 2518.  -     } else {
  2521. 2519.  -       each(geByClass('ads_demography_bars_views'),  show);
  2522. 2520.  -       each(geByClass('ads_demography_bars_clicks'), hide);
  2523. 2521.  -     }
  2524. 2522.  -     try { cur.pageGraphs['ads_graph_users_stats_day_sex'].loadGraph(intval(cur.lastDemographySourceOffset)); } catch(e) {}
  2525. 2523.  -     try { cur.pageGraphs['ads_graph_users_stats_day_age'].loadGraph(intval(cur.lastDemographySourceOffset) * 3 + intval(cur.lastDemographyAgeOffset)); } catch(e) {}
  2526. 2524.  -     try { cur.pageGraphs['ads_graph_users_stats_day_cities'].loadGraph(intval(cur.lastDemographySourceOffset)); } catch(e) {}
  2527. 2525.  -   }
  2528. 2526.  - }
  2529. 2527.  -
  2530. 2528.  - Ads.changeDemographyAge = function(name) {
  2531. 2529.  -   // Change navigation
  2532. 2530.  -   var allNav    = ge('ads_demography_navigation_tab_age_all').parentNode;
  2533. 2531.  -   var femaleNav = ge('ads_demography_navigation_tab_age_female').parentNode;
  2534. 2532.  -   var maleNav   = ge('ads_demography_navigation_tab_age_male').parentNode;
  2535. 2533.  -   switch (name) {
  2536. 2534.  -     case 'all':
  2537. 2535.  -       if (hasClass(allNav, 'summary_tab_sel')) {
  2538. 2536.  -         return;
  2539. 2537.  -       }
  2540. 2538.  -       addClass(allNav,       'summary_tab_sel');
  2541. 2539.  -       addClass(femaleNav,    'summary_tab');
  2542. 2540.  -       addClass(maleNav,      'summary_tab');
  2543. 2541.  -       removeClass(allNav,    'summary_tab');
  2544. 2542.  -       removeClass(femaleNav, 'summary_tab_sel');
  2545. 2543.  -       removeClass(maleNav,   'summary_tab_sel');
  2546. 2544.  -       break;
  2547. 2545.  -     case 'female':
  2548. 2546.  -       if (hasClass(femaleNav, 'summary_tab_sel')) {
  2549. 2547.  -         return;
  2550. 2548.  -       }
  2551. 2549.  -       addClass(femaleNav,    'summary_tab_sel');
  2552. 2550.  -       addClass(allNav,       'summary_tab');
  2553. 2551.  -       addClass(maleNav,      'summary_tab');
  2554. 2552.  -       removeClass(femaleNav, 'summary_tab');
  2555. 2553.  -       removeClass(allNav,    'summary_tab_sel');
  2556. 2554.  -       removeClass(maleNav,   'summary_tab_sel');
  2557. 2555.  -       break;
  2558. 2556.  -     case 'male':
  2559. 2557.  -       if (hasClass(maleNav, 'summary_tab_sel')) {
  2560. 2558.  -         return;
  2561. 2559.  -       }
  2562. 2560.  -       addClass(maleNav,      'summary_tab_sel');
  2563. 2561.  -       addClass(allNav,       'summary_tab');
  2564. 2562.  -       addClass(femaleNav,    'summary_tab');
  2565. 2563.  -       removeClass(maleNav,   'summary_tab');
  2566. 2564.  -       removeClass(allNav,    'summary_tab_sel');
  2567. 2565.  -       removeClass(femaleNav, 'summary_tab_sel');
  2568. 2566.  -       break;
  2569. 2567.  -     default:
  2570. 2568.  -       return;
  2571. 2569.  -   }
  2572. 2570.  -
  2573. 2571.  -   // Change graph
  2574. 2572.  -   switch (name) {
  2575. 2573.  -     case 'all':    cur.lastDemographyAgeOffset = 0; break;
  2576. 2574.  -     case 'female': cur.lastDemographyAgeOffset = 1; break;
  2577. 2575.  -     case 'male':   cur.lastDemographyAgeOffset = 2; break;
  2578. 2576.  -     default:       return;
  2579. 2577.  -   }
  2580. 2578.  -   try { cur.pageGraphs['ads_graph_users_stats_day_age'].loadGraph(intval(cur.lastDemographySourceOffset) * 3 + intval(cur.lastDemographyAgeOffset)); } catch(e) {}
  2581. 2579.  - }
  2582. 2580.  -
  2583. 2581.  - Ads.loadDemography = function(unionId) {
  2584. 2582.  -   if (!cur.demographyDelayed) {
  2585. 2583.  -     return true;
  2586. 2584.  -   }
  2587. 2585.  -   if (!Ads.lock('load_demography', lock, unlock)) {
  2588. 2586.  -     return false;
  2589. 2587.  -   }
  2590. 2588.  -
  2591. 2589.  -   var ajaxParams = {};
  2592. 2590.  -   ajaxParams.union_id = unionId;
  2593. 2591.  -
  2594. 2592.  -   ajax.post('/ads?act=a_users_stats', ajaxParams, {onDone: onComplete, onFail: onComplete});
  2595. 2593.  -
  2596. 2594.  -   function lock() {
  2597. 2595.  -     setStyle('ads_demography_navigation_tab_progress', {visibility: 'visible'});
  2598. 2596.  -   }
  2599. 2597.  -   function unlock() {
  2600. 2598.  -     setStyle('ads_demography_navigation_tab_progress', {visibility: 'hidden'});
  2601. 2599.  -   }
  2602. 2600.  -   function onComplete(response) {
  2603. 2601.  -     Ads.unlock('load_demography');
  2604. 2602.  -     if (response && response.graphs_html && response.graphs_js) {
  2605. 2603.  -       cur.demographyDelayed = false;
  2606. 2604.  -       ge('ads_demography_graphs_wrap2').innerHTML = response.graphs_html;
  2607. 2605.  -       eval(response.graphs_js);
  2608. 2606.  -       Ads.changeDemographyView('graphs', unionId, true);
  2609. 2607.  -     }
  2610. 2608.  -     return true;
  2611. 2609.  -   }
  2612. 2610.  -
  2613. 2611.  -   return false;
  2614. 2612.  - }
  2615. 2613.  -
  2616. 2614.  - Ads.showEditAdminBox = function(event, unionId, userId, userEmail, isRemove) {
  2617. 2615.  -   if (event && (event.which > 1 || event.button > 1 || event.ctrlKey)) {
  2618. 2616.  -     return;
  2619. 2617.  -   }
  2620. 2618.  -
  2621. 2619.  -   userId = intval(userId);
  2622. 2620.  -
  2623. 2621.  -   if (!userId && !userEmail) {
  2624. 2622.  -     var userLink = ge('ads_user_link').getValue();
  2625. 2623.  -     if (!userLink) {
  2626. 2624.  -       showFastBox(getLang('ads_error_box_title'), getLang('ads_edit_admin_no_user_link'));
  2627. 2625.  -       return;
  2628. 2626.  -     }
  2629. 2627.  -   }
  2630. 2628.  -
  2631. 2629.  -   if (isRemove) {
  2632. 2630.  -     cur.editAdminBoxTitle = getLang('ads_edit_admin_box_title_remove');
  2633. 2631.  -   } else {
  2634. 2632.  -     if (userId || userEmail) {
  2635. 2633.  -       cur.editAdminBoxTitle = getLang('ads_edit_admin_box_title_edit');
  2636. 2634.  -     } else {
  2637. 2635.  -       cur.editAdminBoxTitle = getLang('ads_edit_admin_box_title_add');
  2638. 2636.  -     }
  2639. 2637.  -   }
  2640. 2638.  -
  2641. 2639.  -   var ajaxParams = {};
  2642. 2640.  -   ajaxParams.union_id = unionId;
  2643. 2641.  -   if (isRemove) {
  2644. 2642.  -     ajaxParams.action = 'remove';
  2645. 2643.  -   } else {
  2646. 2644.  -     ajaxParams.action = 'edit';
  2647. 2645.  -   }
  2648. 2646.  -   if (userId) {
  2649. 2647.  -     ajaxParams.user_link = userId;
  2650. 2648.  -   } else if (userEmail) {
  2651. 2649.  -     ajaxParams.user_link = userEmail;
  2652. 2650.  -   } else {
  2653. 2651.  -     ajaxParams.user_link = userLink;
  2654. 2652.  -   }
  2655. 2653.  -
  2656. 2654.  -   var showOptions = {params: {}};
  2657. 2655.  -   showOptions.onFail = Ads.onBoxFail;
  2658. 2656.  -   showOptions.params.width = 440;
  2659. 2657.  -
  2660. 2658.  -   showBox('/ads?act=a_edit_admin_box', ajaxParams, showOptions);
  2661. 2659.  -
  2662. 2660.  -   return false;
  2663. 2661.  - }
  2664. 2662.  -
  2665. 2663.  - Ads.showRetargetingGroupBox = function(unionId, groupId) {
  2666. 2664.  -   groupId = intval(groupId);
  2667. 2665.  -
  2668. 2666.  -   var ajaxParams = {};
  2669. 2667.  -   ajaxParams.union_id = unionId;
  2670. 2668.  -   if (groupId) {
  2671. 2669.  -     ajaxParams.group_id = groupId;
  2672. 2670.  -   }
  2673. 2671.  -
  2674. 2672.  -   var showOptions = {params: {}};
  2675. 2673.  -   showOptions.onFail = Ads.onBoxFail;
  2676. 2674.  -   showOptions.params.width = 400;
  2677. 2675.  -
  2678. 2676.  -   showBox('/ads?act=a_retargeting_group_box', ajaxParams, showOptions);
  2679. 2677.  -
  2680. 2678.  -   return false;
  2681. 2679.  - }
  2682. 2680.  -
  2683. 2681.  - Ads.showRetargetingGroupPixel = function(unionId, groupId, hash) {
  2684. 2682.  -   groupId = intval(groupId);
  2685. 2683.  -
  2686. 2684.  -   var ajaxParams = {};
  2687. 2685.  -   ajaxParams.union_id = unionId;
  2688. 2686.  -   ajaxParams.group_id = groupId;
  2689. 2687.  -   ajaxParams.hash = hash;
  2690. 2688.  -
  2691. 2689.  -   var showOptions = {params: {}};
  2692. 2690.  -   showOptions.onFail = Ads.onBoxFail;
  2693. 2691.  -   showOptions.params.width = 400;
  2694. 2692.  -
  2695. 2693.  -   showBox('/ads?act=a_get_retargeting_pixel', ajaxParams, showOptions);
  2696. 2694.  -
  2697. 2695.  -   return false;
  2698. 2696.  - }
  2699. 2697.  -
  2700. 2698.  - Ads.deleteRetargetingGroup = function(unionId, groupId, hash) {
  2701. 2699.  -   groupId = intval(groupId);
  2702. 2700.  -
  2703. 2701.  -   curBox().hide();
  2704. 2702.  -   showFastBox(getLang('ads_retargeting_del_confirm_title'), getLang('ads_retargeting_del_confirm_message'), getLang('box_yes'), function() {
  2705. 2703.  -     ajax.post('/ads', {act: 'a_del_retargeting_group', union_id: unionId, group_id: groupId, hash: hash}, {
  2706. 2704.  -       onDone: function(html) {
  2707. 2705.  -         ge('ads_retargeting_groups_table').innerHTML = html;
  2708. 2706.  -         curBox().hide();
  2709. 2707.  -       }
  2710. 2708.  -     });
  2711. 2709.  -   }, getLang('box_no'));
  2712. 2710.  -
  2713. 2711.  -   return false;
  2714. 2712.  - }
  2715. 2713.  -
  2716. 2714.  - try{stManager.done('ads.js');}catch(e){}
  2717. ------
Advertisement
Add Comment
Please, Sign In to add comment