Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - aes_light.css (Старый размер - 12168 | Новый - 0):
- 0. - #aes_light_css { display: none; }
- 1. -
- 2. - /* Size */
- 3. -
- 4. - .ads_ads_box.size_small {
- 5. - font-size: 11px;
- 6. - }
- 7. - .ads_ads_box.size_medium {
- 8. - font-size: 12px;
- 9. - }
- 10. - .ads_ads_box.size_big {
- 11. - font-size: 13px;
- 12. - }
- 13. -
- 14. - .ads_ad_box.ver.repeat_ver.size_site {
- 15. - width: 118px;
- 16. - }
- 17. - .ads_ad_box.ver.repeat_ver.size_site.news {
- 18. - width: 172px;
- 19. - }
- 20. - .ads_ad_box.ver.repeat_ver.size_small {
- 21. - width: 120px;
- 22. - }
- 23. - .ads_ad_box.ver.repeat_ver.size_medium {
- 24. - width: 135px;
- 25. - }
- 26. - .ads_ad_box.ver.repeat_ver.size_big {
- 27. - width: 150px;
- 28. - }
- 29. - .ads_ad_box.ver.repeat_hor.size_small {
- 30. - width: 132px;
- 31. - }
- 32. - .ads_ad_box.ver.repeat_hor.size_medium {
- 33. - width: 141px;
- 34. - }
- 35. - .ads_ad_box.ver.repeat_hor.size_big {
- 36. - width: 150px;
- 37. - }
- 38. - .ads_ad_box2.ver.repeat_ver.size_site {
- 39. - width: 112px;
- 40. - padding-left: 3px;
- 41. - padding-right: 3px;
- 42. - }
- 43. - .ads_ad_box2.ver.repeat_ver.size_site.news {
- 44. - width: 172px;
- 45. - padding: 0;
- 46. - }
- 47. - .ads_ad_box2.ver.repeat_ver.size_small {
- 48. - width: 112px;
- 49. - padding-left: 4px;
- 50. - padding-right: 4px;
- 51. - }
- 52. - .ads_ad_box2.ver.repeat_ver.size_medium {
- 53. - width: 121px;
- 54. - padding-left: 7px;
- 55. - padding-right: 7px;
- 56. - }
- 57. - .ads_ad_box2.ver.repeat_ver.size_big {
- 58. - width: 130px;
- 59. - padding-left: 10px;
- 60. - padding-right: 10px;
- 61. - }
- 62. - .ads_ad_box2.ver.repeat_hor.size_small,
- 63. - .ads_ad_box2.ver.repeat_hor.size_medium,
- 64. - .ads_ad_box2.ver.repeat_hor.size_big {
- 65. - padding-left: 10px;
- 66. - padding-right: 10px;
- 67. - }
- 68. -
- 69. - .ads_ad_box.hor.repeat_ver.size_small {
- 70. - max-width: 390px;
- 71. - }
- 72. - .ads_ad_box.hor.repeat_ver.size_medium {
- 73. - max-width: 410px;
- 74. - }
- 75. - .ads_ad_box.hor.repeat_ver.size_big {
- 76. - max-width: 430px;
- 77. - }
- 78. - .ads_ad_box.hor.repeat_hor.size_small {
- 79. - max-width: 260px;
- 80. - }
- 81. - .ads_ad_box.hor.repeat_hor.size_medium {
- 82. - max-width: 280px;
- 83. - }
- 84. - .ads_ad_box.hor.repeat_hor.size_big {
- 85. - max-width: 300px;
- 86. - }
- 87. - .ads_ad_box2.hor.repeat_ver {
- 88. - padding: 10px;
- 89. - }
- 90. - .ads_ad_box2.hor.repeat_hor {
- 91. - padding: 0 10px;
- 92. - }
- 93. - .ads_ad_box2.hor.repeat_ver.size_small {
- 94. - max-width: 370px;
- 95. - }
- 96. - .ads_ad_box2.hor.repeat_ver.size_medium {
- 97. - max-width: 390px;
- 98. - }
- 99. - .ads_ad_box2.hor.repeat_ver.size_big {
- 100. - max-width: 410px;
- 101. - }
- 102. - .ads_ad_box2.hor.repeat_hor.size_small {
- 103. - max-width: 240px;
- 104. - }
- 105. - .ads_ad_box2.hor.repeat_hor.size_medium {
- 106. - max-width: 260px;
- 107. - }
- 108. - .ads_ad_box2.hor.repeat_hor.size_big {
- 109. - max-width: 280px;
- 110. - }
- 111. - .ads_ad_text_box.hor.repeat_ver.size_small {
- 112. - max-width: 270px;
- 113. - }
- 114. - .ads_ad_text_box.hor.repeat_ver.size_medium {
- 115. - max-width: 290px;
- 116. - }
- 117. - .ads_ad_text_box.hor.repeat_ver.size_big {
- 118. - max-width: 310px;
- 119. - }
- 120. - .ads_ad_text_box.hor.repeat_hor.size_small {
- 121. - max-width: 140px;
- 122. - }
- 123. - .ads_ad_text_box.hor.repeat_hor.size_medium {
- 124. - max-width: 160px;
- 125. - }
- 126. - .ads_ad_text_box.hor.repeat_hor.size_big {
- 127. - max-width: 180px;
- 128. - }
- 129. -
- 130. - .ads_ad_box.hor.repeat_hor.size_small {
- 131. - height: 105px;
- 132. - max-height: 105px;
- 133. - }
- 134. - .ads_ad_box.hor.repeat_hor.size_medium {
- 135. - height: 110px;
- 136. - max-height: 110px;
- 137. - }
- 138. - .ads_ad_box.hor.repeat_hor.size_big {
- 139. - height: 115px;
- 140. - max-height: 115px;
- 141. - }
- 142. - .ads_ad_box2.hor.repeat_hor.size_small {
- 143. - height: 105px;
- 144. - }
- 145. - .ads_ad_box2.hor.repeat_hor.size_medium {
- 146. - height: 110px;
- 147. - }
- 148. - .ads_ad_box2.hor.repeat_hor.size_big {
- 149. - height: 115px;
- 150. - }
- 151. -
- 152. - .ads_ad_box5_spacer.hor.repeat_hor.size_small {
- 153. - height: 95px;
- 154. - }
- 155. - .ads_ad_box5_spacer.hor.repeat_hor.size_medium {
- 156. - height: 100px;
- 157. - }
- 158. - .ads_ad_box5_spacer.hor.repeat_hor.size_big {
- 159. - height: 105px;
- 160. - }
- 161. -
- 162. - /* Ads */
- 163. -
- 164. - .ads_ads_box {
- 165. - display: table;
- 166. - width: 100%;
- 167. - }
- 168. - .ads_ads_box2 {
- 169. - display: table-cell;
- 170. - }
- 171. - .ads_ads_box2.hor {
- 172. - vertical-align: middle;
- 173. - }
- 174. - .ads_ads_box2.ver,
- 175. - .ads_ads_box2.hor.repeat_ver {
- 176. - text-align: center;
- 177. - }
- 178. - .ads_ads_box3 {
- 179. - display: inline-block;
- 180. - }
- 181. - .ads_ads_box3.mosaic,
- 182. - .ads_ads_box3.news {
- 183. - display: block;
- 184. - width: 100%;
- 185. - position: relative;
- 186. - padding-bottom: 8px;
- 187. - }
- 188. - .ads_ads_box4.repeat_hor {
- 189. - white-space: nowrap;
- 190. - }
- 191. - .ads_ads_box4.ver.repeat_hor {
- 192. - overflow: hidden;
- 193. - padding-bottom: 20px;
- 194. - }
- 195. - .ads_ads_box4.ver.repeat_hor.with_ads_border {
- 196. - padding-bottom: 15px;
- 197. - }
- 198. - .ads_ads_box4.mosaic,
- 199. - .ads_ads_box4.news {
- 200. - display: table;
- 201. - width: 100%;
- 202. - }
- 203. -
- 204. - .ads_ads_border {
- 205. - position: absolute;
- 206. - background-color: #FFFFFF;
- 207. - border: 1px solid transparent;
- 208. - top: 0;
- 209. - bottom: 0;
- 210. - left: 0;
- 211. - right: 0;
- 212. - z-index: -10;
- 213. - }
- 214. - .ads_ads_border.mosaic {
- 215. - border-bottom: 1px solid #DCE3E9;
- 216. - z-index: auto;
- 217. - }
- 218. -
- 219. - .ads_ads_help {
- 220. - padding: 3px 0 4px 0;
- 221. - font-size: 0.91em;
- 222. - text-align: center;
- 223. - }
- 224. -
- 225. - .ads_ads_all_ads {
- 226. - padding: 3px 0 4px 0;
- 227. - font-size: 0.91em;
- 228. - text-align: center;
- 229. - }
- 230. - .ads_ads_all_ads_link {
- 231. - color: #777777;
- 232. - }
- 233. -
- 234. - .ads_ads_about {
- 235. - height: 24px;
- 236. - padding-bottom: 1px;
- 237. - font-size: 0.91em;
- 238. - text-align: center;
- 239. - display: table;
- 240. - width: 100%;
- 241. - position: relative;
- 242. - z-index: 6;
- 243. - }
- 244. - .ads_ads_about2 {
- 245. - display: table-cell;
- 246. - vertical-align: middle;
- 247. - }
- 248. - .ads_ads_about.repeat_hor {
- 249. - height: 19px;
- 250. - padding-left: 10px;
- 251. - text-align: left;
- 252. - }
- 253. - .ads_ads_about2.repeat_hor {
- 254. - vertical-align: top;
- 255. - }
- 256. - .ads_ads_about.ver.repeat_hor {
- 257. - margin-top: -20px;
- 258. - }
- 259. - .ads_ads_about.ver.repeat_hor.with_ads_border {
- 260. - margin-top: -15px;
- 261. - }
- 262. -
- 263. - /* Ad wrap */
- 264. -
- 265. - .ads_ad_box_wrap.mosaic,
- 266. - .ads_ad_box_wrap.news {
- 267. - display: table-cell;
- 268. - vertical-align: top;
- 269. - overflow: hidden;
- 270. - }
- 271. - .ads_ad_box_wrap.news {
- 272. - padding-right: 10px;
- 273. - }
- 274. -
- 275. - /* Ad */
- 276. -
- 277. - .ads_ad_box {
- 278. - display: block;
- 279. - position: relative;
- 280. - white-space: normal;
- 281. - }
- 282. - .ads_ad_box.ver.repeat_hor,
- 283. - .ads_ad_box.ver.repeat_ver.mosaic {
- 284. - overflow: hidden;
- 285. - padding-bottom: 300px;
- 286. - margin-bottom: -300px;
- 287. - }
- 288. - .ads_ad_box.repeat_hor {
- 289. - display: inline-block;
- 290. - vertical-align: top;
- 291. - }
- 292. - .ads_ad_box2 {
- 293. - overflow: hidden;
- 294. - word-wrap: break-word;
- 295. - position: relative;
- 296. - z-index: 2;
- 297. - }
- 298. - .ads_ad_box2.ver {
- 299. - display: block;
- 300. - text-align: center;
- 301. - padding-top: 8px;
- 302. - padding-bottom: 11px;
- 303. - }
- 304. - .ads_ad_box2.ver.news {
- 305. - text-align: left;
- 306. - }
- 307. - .ads_ad_box2.hor {
- 308. - display: inline-block;
- 309. - text-align: left;
- 310. - }
- 311. - .ads_ad_box2.ver.repeat_hor,
- 312. - .ads_ad_box2.ver.repeat_ver.mosaic {
- 313. - padding-bottom: 311px;
- 314. - margin-bottom: -300px;
- 315. - }
- 316. - .ads_ad_box2.hor.repeat_ver {
- 317. - width: 100%;
- 318. - }
- 319. - a.ads_ad_box2:hover {
- 320. - text-decoration: none;
- 321. - }
- 322. - .ads_ad_box3 {
- 323. - display: inline-block;
- 324. - overflow: hidden;
- 325. - height: 100%;
- 326. - }
- 327. - .ads_ad_box3.ver {
- 328. - width: 100%;
- 329. - }
- 330. - .ads_ad_box4 {
- 331. - display: table;
- 332. - height: 100%;
- 333. - }
- 334. - .ads_ad_box4.ver {
- 335. - table-layout: fixed;
- 336. - width: 100%;
- 337. - }
- 338. - .ads_ad_box5 {
- 339. - display: table-cell;
- 340. - vertical-align: middle;
- 341. - }
- 342. - .ads_ad_box5.hor.repeat_hor.max_size {
- 343. - white-space: nowrap;
- 344. - }
- 345. - .ads_ad_box5_spacer {
- 346. - display: none;
- 347. - }
- 348. - .ads_ad_box5_spacer.hor.repeat_hor {
- 349. - display: block;
- 350. - float: left;
- 351. - width: 0;
- 352. - }
- 353. - .ads_ad_box6.hor {
- 354. - display: table;
- 355. - padding-top: 6px;
- 356. - }
- 357. -
- 358. - .ads_ad_box_border {
- 359. - border: 0 solid #DCE3E9;
- 360. - position: absolute;
- 361. - top: 0;
- 362. - bottom: 0;
- 363. - left: 0;
- 364. - right: 0;
- 365. - z-index: 1;
- 366. - }
- 367. - .ads_ad_box_border.repeat_ver {
- 368. - border-bottom-width: 1px;
- 369. - }
- 370. - .ads_ad_box_border.repeat_ver.with_ads_border {
- 371. - left: 5px;
- 372. - right: 5px;
- 373. - }
- 374. - .ads_ad_box_border.repeat_ver.first {
- 375. - border-top-width: 1px;
- 376. - }
- 377. - .ads_ad_box_border.repeat_ver.first.with_ads_border {
- 378. - border-top-width: 0;
- 379. - }
- 380. - .ads_ad_box_border.repeat_ver.mosaic.first {
- 381. - border-width: 0;
- 382. - }
- 383. - .ads_ad_box_border.repeat_hor {
- 384. - border-right-width: 1px;
- 385. - bottom: -20px;
- 386. - }
- 387. - .ads_ad_box_border.repeat_hor.with_ads_border {
- 388. - top: 5px;
- 389. - bottom: -15px;
- 390. - }
- 391. - .ads_ad_box_border.repeat_hor.last {
- 392. - border-right-width: 0;
- 393. - }
- 394. -
- 395. - /* Ad parts */
- 396. -
- 397. - .ads_ad_photo_box {
- 398. - position: relative;
- 399. - }
- 400. - .ads_ad_photo_box.ver {
- 401. - padding-top: 9px;
- 402. - }
- 403. - .ads_ad_photo_box.ver.news {
- 404. - padding: 0;
- 405. - }
- 406. - .ads_ad_photo_box.hor {
- 407. - display: table-cell;
- 408. - vertical-align: top;
- 409. - padding: 3px 0;
- 410. - }
- 411. - .ads_ad_photo_box.promotion {
- 412. - max-height: 90px;
- 413. - overflow: hidden;
- 414. - }
- 415. -
- 416. - .ads_ad_text_box.hor {
- 417. - display: table-cell;
- 418. - vertical-align: top;
- 419. - padding-left: 10px;
- 420. - }
- 421. -
- 422. - .ads_ad_photo {
- 423. - display: block;
- 424. - max-width: 90px;
- 425. - }
- 426. - .ads_ad_photo.ver {
- 427. - margin: 0 auto;
- 428. - }
- 429. - .ads_ad_photo.ver.news {
- 430. - margin: 0;
- 431. - max-width: 172px;
- 432. - border-radius: 3px;
- 433. - }
- 434. -
- 435. - .ads_ad_play {
- 436. - position: absolute;
- 437. - top: 46px;
- 438. - left: 33px;
- 439. - width: 46px;
- 440. - height: 46px;
- 441. - background: url(/images/ad_video_play.png) no-repeat 0 0;
- 442. - background-size: 46px 46px;
- 443. - }
- 444. - .is_2x .ads_ad_play {
- 445. - background-image: url(/images/ad_video_play_2x.png);
- 446. - }
- 447. - .ads_ad_play.big {
- 448. - top: 66px;
- 449. - }
- 450. -
- 451. - .ads_ad_play_app {
- 452. - display: none;
- 453. - position: absolute;
- 454. - top: 33px;
- 455. - left: 26px;
- 456. - width: 54px;
- 457. - height: 16px;
- 458. - padding: 12px 54px 12px 12px;
- 459. - border-radius: 6px;
- 460. - color: #FFFFFF;
- 461. - font-weight: bold;
- 462. - white-space: nowrap;
- 463. - word-wrap: normal;
- 464. - text-align: center;
- 465. - background: url(/images/joy_white.png) no-repeat 78px 10px rgba(0, 0, 0, 0.55);
- 466. - background-size: 31px 20px;
- 467. -
- 468. - opacity: 0;
- 469. - -webkit-transition: opacity 200ms ease-out;
- 470. - -moz-transition: opacity 200ms ease-out;
- 471. - -o-transition: opacity 200ms ease-out;
- 472. - transition: opacity 200ms ease-out;
- 473. - }
- 474. - .is_2x .ads_ad_play_app {
- 475. - background-image: url(/images/joy_white_2x.png);
- 476. - }
- 477. - .ads_ad_play_app:active {
- 478. - padding-top: 13px;
- 479. - padding-bottom: 11px;
- 480. - background-position: 78px 11px;
- 481. - }
- 482. -
- 483. - .ads_ad_title_box {
- 484. - color: #36638E;
- 485. - font-weight: bold;
- 486. - }
- 487. - .ads_ad_title_box.ver.repeat_hor,
- 488. - .ads_ad_title_box.mosaic {
- 489. - display: table;
- 490. - width: 100%;
- 491. - }
- 492. - .ads_ad_title_box.news {
- 493. - padding-top: 7px;
- 494. - }
- 495. - .ads_ad_title_spacer1.ver.repeat_hor,
- 496. - .ads_ad_title_spacer1.mosaic {
- 497. - display: table-cell;
- 498. - }
- 499. - .ads_ad_title_spacer2.ver.repeat_hor,
- 500. - .ads_ad_title_spacer2.mosaic {
- 501. - visibility: hidden;
- 502. - white-space: pre;
- 503. - width: 0;
- 504. - }
- 505. - .ads_ad_title.ver.repeat_hor,
- 506. - .ads_ad_title.mosaic {
- 507. - display: table-cell;
- 508. - vertical-align: bottom;
- 509. - }
- 510. - .ads_ad_title.news:hover {
- 511. - text-decoration: underline;
- 512. - }
- 513. - .ads_ad_description {
- 514. - color: #000000;
- 515. - }
- 516. - .ads_ad_description.ver {
- 517. - padding-top: 10px;
- 518. - }
- 519. -
- 520. - .ads_ad_community_join {
- 521. - color: #2B587A;
- 522. - padding-top: 10px;
- 523. - }
- 524. - .ads_ad_community_join:hover {
- 525. - text-decoration: underline;
- 526. - cursor: pointer;
- 527. - }
- 528. -
- 529. - .ads_ad_domain {
- 530. - color: #777777;
- 531. - font-size: 0.91em;
- 532. - padding-top: 3px;
- 533. - }
- 534. - .ads_ad_domain.news {
- 535. - font-size: 1em;
- 536. - padding-top: 1px;
- 537. - }
- 538. -
- 539. - .ads_ad_disclaimers {
- 540. - color: #777777;
- 541. - font-size: 0.82em;
- 542. - line-height: 130%;
- 543. - }
- 544. - .ads_ad_disclaimer_medical.ver,
- 545. - .ads_ad_disclaimer_specialist.ver {
- 546. - padding-top: 10px;
- 547. - }
- 548. - .ads_ad_disclaimer_medical.hor,
- 549. - .ads_ad_disclaimer_specialist.hor {
- 550. - padding-top: 3px;
- 551. - }
- 552. -
- 553. - /* Ad extra */
- 554. -
- 555. - .ads_ad_external_stats {
- 556. - display: none;
- 557. - }
- 558. -
- 559. - /* Ad close */
- 560. -
- 561. - .ads_ad_close_info {
- 562. - color: #808080;
- 563. - font-size: 0.91em;
- 564. - background-color: #F7F7F7;
- 565. - height: 100%;
- 566. - width: 100%;
- 567. - overflow: hidden;
- 568. - text-align: center;
- 569. - position: absolute;
- 570. - z-index: 5;
- 571. - display: none;
- 572. - word-wrap: break-word;
- 573. - }
- 574. - .ads_ad_close_info2 {
- 575. - padding: 0 3px;
- 576. - overflow: hidden;
- 577. - height: 100%;
- 578. - position: relative;
- 579. - z-index: 2;
- 580. - }
- 581. - .ads_ad_close_info3 {
- 582. - display: table;
- 583. - table-layout: fixed;
- 584. - height: 100%;
- 585. - width: 100%;
- 586. - }
- 587. - .ads_ad_close_info4 {
- 588. - display: table-cell;
- 589. - vertical-align: middle;
- 590. - overflow: hidden;
- 591. - }
- 592. - .ads_ad_close_complain {
- 593. - padding-top: 10px;
- 594. - }
- 595. - .ads_ad_close_complain_link {
- 596. - color: #2B587A;
- 597. - }
- 598. - .ads_ad_close_complain_link:hover {
- 599. - text-decoration: underline;
- 600. - cursor: pointer;
- 601. - }
- 602. -
- 603. - /* All ads box */
- 604. -
- 605. - #ads_ads_all_ads_rows {
- 606. - overflow: hidden;
- 607. - }
- 608. - .ads_ads_all_ads_box_row {
- 609. - margin-right: -10px;
- 610. - }
- 611. - .ads_ads_all_ads_box_cell {
- 612. - padding: 14px 10px 8px 0;
- 613. - vertical-align: top;
- 614. - overflow: hidden;
- 615. - }
- 616. - .ads_ads_all_ads_box_border {
- 617. - position: relative;
- 618. - }
- 619. -
- 620. - /* News */
- 621. -
- 622. - .ads_ads_news_wrap {
- 623. - border-bottom: 1px solid #DCE3E9;
- 624. - padding-top: 10px;
- 625. - position: relative;
- 626. - }
- 627. - .ads_ads_news_left {
- 628. - position: absolute;
- 629. - }
- 630. - .ads_ads_news_right {
- 631. - padding-left: 60px;
- 632. - }
- 633. - .ads_ads_news_image {
- 634. - display: block;
- 635. - width: 50px;
- 636. - height: 50px;
- 637. - background: url(/images/joy_50.png) no-repeat 0 0;
- 638. - background-size: 50px 50px;
- 639. - }
- 640. - .is_2x .ads_ads_news_image {
- 641. - background-image: url(/images/joy_100.png);
- 642. - }
- 643. - .ads_ads_news_title {
- 644. - font-weight: bold;
- 645. - }
- 646. - .ads_ads_news_content {
- 647. - padding-top: 8px;
- 648. - padding-bottom: 2px;
- 649. - margin-right: -10px;
- 650. - }
- 651. - .ads_ads_news_close {
- 652. - position: absolute;
- 653. - background: url(/images/pics/statusx_op.gif) no-repeat scroll 0 0;
- 654. - background-size: 11px 11px;
- 655. - width: 11px;
- 656. - height: 11px;
- 657. - top: 10px;
- 658. - right: 0;
- 659. - opacity: 0;
- 660. - cursor: pointer;
- 661. - }
- 662. - .is_2x .ads_ads_news_close {
- 663. - background-image: url(/images/pics/statusx_op_2x.gif);
- 664. - }
- 665. - .ads_ads_news_close_tooltip {
- 666. - display: none;
- 667. - }
- 668. -
- 669. - .ads_ads_news_wrap .ads_ad_box_border.news {
- 670. - border: 0;
- 671. - }
- 672. - .ads_ads_news_wrap .ads_ad_play_app {
- 673. - display: block;
- 674. - }
- 675. - .ads_ads_news_wrap .ads_ad_box:hover .ads_ad_play_app {
- 676. - opacity: 1;
- 677. - }
- ------
- Файл - aes_light.js (Старый размер - 36758 | Новый - 0):
- 0. - (function() {
- 1. -
- 2. - var AdsLight = {};
- 3. -
- 4. - var isVkDomain = (document.domain === 'vk.com');
- 5. -
- 6. - var uaLight = navigator.userAgent.toLowerCase();
- 7. - var browserLight = {
- 8. - msie6: (/msie 6/i.test(uaLight) && !/opera/i.test(uaLight)),
- 9. - msie7: (/msie 7/i.test(uaLight) && !/opera/i.test(uaLight)),
- 10. - msie8: (/msie 8/i.test(uaLight) && !/opera/i.test(uaLight))
- 11. - };
- 12. -
- 13. - if (isVkDomain) {
- 14. - if (!('__adsLoaded' in window)) window.__adsLoaded = vkNow();
- 15. - window.AdsLight = AdsLight;
- 16. - }
- 17. -
- 18. - AdsLight.init = function() {
- 19. - if (window.vk__adsLight) {
- 20. - return;
- 21. - }
- 22. -
- 23. - window.vk__adsLight = {};
- 24. -
- 25. - AdsLight.initUserHandlers();
- 26. -
- 27. - vk__adsLight.widgetsIds = {};
- 28. - vk__adsLight.observersInited = false;
- 29. - vk__adsLight.publishTimers = {};
- 30. -
- 31. - vk__adsLight.windowId = Math.round(Math.random() * 1000000000 + 1);
- 32. - vk__adsLight.activeTab = 0;
- 33. - vk__adsLight.userEventTime = 0;
- 34. - vk__adsLight.wrapVisible = false;
- 35. - vk__adsLight.imagesTimer = false;
- 36. - vk__adsLight.reloadTimer = false;
- 37. - vk__adsLight.updateBlockTimer = false;
- 38. -
- 39. - vk__adsLight.adsCanShow = 1;
- 40. - vk__adsLight.adsSection = false;
- 41. - vk__adsLight.adsShowed = '';
- 42. - vk__adsLight.adsShowedHash = +new Date;
- 43. - vk__adsLight.adsParams = false;
- 44. -
- 45. - vk__adsLight.updateProgress = 0;
- 46. - vk__adsLight.adsShowedAll = {};
- 47. -
- 48. - vk__adsLight.loadComplete = false;
- 49. - vk__adsLight.loaderParams = false;
- 50. -
- 51. - if ('onfocusin' in window) { // IE
- 52. - if (window.addEventListener) { // IE >= 9
- 53. - window.addEventListener('focusin', vk__adsLight.userHandlers.onFocusWindow, false);
- 54. - window.addEventListener('focusout', vk__adsLight.userHandlers.onBlurWindow, false);
- 55. - } else {
- 56. - if (window.attachEvent) { // IE < 9
- 57. - window.attachEvent('onfocusin', vk__adsLight.userHandlers.onFocusWindow);
- 58. - window.attachEvent('onfocusout', vk__adsLight.userHandlers.onBlurWindow);
- 59. - }
- 60. - }
- 61. - } else {
- 62. - if (window.addEventListener) { // Firefox, Opera, Google Chrome and Safari
- 63. - window.addEventListener('focus', vk__adsLight.userHandlers.onFocusWindow, true);
- 64. - window.addEventListener('blur', vk__adsLight.userHandlers.onBlurWindow, true);
- 65. - }
- 66. - }
- 67. - if (document.addEventListener) {
- 68. - window.addEventListener('scroll', vk__adsLight.userHandlers.onScrollWindow, true);
- 69. - document.addEventListener('mousedown', vk__adsLight.userHandlers.onMouseDownDocument, true);
- 70. - } else if (document.attachEvent) {
- 71. - window.attachEvent('onscroll', vk__adsLight.userHandlers.onScrollWindow);
- 72. - document.attachEvent('onmousedown', vk__adsLight.userHandlers.onMouseDownDocument);
- 73. - }
- 74. -
- 75. - if (!isVkDomain && window.VK && VK.addCallback) {
- 76. - VK.addCallback('adsPublish', AdsLight.handleEvent);
- 77. - }
- 78. -
- 79. - vk__adsLight.userHandlers.onInit(true);
- 80. - }
- 81. -
- 82. - AdsLight.initUserHandlers = function() {
- 83. -
- 84. - vk__adsLight.userHandlers = {
- 85. - onInit: onInit,
- 86. - onHasFocus: onHasFocus,
- 87. - onFocusWindow: onFocusWindow,
- 88. - onBlurWindow: onBlurWindow,
- 89. - onScrollWindow: onScrollWindow,
- 90. - onMouseDownDocument: onMouseDownDocument,
- 91. - onMouseDownDocumentAction: onMouseDownDocumentAction,
- 92. - onActiveTab: onActiveTab
- 93. - };
- 94. -
- 95. - var needBlur = false;
- 96. - var afterClickLink = false;
- 97. - var focusTime = false;
- 98. - var updateTimer = false;
- 99. - var scrollTimer = false;
- 100. -
- 101. - function onInit(eventStub) {
- 102. - AdsLight.initObservers();
- 103. -
- 104. - if (eventStub) {
- 105. - AdsLight.handleEvent('ads.onEvent', 'onInit', 0);
- 106. - }
- 107. -
- 108. - if (!eventStub) {
- 109. - AdsLight.loadAds();
- 110. - }
- 111. -
- 112. - if (document.hasFocus && document.hasFocus()) {
- 113. - onHasFocus(true);
- 114. - }
- 115. - }
- 116. - function onHasFocus(eventStub) {
- 117. - if (eventStub) {
- 118. - AdsLight.handleEvent('ads.onEvent', 'onHasFocus', 0);
- 119. - }
- 120. -
- 121. - onActiveTab();
- 122. - }
- 123. - function onFocusWindow(event) {
- 124. - if (event) {
- 125. - AdsLight.handleEvent('ads.onEvent', 'onFocusWindow', 0);
- 126. - }
- 127. -
- 128. - // Opera fix
- 129. - // May be obsolete
- 130. - if (needBlur) {
- 131. - return;
- 132. - }
- 133. - needBlur = true;
- 134. -
- 135. - focusTime = (window.vkNow && vkNow() || 0);
- 136. -
- 137. - vk__adsLight.userEventTime = (window.vkNow && vkNow() || 0);
- 138. -
- 139. - onActiveTab();
- 140. - }
- 141. - function onBlurWindow(event) {
- 142. -
- 143. - needBlur = false;
- 144. -
- 145. - if (window.vkNow && vkNow() - focusTime < 1000) {
- 146. - return;
- 147. - }
- 148. -
- 149. - if (event) {
- 150. - AdsLight.handleEvent('ads.onEvent', 'onBlurWindow', 0);
- 151. - }
- 152. -
- 153. - vk__adsLight.activeTab = (window.vkNow && -vkNow() || 0);
- 154. - }
- 155. - function onScrollWindow(event, delayed) {
- 156. - if (event && !delayed) {
- 157. - clearTimeout(scrollTimer);
- 158. - scrollTimer = setTimeout(function() {
- 159. - onScrollWindow(event, true);
- 160. - }, 100);
- 161. - return;
- 162. - }
- 163. -
- 164. - if (event) {
- 165. - AdsLight.handleEvent('ads.onEvent', 'onScrollWindow', 0);
- 166. - }
- 167. -
- 168. - vk__adsLight.userEventTime = (window.vkNow && vkNow() || 0);
- 169. -
- 170. - onActiveTab();
- 171. -
- 172. - if (isVkDomain && window.vkNow && window.vk && vk.ads_rotate_interval && isTimeToUpdate()) {
- 173. - clearTimeout(updateTimer);
- 174. - updateTimer = setTimeout(function() {
- 175. - if (isTimeToUpdate()) {
- 176. - __adsLoaded = 0;
- 177. - AdsLight.updateBlock();
- 178. - }
- 179. - }, 10);
- 180. - }
- 181. -
- 182. - function isTimeToUpdate() {
- 183. - return vk__adsLight.adsSection === 'web' && vkNow() - __adsLoaded >= vk.ads_rotate_interval || vkNow() - __adsLoaded >= vk.ads_rotate_interval * 5;
- 184. - }
- 185. - }
- 186. - function onMouseDownDocument(event) {
- 187. - if (event) {
- 188. - AdsLight.handleEvent('ads.onEvent', 'onMouseDownDocument', 0);
- 189. - }
- 190. -
- 191. - vk__adsLight.userEventTime = (window.vkNow && vkNow() || 0);
- 192. -
- 193. - onActiveTab();
- 194. -
- 195. - if (!event) {
- 196. - return;
- 197. - }
- 198. - var elem = event.target;
- 199. - while (elem) {
- 200. - if (elem.tagName == 'A') {
- 201. - break;
- 202. - }
- 203. - if (elem.onclick) {
- 204. - break;
- 205. - }
- 206. - elem = elem.parentNode;
- 207. - }
- 208. - if (!elem) {
- 209. - return;
- 210. - }
- 211. -
- 212. - onMouseDownDocumentAction(true);
- 213. - }
- 214. - function onMouseDownDocumentAction(eventStub) {
- 215. - if (eventStub) {
- 216. - AdsLight.handleEvent('ads.onEvent', 'onMouseDownDocumentAction', 0);
- 217. - }
- 218. -
- 219. - clearTimeout(updateTimer);
- 220. -
- 221. - afterClickLink = true;
- 222. - setTimeout(function() {
- 223. - afterClickLink = false;
- 224. - }, 10);
- 225. - }
- 226. - function onActiveTab(eventStub) {
- 227. - if (isVkDomain && window.vkNow && window.vk && vk.ads_rotate_interval && !afterClickLink && vk__adsLight.activeTab < 0 && vkNow() + vk__adsLight.activeTab >= 15000 && isTimeToUpdate()) {
- 228. - clearTimeout(updateTimer);
- 229. - updateTimer = setTimeout(function() {
- 230. - if (isTimeToUpdate()) {
- 231. - __adsLoaded = 0;
- 232. - AdsLight.updateBlock();
- 233. - }
- 234. - }, 10);
- 235. - }
- 236. - vk__adsLight.activeTab = 1;
- 237. -
- 238. - function isTimeToUpdate() {
- 239. - return vkNow() - __adsLoaded >= vk.ads_rotate_interval;
- 240. - }
- 241. - }
- 242. - }
- 243. -
- 244. - AdsLight.initWeb = function(adsSection, loaderParams, adsScriptVersion, adsParamsExport) {
- 245. - vk__adsLight.adsSection = adsSection;
- 246. -
- 247. - if (top === window) {
- 248. - return;
- 249. - }
- 250. -
- 251. - var rpcMethods = {
- 252. - adsPublish: function() {
- 253. - AdsLight.handleEvent.apply(AdsLight, arguments);
- 254. - },
- 255. - onAdsAttached: function() {
- 256. - vk__adsLight.rpc.callMethod('publish', 'ads.subscribeEvents');
- 257. - },
- 258. - onInit: function() {
- 259. - vk__adsLight.rpc.callMethod('publish', 'ads.subscribeEvents');
- 260. - }
- 261. - };
- 262. - try {
- 263. - vk__adsLight.rpc = new fastXDM.Client(rpcMethods);
- 264. - vk__adsLight.rpc.callMethod('adsOnInitLoader', adsScriptVersion);
- 265. - vk__adsLight.loaderParams = loaderParams;
- 266. - vk__adsLight.adsParamsExport = adsParamsExport;
- 267. - } catch (e) {
- 268. - debugLog(e);
- 269. - }
- 270. - }
- 271. -
- 272. - AdsLight.initObservers = function() {
- 273. - if (!window.VK || !VK.Observer || !VK.Observer.subscribe) {
- 274. - return;
- 275. - }
- 276. - if (vk__adsLight.observersInited) {
- 277. - return;
- 278. - }
- 279. - vk__adsLight.observersInited = true;
- 280. -
- 281. - VK.Observer.subscribe('ads.isVisibleBlockWrap', getHandler('ads.isVisibleBlockWrap'));
- 282. - VK.Observer.subscribe('ads.subscribeEvents', getHandler('ads.subscribeEvents'));
- 283. - VK.Observer.subscribe('ads.onEvent', getHandler('ads.onEvent'));
- 284. - VK.Observer.subscribe('ads.onAdsShowed', getHandler('ads.onAdsShowed'));
- 285. -
- 286. - for (var widgetId in VK.Widgets.RPC) {
- 287. - if (VK.Widgets.RPC[widgetId].methods.adsOnInit) {
- 288. - VK.Widgets.RPC[widgetId].callMethod('onAdsAttached');
- 289. - }
- 290. - }
- 291. -
- 292. - function getHandler(publishEventName) {
- 293. - return function() {
- 294. - var args = Array.prototype.slice.call(arguments);
- 295. - args.unshift(publishEventName);
- 296. - AdsLight.handleEvent.apply(AdsLight, args);
- 297. - };
- 298. - }
- 299. - }
- 300. -
- 301. - AdsLight.handleEvent = function() {
- 302. - var args = Array.prototype.slice.call(arguments);
- 303. - var publishEventName = args.shift();
- 304. - switch (publishEventName) {
- 305. - case 'ads.isVisibleBlockWrap':
- 306. - AdsLight.isVisibleBlockWrapRpc.apply(AdsLight, args);
- 307. - break;
- 308. - case 'ads.subscribeEvents':
- 309. - var widgetId = args[0];
- 310. - if (widgetId && !vk__adsLight.widgetsIds[widgetId]) {
- 311. - vk__adsLight.widgetsIds[widgetId] = true;
- 312. - }
- 313. - vk__adsLight.userHandlers.onInit(true);
- 314. - break;
- 315. - case 'ads.onEvent':
- 316. - AdsLight.onEvent.apply(AdsLight, args);
- 317. - break;
- 318. - case 'ads.onAdsShowed':
- 319. - AdsLight.onAdsShowed.apply(AdsLight, args);
- 320. - break;
- 321. - }
- 322. - }
- 323. -
- 324. - AdsLight.onEvent = function(eventName, windowsIds) {
- 325. - if (windowsIds === 0) {
- 326. - windowsIds = [];
- 327. - //windowsIds.push(Math.round(Math.random() * -1000)); // For debug
- 328. - } else {
- 329. - var isWindowCur = false;
- 330. - for (var i in windowsIds) {
- 331. - if (windowsIds[i] == vk__adsLight.windowId) {
- 332. - isWindowCur = true;
- 333. - break;
- 334. - }
- 335. - }
- 336. - if (isWindowCur) {
- 337. - return;
- 338. - }
- 339. - if (vk__adsLight.userHandlers[eventName]) {
- 340. - vk__adsLight.userHandlers[eventName](false);
- 341. - }
- 342. - }
- 343. - windowsIds.push(vk__adsLight.windowId);
- 344. -
- 345. - AdsLight.publish(false, 'ads.onEvent', eventName, windowsIds);
- 346. - }
- 347. -
- 348. - AdsLight.onAdsShowed = function(adsShowedAll) {
- 349. - if (adsShowedAll === 0) {
- 350. - adsShowedAll = {};
- 351. - }
- 352. -
- 353. - // Sort windows ids to correct compare received messages
- 354. - {
- 355. - var windowsIds = [];
- 356. - for (var windowId in adsShowedAll) {
- 357. - windowsIds.push(parseInt(windowId));
- 358. - }
- 359. - windowsIds.sort();
- 360. - }
- 361. -
- 362. - // Check for identical message was send
- 363. - {
- 364. - var publishHash = [];
- 365. - for (var i = 0, len = windowsIds.length; i < len; i++) {
- 366. - var windowId = windowsIds[i];
- 367. - publishHash.push(adsShowedAll[windowId].ads_showed_hash);
- 368. - }
- 369. - publishHash = publishHash.join('_');
- 370. -
- 371. - var noPublish = (publishHash && adsShowedAll[vk__adsLight.windowId] && publishHash === adsShowedAll[vk__adsLight.windowId].publish_hash);
- 372. - }
- 373. -
- 374. - // Add known showed ads to message
- 375. - {
- 376. - var nowTime = +new Date;
- 377. -
- 378. - if (!adsShowedAll[vk__adsLight.windowId]) {
- 379. - adsShowedAll[vk__adsLight.windowId] = {};
- 380. - windowsIds.push(vk__adsLight.windowId);
- 381. - windowsIds.sort();
- 382. - }
- 383. - adsShowedAll[vk__adsLight.windowId].ads_showed = vk__adsLight.adsShowed;
- 384. - adsShowedAll[vk__adsLight.windowId].ads_showed_hash = vk__adsLight.adsShowedHash;
- 385. - adsShowedAll[vk__adsLight.windowId].update_progress = vk__adsLight.updateProgress;
- 386. -
- 387. - for (var windowId in vk__adsLight.adsShowedAll) {
- 388. - if ((!adsShowedAll[windowId] || vk__adsLight.adsShowedAll[windowId].publish_time > adsShowedAll[windowId].publish_time) && nowTime - vk__adsLight.adsShowedAll[windowId].publish_time < 10000) {
- 389. - adsShowedAll[windowId] = vk__adsLight.adsShowedAll[windowId];
- 390. - }
- 391. - }
- 392. -
- 393. - var publishHash = [];
- 394. - for (var i = 0, len = windowsIds.length; i < len; i++) {
- 395. - var windowId = windowsIds[i];
- 396. - publishHash.push(adsShowedAll[windowId].ads_showed_hash);
- 397. - }
- 398. - publishHash = publishHash.join('_');
- 399. -
- 400. - adsShowedAll[vk__adsLight.windowId].publish_time = nowTime;
- 401. - adsShowedAll[vk__adsLight.windowId].publish_hash = publishHash;
- 402. - }
- 403. -
- 404. - // Update all showed ads
- 405. - for (var windowId in adsShowedAll) {
- 406. - vk__adsLight.adsShowedAll[windowId] = adsShowedAll[windowId];
- 407. - }
- 408. -
- 409. - if (!noPublish) {
- 410. - AdsLight.publish(true, 'ads.onAdsShowed', adsShowedAll);
- 411. - }
- 412. - }
- 413. -
- 414. - AdsLight.publish = function(delayBigPublish, publishEventName) {
- 415. -
- 416. - var args = Array.prototype.slice.call(arguments, 1);
- 417. - var args1 = args.slice();
- 418. - var args2 = args.slice();
- 419. - var args3 = args.slice();
- 420. - var args4 = args.slice();
- 421. - args1.unshift('adsPublish');
- 422. - args2.unshift('adsPublish');
- 423. - args3.unshift('adsPublish');
- 424. - args4.unshift('publish');
- 425. -
- 426. - var func;
- 427. - var funcs = [];
- 428. - if (window.VK && VK.Widgets && VK.Widgets.RPC) {
- 429. - for (var widgetId in vk__adsLight.widgetsIds) {
- 430. - if (VK.Widgets.RPC[widgetId] && VK.Widgets.RPC[widgetId].callMethod) {
- 431. - func = (function() {
- 432. - var widgetIdCur = widgetId;
- 433. - return function() {
- 434. - VK.Widgets.RPC[widgetIdCur].callMethod.apply(VK.Widgets.RPC[widgetIdCur], args1);
- 435. - }
- 436. - })();
- 437. - funcs.push(func);
- 438. - }
- 439. - }
- 440. - }
- 441. - if (!isVkDomain && window.VK && VK.callMethod) {
- 442. - func = function() {
- 443. - VK.callMethod.apply(VK, args2);
- 444. - }
- 445. - funcs.push(func);
- 446. - }
- 447. - if (isVkDomain && vk__adsLight.adsSection !== 'web' && window.cur && cur.app && cur.app.runCallback) {
- 448. - func = function() {
- 449. - cur.app.runCallback.apply(cur.app, args3);
- 450. - }
- 451. - funcs.push(func);
- 452. - }
- 453. - if (isVkDomain && vk__adsLight.adsSection === 'web' && vk__adsLight.rpc && vk__adsLight.rpc.callMethod) {
- 454. - func = function() {
- 455. - vk__adsLight.rpc.callMethod.apply(vk__adsLight.rpc, args4);
- 456. - }
- 457. - funcs.push(func);
- 458. - }
- 459. -
- 460. - clearTimeout(vk__adsLight.publishTimers[publishEventName]);
- 461. - if (funcs.length > 1 && delayBigPublish) {
- 462. - vk__adsLight.publishTimers[publishEventName] = setTimeout(publishAll, 50);
- 463. - } else {
- 464. - publishAll();
- 465. - }
- 466. -
- 467. - function publishAll() {
- 468. - for (var i = 0, len = funcs.length; i < len; i++) {
- 469. - funcs[i]();
- 470. - }
- 471. - }
- 472. - }
- 473. -
- 474. - AdsLight.canUpdate = function(forAjax) {
- 475. -
- 476. - var containerElem = ge('left_ads');
- 477. -
- 478. - var initialAjax = (forAjax && __adsLoaded === false);
- 479. -
- 480. - var result = true;
- 481. -
- 482. - // Is visible
- 483. - result = (result && containerElem && isVisible(containerElem) && (vk__adsLight.activeTab > 0 && AdsLight.isVisibleBlockWrap() || initialAjax));
- 484. - // Is reasonable
- 485. - result = (result && vk.id && (vk__adsLight.adsCanShow >= 1 || vkNow() + vk__adsLight.adsCanShow > 3600000)); // hour
- 486. -
- 487. - if (vk__adsLight.adsSection === 'web') {
- 488. - // Is reasonable
- 489. - result = (result && vk__adsLight.loadComplete === 2);
- 490. - } else {
- 491. - // Is visible
- 492. - result = (result && isVisible('side_bar') && !layers.visible && !isVisible('left_friends'));
- 493. - // Is reasonable
- 494. - result = (result && !vk.no_ads && (vk.loaded || initialAjax));
- 495. - }
- 496. -
- 497. - return result;
- 498. - }
- 499. -
- 500. - AdsLight.getAjaxParams = function(ajaxParams, ajaxOptions) {
- 501. - var ajaxParamsNew = {};
- 502. - var canUpdateBlock = AdsLight.canUpdate(true);
- 503. - if (ajaxOptions.noAds) {
- 504. - ajaxParamsNew.al_ad = 0;
- 505. - } else if (canUpdateBlock || ajaxOptions.ads) {
- 506. - if (ajaxOptions.ads || window.vkNow && window.vk && vk.ads_rotate_interval && vk__adsLight.adsSection !== 'web' && vkNow() - __adsLoaded >= vk.ads_rotate_interval) {
- 507. - __adsLoaded = vkNow();
- 508. - ajaxParamsNew.al_ad = 1;
- 509. - }
- 510. - if (ajaxParams.al_ad || ajaxParamsNew.al_ad) {
- 511. - ajaxParamsNew.ads_section = vk__adsLight.adsSection;
- 512. - ajaxParamsNew.ads_showed = AdsLight.getAdsShowed();
- 513. - }
- 514. - } else {
- 515. - ajaxParamsNew.al_ad = null;
- 516. - }
- 517. - return ajaxParamsNew;
- 518. - }
- 519. -
- 520. - AdsLight.doRequest = function(requestFunc, delayed) {
- 521. -
- 522. - var isWebLoad = (vk__adsLight.adsSection === 'web' && vk__adsLight.loadComplete === 1);
- 523. -
- 524. - if (!delayed) {
- 525. - vk__adsLight.updateProgress = 1;
- 526. - AdsLight.onAdsShowed(0);
- 527. - setTimeout(AdsLight.doRequest.pbind(requestFunc, true), 300);
- 528. - return;
- 529. - }
- 530. -
- 531. - var lastRequestWindowId = 0;
- 532. - var lastRequestWindowsIds = {};
- 533. - var intervalTimer;
- 534. - var timeoutTimer;
- 535. -
- 536. - checkRequest();
- 537. -
- 538. - function checkRequest(force) {
- 539. - var nowTime = +new Date;
- 540. - var currentRequestWindowId = 0;
- 541. - for (var windowId in vk__adsLight.adsShowedAll) {
- 542. - var windowAdsShowed = vk__adsLight.adsShowedAll[windowId];
- 543. - if (nowTime - windowAdsShowed.publish_time >= 30000) {
- 544. - delete vk__adsLight.adsShowedAll[windowId];
- 545. - } else if (!isWebLoad || !lastRequestWindowsIds[windowId]) {
- 546. - if (windowAdsShowed.update_progress == 2) {
- 547. - currentRequestWindowId = windowId;
- 548. - break;
- 549. - } else if (windowAdsShowed.update_progress == 1 && (!currentRequestWindowId || windowId < currentRequestWindowId)) {
- 550. - currentRequestWindowId = windowId;
- 551. - }
- 552. - }
- 553. - }
- 554. -
- 555. - if (force || !currentRequestWindowId || currentRequestWindowId == vk__adsLight.windowId) {
- 556. - clearInterval(intervalTimer);
- 557. - clearTimeout(timeoutTimer);
- 558. - vk__adsLight.updateProgress = 2;
- 559. - AdsLight.onAdsShowed(0);
- 560. - requestFunc();
- 561. - } else if (currentRequestWindowId != lastRequestWindowId) {
- 562. - lastRequestWindowId = currentRequestWindowId;
- 563. - clearInterval(intervalTimer);
- 564. - clearTimeout(timeoutTimer);
- 565. - intervalTimer = setInterval(checkRequest, isWebLoad ? 100 : 200);
- 566. - timeoutTimer = setTimeout(checkRequest.pbind(true), 5000 + 50);
- 567. - }
- 568. -
- 569. - lastRequestWindowsIds[currentRequestWindowId] = (lastRequestWindowsIds[currentRequestWindowId] ? lastRequestWindowsIds[currentRequestWindowId] + 1 : 1);
- 570. - }
- 571. - }
- 572. -
- 573. - AdsLight.getAdsShowed = function() {
- 574. - var adsShowed = [];
- 575. - for (var windowId in vk__adsLight.adsShowedAll) {
- 576. - var windowAdsShowed = vk__adsLight.adsShowedAll[windowId];
- 577. - if (windowAdsShowed.ads_showed) {
- 578. - adsShowed.push(windowAdsShowed.ads_showed);
- 579. - }
- 580. - }
- 581. - adsShowed = adsShowed.join(',');
- 582. - return adsShowed;
- 583. - }
- 584. -
- 585. - AdsLight.updateBlock = function(force, delayed) {
- 586. -
- 587. - if (force === 'very_lazy') {
- 588. - __adsLoaded = 0;
- 589. - return;
- 590. - }
- 591. - if (force === 'lazy') {
- 592. - if (__adsLoaded) {
- 593. - __adsLoaded = 0;
- 594. - return;
- 595. - } else {
- 596. - __adsLoaded = 0; // if __adsLoaded === false
- 597. - }
- 598. - }
- 599. - if (force === 'force') {
- 600. - __adsLoaded = 0;
- 601. - }
- 602. - if (force === 'already') {
- 603. - __adsLoaded = vkNow();
- 604. - return;
- 605. - }
- 606. -
- 607. - if (__adsLoaded || __adsLoaded === false) {
- 608. - return;
- 609. - }
- 610. -
- 611. - if (!delayed) {
- 612. - clearTimeout(vk__adsLight.updateBlockTimer);
- 613. - vk__adsLight.updateBlockTimer = setTimeout(AdsLight.updateBlock.pbind(false, 1), 1000);
- 614. - return;
- 615. - }
- 616. -
- 617. - var canUpdateBlock = AdsLight.canUpdate();
- 618. -
- 619. - if (delayed == 1) {
- 620. - setTimeout(AdsLight.updateBlock.pbind(false, 2), 500); // Period must be greater than in isVisibleBlockWrapCoords
- 621. - return;
- 622. - }
- 623. -
- 624. - if (!canUpdateBlock) {
- 625. - return;
- 626. - }
- 627. -
- 628. - __adsLoaded = vkNow();
- 629. -
- 630. - var ajaxParams = {};
- 631. - for (var i in vk__adsLight.adsParams) {
- 632. - ajaxParams[i] = vk__adsLight.adsParams[i];
- 633. - }
- 634. -
- 635. - AdsLight.doRequest(function(){
- 636. - ajaxParams.ads_showed = AdsLight.getAdsShowed();
- 637. - ajax.post('/ads_rotate.php?act=al_update_ad', ajaxParams, {ads: 1, onDone: onComplete, onFail: onComplete});
- 638. - });
- 639. -
- 640. - function onComplete() {
- 641. - vk__adsLight.updateProgress = 3;
- 642. - }
- 643. - }
- 644. -
- 645. - AdsLight.setNewBlock = function(adsHtml, adsSection, adsCanShow, adsShowed, adsParams) {
- 646. - if (typeof(adsSection) === 'string') {
- 647. - vk__adsLight.adsSection = adsSection;
- 648. - }
- 649. - vk__adsLight.adsCanShow = ((adsCanShow || adsCanShow === '0') ? 1 : -vkNow());
- 650. - vk__adsLight.adsShowed = adsShowed;
- 651. - vk__adsLight.adsShowedHash = +new Date;
- 652. - if (adsParams) {
- 653. - vk__adsLight.adsParams = adsParams;
- 654. - }
- 655. -
- 656. - if (!adsHtml) {
- 657. - if (vk.no_ads) {
- 658. - adsHtml = '';
- 659. - } else if (vk__adsLight.adsSection === 'im' && __seenAds == 0) {
- 660. - adsHtml = '';
- 661. - } else {
- 662. - AdsLight.resizeBlockWrap([0,0], false, false, true);
- 663. - return;
- 664. - }
- 665. - }
- 666. -
- 667. - __adsLoaded = vkNow();
- 668. -
- 669. - var containerElem = ge('left_ads');
- 670. - var isContainerVisible = (containerElem && isVisible(containerElem) || vk.ad_preview);
- 671. - if (!containerElem) {
- 672. - var sideBarElem = ge('side_bar');
- 673. - if (!sideBarElem) {
- 674. - AdsLight.resizeBlockWrap([0,0], false, false, true);
- 675. - return;
- 676. - }
- 677. - containerElem = sideBarElem.appendChild(ce('div', {id: 'left_ads'}, {display: isContainerVisible ? 'block' : 'none'}));
- 678. - }
- 679. -
- 680. - AdsLight.showNewBlock(containerElem, adsHtml, isContainerVisible);
- 681. -
- 682. - if (window.vk && vk.ads_rotate_interval && vk__adsLight.adsSection === 'web') {
- 683. - clearInterval(vk__adsLight.reloadTimer);
- 684. - vk__adsLight.reloadTimer = setInterval(function(){
- 685. - if (vkNow() - __adsLoaded >= vk.ads_rotate_interval && vkNow() - vk__adsLight.userEventTime <= vk.ads_rotate_interval * 3 / 4) { // Check part of ads_rotate_interval for user actions to prevent side effects when rotating ads cause window to scroll
- 686. - __adsLoaded = 0;
- 687. - AdsLight.updateBlock();
- 688. - }
- 689. - }, vk.ads_rotate_interval);
- 690. - }
- 691. -
- 692. - setTimeout(function() {
- 693. - vk__adsLight.updateProgress = 3;
- 694. - AdsLight.onAdsShowed(0);
- 695. - }, 100);
- 696. - }
- 697. -
- 698. - AdsLight.showNewBlock = function(containerElem, adsHtml, isContainerVisible) {
- 699. - if (!isContainerVisible || browserLight.msie6 || browserLight.msie7) {
- 700. - if (!isContainerVisible) {
- 701. - debugLog('Ads container is hidden');
- 702. - }
- 703. - containerElem.innerHTML = adsHtml;
- 704. - var newSize = AdsLight.getBlockSize(containerElem);
- 705. - AdsLight.resizeBlockWrap(newSize, false, false, true);
- 706. - AdsLight.updateExternalStats(containerElem);
- 707. - return;
- 708. - }
- 709. -
- 710. - var isNewBlockEmpty = !adsHtml;
- 711. - var speed = (isNewBlockEmpty ? 0 : 200);
- 712. - var oldSize = AdsLight.getBlockSize(containerElem);
- 713. - var lastSize = [0, 0];
- 714. - var newBlockElem = containerElem.appendChild(ce('div', {innerHTML: adsHtml}, {display: 'none'}));
- 715. - var newBlockSizeElem = (geByClass1('ads_ads_box3', newBlockElem) || newBlockElem);
- 716. -
- 717. - var imagesElems = geByTag('img', newBlockElem);
- 718. - var imagesObjects = [];
- 719. - for (var i = 0, len = imagesElems.length; i < len; i++) {
- 720. - var imageObject = vkImage();
- 721. - imageObject.onload = delayedResizeBlockWrap;
- 722. - imageObject.onerror = delayedResizeBlockWrap;
- 723. - imageObject.src = imagesElems[i].src;
- 724. - imagesObjects.push(imageObject);
- 725. - }
- 726. -
- 727. - // Wait images then show ads
- 728. - clearInterval(vk__adsLight.imagesTimer);
- 729. - vk__adsLight.imagesTimer = setInterval(waitIamges.pbind({count: 40}), 50); // 2 seconds
- 730. -
- 731. - function waitIamges(context) {
- 732. - if (--context.count > 0) {
- 733. - for (var i in imagesObjects) {
- 734. - if (!imagesObjects[i].width || !imagesObjects[i].height) {
- 735. - return;
- 736. - }
- 737. - }
- 738. - }
- 739. - clearInterval(vk__adsLight.imagesTimer);
- 740. - startShowing();
- 741. - }
- 742. - function delayedResizeBlockWrap() {
- 743. - if (isVisible(newBlockElem)) {
- 744. - var newSize = AdsLight.getBlockSize(newBlockSizeElem);
- 745. - newSize = AdsLight.resizeBlockWrap(newSize, oldSize, lastSize);
- 746. - }
- 747. - }
- 748. - function startShowing() {
- 749. - setStyle(containerElem, {overflow: 'hidden'});
- 750. - // zIndex: 10 - To be upper then previous block and hiders after closing ads
- 751. - // width: '100%' - For correct horizontal centering.
- 752. - setStyle(newBlockElem, {display: 'block', position: 'absolute', left: 0, top: 0, opacity: 0, zIndex: 10, width: '100%'});
- 753. -
- 754. - var newSize = AdsLight.getBlockSize(newBlockSizeElem);
- 755. - newSize = AdsLight.resizeBlockWrap(newSize, oldSize, lastSize);
- 756. -
- 757. - // Resize container
- 758. - animate(containerElem, {width: newSize[0], height: newSize[1]}, speed, showNewBlock.pbind());
- 759. - }
- 760. - function showNewBlock() {
- 761. - cleanElems(containerElem);
- 762. -
- 763. - var newSize = AdsLight.getBlockSize(newBlockSizeElem)
- 764. - newSize = AdsLight.resizeBlockWrap(newSize, false, lastSize, true);
- 765. -
- 766. - animate(newBlockElem, {opacity: 1}, speed, removeOldBlock);
- 767. - }
- 768. - function removeOldBlock() {
- 769. - cleanElems(newBlockElem);
- 770. -
- 771. - while (newBlockElem.previousSibling) {
- 772. - re(newBlockElem.previousSibling);
- 773. - }
- 774. - setStyle(newBlockElem, {position: 'static', zIndex: '', width: ''});
- 775. - setStyle(containerElem, {width: '', height: '', overflow: 'visible'});
- 776. -
- 777. - // Update site layout
- 778. - if (window.updSideTopLink) updSideTopLink();
- 779. -
- 780. - AdsLight.updateExternalStats(containerElem);
- 781. - }
- 782. - }
- 783. -
- 784. - AdsLight.updateExternalStats = function(containerElem) {
- 785. - var elems = geByClass('ads_ad_external_stats', containerElem);
- 786. - for (var i = 0, elem; elem = elems[i]; i++) {
- 787. - if (elem.getAttribute('external_stats_complete')) {
- 788. - continue;
- 789. - }
- 790. - elem.setAttribute('external_stats_complete', 1);
- 791. - vkImage().src = elem.getAttribute('external_stats_src');
- 792. - }
- 793. - }
- 794. -
- 795. - AdsLight.isVisibleBlockWrap = function(forceLocal) {
- 796. - var containerElem = ge('left_ads');
- 797. - var containerRect = containerElem.getBoundingClientRect();
- 798. - var coords = [];
- 799. - if (containerRect.right && containerRect.bottom) {
- 800. - coords.push([containerRect.left + (containerRect.right - containerRect.left) * 1 / 5, containerRect.top + (containerRect.bottom - containerRect.top) * 1 / 5]);
- 801. - coords.push([containerRect.left + (containerRect.right - containerRect.left) * 4 / 5, containerRect.top + (containerRect.bottom - containerRect.top) * 4 / 5]);
- 802. - }
- 803. -
- 804. - AdsLight.isVisibleBlockWrapCoords(coords, containerElem, onComplete, forceLocal);
- 805. -
- 806. - return vk__adsLight.wrapVisible;
- 807. -
- 808. - function onComplete(isVisibleWrap) {
- 809. - vk__adsLight.wrapVisible = isVisibleWrap;
- 810. - }
- 811. - }
- 812. -
- 813. - AdsLight.isVisibleBlockWrapCoords = function(coords, containerElem, onComplete, forceLocal) {
- 814. -
- 815. - var isVisibleWrap = false;
- 816. - var coordsNew = [];
- 817. - for (var i = 0, len = coords.length; i < len; i++) {
- 818. - var elem = document.elementFromPoint(coords[i][0], coords[i][1]);
- 819. - var isVisibleElem = (elem && (elem === containerElem || isAncestor(elem, containerElem)));
- 820. - var isVisibleWrap = (isVisibleWrap || isVisibleElem);
- 821. - if (isVisibleElem) {
- 822. - coordsNew.push(coords[i]);
- 823. - }
- 824. - }
- 825. - isVisibleWrap = !!isVisibleWrap;
- 826. -
- 827. - var completeTimer;
- 828. - var onCompleteCurrent = function(isVisibleWrapNew) {
- 829. - clearTimeout(completeTimer);
- 830. - onComplete((isVisibleWrapNew !== undefined) ? isVisibleWrapNew : isVisibleWrap);
- 831. - }
- 832. -
- 833. - if (!forceLocal && coordsNew.length && window != parent && isVkDomain && vk__adsLight.adsSection === 'web' && vk__adsLight.rpc && vk__adsLight.rpc.callMethod) {
- 834. - vk__adsLight.rpc.callMethod('publish', 'ads.isVisibleBlockWrap', coordsNew, onCompleteCurrent);
- 835. - completeTimer = setTimeout(onCompleteCurrent, 300); // Period must be lower than in updateBlock
- 836. - } else if (!forceLocal && coordsNew.length && window != parent && !isVkDomain && window.VK && VK.callMethod) {
- 837. - VK.callMethod('adsPublish', 'ads.isVisibleBlockWrap', coordsNew, onCompleteCurrent);
- 838. - completeTimer = setTimeout(onCompleteCurrent, 300); // Period must be lower than in updateBlock
- 839. - } else {
- 840. - onCompleteCurrent();
- 841. - }
- 842. -
- 843. - function isAncestor(elem, ancestor) {
- 844. - if (!elem || !ancestor) {
- 845. - return false;
- 846. - }
- 847. - while (elem = elem.parentNode) {
- 848. - if (elem === ancestor) {
- 849. - return true;
- 850. - }
- 851. - }
- 852. - return false;
- 853. - }
- 854. - }
- 855. -
- 856. - AdsLight.isVisibleBlockWrapRpc = function(coords, onComplete, widgetId) {
- 857. - var containerElem;
- 858. - if (widgetId) {
- 859. - containerElem = VK.Widgets.RPC[widgetId].frame;
- 860. - } else {
- 861. - containerElem = cur.app.frame;
- 862. - }
- 863. -
- 864. - var contanerRect = containerElem.getBoundingClientRect();
- 865. -
- 866. - var coordsNew = [];
- 867. - for (var i = 0, len = coords.length; i < len; i++) {
- 868. - var newX = coords[i][0] + contanerRect.left;
- 869. - var newY = coords[i][1] + contanerRect.top;
- 870. - coordsNew.push([newX, newY]);
- 871. - }
- 872. -
- 873. - AdsLight.isVisibleBlockWrapCoords(coordsNew, containerElem, onComplete);
- 874. - }
- 875. -
- 876. - AdsLight.getBlockSize = function(blockElem) {
- 877. - var adBoxes1 = geByClass('ads_ad_box', blockElem);
- 878. - var adBoxes5 = geByClass('ads_ad_box5', blockElem);
- 879. -
- 880. - each(adBoxes5, function(index, elem) { addClass(elem, 'max_size'); });
- 881. -
- 882. - if (browserLight.msie8) {
- 883. - each(adBoxes1, function(index, elem) {
- 884. - var width = Math.ceil(floatval(getStyle(elem, 'width')));
- 885. - var widthMax = Math.ceil(floatval(getStyle(elem, 'max-width')));
- 886. - if (widthMax && widthMax > 200 && width >= widthMax) {
- 887. - elem.style.width = widthMax + 'px';
- 888. - }
- 889. - });
- 890. - }
- 891. -
- 892. - var blockWidth = Math.ceil(floatval(getStyle(blockElem, 'width')));
- 893. - var blockHeight = Math.ceil(floatval(getStyle(blockElem, 'height')));
- 894. - var blockSize = [blockWidth, blockHeight];
- 895. -
- 896. - each(adBoxes5, function(index, elem) { removeClass(elem, 'max_size'); });
- 897. -
- 898. - return blockSize;
- 899. - }
- 900. -
- 901. - AdsLight.resizeBlockWrap = function(newSize, oldSize, lastSize, forceResize) {
- 902. - if (!newSize) {
- 903. - return [0, 0];
- 904. - }
- 905. -
- 906. - var newWidth = newSize[0];
- 907. - var newHeight = newSize[1];
- 908. - if (newWidth && vk__adsLight.adsParams && vk__adsLight.adsParams.ads_ad_unit_width_real > newWidth) {
- 909. - newWidth = vk__adsLight.adsParams.ads_ad_unit_width_real;
- 910. - }
- 911. - if (newHeight && vk__adsLight.adsParams && vk__adsLight.adsParams.ads_ad_unit_height_real > newHeight) {
- 912. - newHeight = vk__adsLight.adsParams.ads_ad_unit_height_real;
- 913. - }
- 914. - var isResizeWidth = !!(forceResize || oldSize && newWidth > oldSize[0] || lastSize && lastSize[0] && newWidth > lastSize[0]);
- 915. - var isResizeHeight = !!(forceResize || oldSize && newHeight > oldSize[1] || lastSize && lastSize[1] && newHeight > lastSize[1]);
- 916. - if (!isResizeWidth && !isResizeHeight) {
- 917. - return [newWidth, newHeight];
- 918. - }
- 919. - if (lastSize) {
- 920. - if (isResizeWidth) {
- 921. - lastSize[0] = newWidth;
- 922. - }
- 923. - if (isResizeHeight) {
- 924. - lastSize[1] = newHeight;
- 925. - }
- 926. - }
- 927. -
- 928. - if (isVkDomain && vk__adsLight.adsSection === 'web' && vk__adsLight.rpc && vk__adsLight.rpc.callMethod) {
- 929. - vk__adsLight.rpc.callMethod('resizeWidget', isResizeWidth && newWidth, isResizeHeight && newHeight);
- 930. - }
- 931. -
- 932. - return [newWidth, newHeight];
- 933. - }
- 934. -
- 935. - AdsLight.loadAds = function() {
- 936. - if (!isVkDomain || !vk__adsLight.loaderParams || vk__adsLight.loadComplete) {
- 937. - return;
- 938. - }
- 939. - vk__adsLight.loadComplete = 1;
- 940. -
- 941. - var adsParamsExport = vk__adsLight.adsParamsExport;
- 942. - delete vk__adsLight.adsParamsExport;
- 943. -
- 944. - var ajaxParams = {};
- 945. -
- 946. - for (var i in vk__adsLight.loaderParams) {
- 947. - ajaxParams[i] = vk__adsLight.loaderParams[i];
- 948. - }
- 949. -
- 950. - ajaxParams.url = document.referrer;
- 951. - try { ajaxParams.url_top = top.location.toString(); } catch (e) {}
- 952. -
- 953. - var isVisibleWeb = AdsLight.isVisibleBlockWrap(true);
- 954. - if (!isVisibleWeb) {
- 955. - ajaxParams.web_invisible = 1;
- 956. - }
- 957. -
- 958. - if (document.documentMode) {
- 959. - ajaxParams.ie_document_mode = document.documentMode;
- 960. - }
- 961. -
- 962. - AdsLight.doRequest(function(){
- 963. - ajaxParams.ads_showed = AdsLight.getAdsShowed();
- 964. - ajax.post('/ads_rotate.php?act=ads_web', ajaxParams, {onDone: onComplete, onFail: onComplete});
- 965. - });
- 966. -
- 967. - function onComplete(response, nothing, js) {
- 968. - vk__adsLight.updateProgress = 3;
- 969. -
- 970. - if (response && isObject(response) && 'ads_html' in response) {
- 971. - var styleElemOld = ge('ads_style_web_loader');
- 972. - var sheetOld = (styleElemOld.sheet ? styleElemOld.sheet : styleElemOld.styleSheet);
- 973. - var deleteFunc = (sheetOld.deleteRule ? 'deleteRule' : 'removeRule');
- 974. - sheetOld[deleteFunc](0);
- 975. -
- 976. - var styleElemNew = ce('style', {type: 'text/css'})
- 977. - if (styleElemNew.styleSheet) {
- 978. - styleElemNew.styleSheet.cssText = response.css;
- 979. - } else {
- 980. - styleElemNew.appendChild(document.createTextNode(response.css));
- 981. - }
- 982. - headNode.appendChild(styleElemNew);
- 983. -
- 984. - AdsLight.setNewBlock(response.ads_html, response.ads_section, response.ads_can_show, response.ads_showed, response.ads_params);
- 985. - vk__adsLight.rpc.callMethod('adsOnInit', response.ads_count, response.ads_params_export);
- 986. -
- 987. - vk__adsLight.loadComplete = 2;
- 988. - } else {
- 989. - if (typeof(js) === 'string') {
- 990. - try {
- 991. - eval(js);
- 992. - } catch (e) {
- 993. - debugLog(e);
- 994. - }
- 995. - }
- 996. - AdsLight.loadAdsFailed(-3001, adsParamsExport);
- 997. - }
- 998. - }
- 999. - }
- 1000. -
- 1001. - AdsLight.loadAdsFailed = function(errorCode, adsParamsExport) {
- 1002. - if (!vk__adsLight.rpc) {
- 1003. - return false;
- 1004. - }
- 1005. - if (vk__adsLight.loadComplete === -1) {
- 1006. - return true;
- 1007. - }
- 1008. - vk__adsLight.loadComplete = -1;
- 1009. -
- 1010. - vk__adsLight.rpc.callMethod('resizeWidget', 0, 0);
- 1011. - vk__adsLight.rpc.callMethod('adsOnInit', errorCode, adsParamsExport);
- 1012. -
- 1013. - return true;
- 1014. - }
- 1015. -
- 1016. - AdsLight.handleAllAds = function(box, adsIdsMore, adsIdsApply, adsHeightMore) {
- 1017. -
- 1018. - var moreLocked = false;
- 1019. - var applyLocked = false;
- 1020. - var needAdsHeight = false;
- 1021. - var needAdsApply = {};
- 1022. - var applyAllowed = false;
- 1023. -
- 1024. - boxLayerWrap.scrollTop = 0;
- 1025. -
- 1026. - var boxOptions = {};
- 1027. - boxOptions.onClean = deinit;
- 1028. - box.setOptions(boxOptions);
- 1029. -
- 1030. - if (adsIdsMore) {
- 1031. - addEvent(boxLayerWrap, 'scroll', onScroll);
- 1032. - }
- 1033. - allowApply();
- 1034. - onScroll();
- 1035. -
- 1036. - function deinit() {
- 1037. - removeEvent(boxLayerWrap, 'scroll', onScroll);
- 1038. - hide('ads_ads_all_ads_more');
- 1039. - }
- 1040. - function checkDeinit() {
- 1041. - if (!adsIdsMore && (!adsIdsApply || isEmpty(adsIdsApply) || adsIdsApply.length == 0)) {
- 1042. - deinit();
- 1043. - }
- 1044. - }
- 1045. - function allowApply(delayed) {
- 1046. - if (!delayed) {
- 1047. - setTimeout(allowApply.pbind(true), 1000);
- 1048. - return;
- 1049. - }
- 1050. - applyAllowed = true;
- 1051. - onScroll();
- 1052. - }
- 1053. - function onScroll() {
- 1054. - var moreElem = ge('ads_ads_all_ads_more');
- 1055. - if (!moreElem) {
- 1056. - return;
- 1057. - }
- 1058. - var moreRect = moreElem.getBoundingClientRect()
- 1059. - if (moreRect.top < lastWindowHeight + adsHeightMore) {
- 1060. - needAdsHeight = Math.round(Math.max(needAdsHeight, lastWindowHeight - moreRect.top + adsHeightMore));
- 1061. - moreAds();
- 1062. - }
- 1063. -
- 1064. - if (applyAllowed) {
- 1065. - var isApplyAdsUpdated = false;
- 1066. - for (var i in adsIdsApply) {
- 1067. - if (needAdsApply[i]) {
- 1068. - continue;
- 1069. - }
- 1070. - adsRowRect = ge(i).getBoundingClientRect();
- 1071. - if (adsRowRect.bottom > 0 && adsRowRect.top < lastWindowHeight) {
- 1072. - needAdsApply[i] = true;
- 1073. - isApplyAdsUpdated = true;
- 1074. - }
- 1075. - }
- 1076. - if (isApplyAdsUpdated) {
- 1077. - applyAds();
- 1078. - }
- 1079. - }
- 1080. - }
- 1081. - function moreAds(delayed) {
- 1082. - if (!delayed) {
- 1083. - setTimeout(moreAds.pbind(true), 100);
- 1084. - return;
- 1085. - }
- 1086. - if (!adsIdsMore) {
- 1087. - return;
- 1088. - }
- 1089. - if (!needAdsHeight) {
- 1090. - return;
- 1091. - }
- 1092. - if (moreLocked) {
- 1093. - return;
- 1094. - }
- 1095. - moreLocked = true;
- 1096. -
- 1097. - var ajaxParams = {};
- 1098. - ajaxParams.ads_ids_more = adsIdsMore;
- 1099. - ajaxParams.ads_height = needAdsHeight;
- 1100. -
- 1101. - ajax.post('/ads_light.php?act=all_ads_more', ajaxParams, {onDone: onDoneMoreAds.pbind(), onFail: onFailMoreAds})
- 1102. - }
- 1103. - function onDoneMoreAds(response) {
- 1104. - moreLocked = false;
- 1105. - if (!response) {
- 1106. - onFailMoreAds();
- 1107. - return;
- 1108. - }
- 1109. - adsIdsMore = response.ads_ids_more;
- 1110. - for (var i in response.ads_ids_apply) {
- 1111. - adsIdsApply[i] = response.ads_ids_apply[i];
- 1112. - }
- 1113. - if (response.ads_html) {
- 1114. - var adsElem = ge('ads_ads_all_ads_rows');
- 1115. - var moreElem = ge('ads_ads_all_ads_more');
- 1116. - if (adsElem) {
- 1117. - adsElem.innerHTML += response.ads_html;
- 1118. - needAdsHeight = false;
- 1119. - onScroll();
- 1120. - }
- 1121. - if (moreElem) {
- 1122. - moreElem.height = response.ads_more_height;
- 1123. - }
- 1124. - }
- 1125. - checkDeinit();
- 1126. - }
- 1127. - function onFailMoreAds() {
- 1128. - moreLocked = false;
- 1129. - return true;
- 1130. - }
- 1131. - function applyAds(delayed) {
- 1132. - if (!delayed) {
- 1133. - setTimeout(applyAds.pbind(true), 100);
- 1134. - return;
- 1135. - }
- 1136. - if (!adsIdsApply || isEmpty(adsIdsApply) || adsIdsApply.length == 0) {
- 1137. - checkDeinit();
- 1138. - return;
- 1139. - }
- 1140. - if (!needAdsApply || isEmpty(needAdsApply) || needAdsApply.length == 0) {
- 1141. - return;
- 1142. - }
- 1143. - if (applyLocked) {
- 1144. - return;
- 1145. - }
- 1146. - applyLocked = true;
- 1147. -
- 1148. - var ajaxParams = {};
- 1149. - ajaxParams.ads_ids_apply = [];
- 1150. -
- 1151. - for (var i in needAdsApply) {
- 1152. - ajaxParams.ads_ids_apply.push(adsIdsApply[i]);
- 1153. - delete adsIdsApply[i];
- 1154. - }
- 1155. - needAdsApply = {};
- 1156. -
- 1157. - ajaxParams.ads_ids_apply = ajaxParams.ads_ids_apply.join(';');
- 1158. -
- 1159. - ajax.post('/ads_light.php?act=all_ads_apply', ajaxParams, {onDone: onCompleteApplyAds, onFail: onCompleteApplyAds})
- 1160. - }
- 1161. - function onCompleteApplyAds(response) {
- 1162. - for (var blockIdSuffix in response) {
- 1163. - var elem = ge('ads_ad_box2_' + blockIdSuffix);
- 1164. - if (!elem) {
- 1165. - continue;
- 1166. - }
- 1167. - for (var key in response[blockIdSuffix]) {
- 1168. - elem.setAttribute(key, response[blockIdSuffix][key]);
- 1169. - }
- 1170. - }
- 1171. -
- 1172. - applyLocked = false;
- 1173. - applyAds();
- 1174. - }
- 1175. - }
- 1176. -
- 1177. - AdsLight.blockOverOut = function(event, elemCur, targetClass) {
- 1178. - var isOver = (event.type === 'mouseover');
- 1179. - var elemTarget;
- 1180. - var opacity = false;
- 1181. - if (hasClass(elemCur, targetClass)) {
- 1182. - elemTarget = elemCur;
- 1183. - toggleClass(elemTarget, 'over', isOver);
- 1184. - opacity = (isOver ? 1 : 0.3);
- 1185. - } else {
- 1186. - elemTarget = geByClass1(targetClass, elemTarget);
- 1187. - elemTarget.over = 1;
- 1188. - if (!hasClass(elemTarget, 'over')) {
- 1189. - opacity = (isOver ? 0.3 : 0);
- 1190. - }
- 1191. - }
- 1192. - if (opacity !== false) {
- 1193. - animate(elemTarget, {opacity: opacity}, 200);
- 1194. - }
- 1195. - if (isOver && elemCur == elemTarget) {
- 1196. - var tooltipTextElem = geByClass1('tooltip_text', elemTarget);
- 1197. - if (tooltipTextElem) {
- 1198. - showTooltip(elemTarget, {text: tooltipTextElem.innerHTML, showdt: 0, black: 1, shift: [14, 3, 3]});
- 1199. - }
- 1200. - }
- 1201. - }
- 1202. -
- 1203. - AdsLight.closeNewsBlock = function(elem, hash) {
- 1204. - while (!hasClass(elem, 'feed_row')) elem = elem.parentNode;
- 1205. - slideUp(elem, 200);
- 1206. - ajax.post('/ads_light.php?act=close_news', {hash: hash}, {onDone: onComplete, onFail: onComplete});
- 1207. - function onComplete() {
- 1208. - return true;
- 1209. - }
- 1210. - }
- 1211. -
- 1212. - AdsLight.init();
- 1213. -
- 1214. - })();
- 1215. -
- 1216. - try{stManager.done('aes_light.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment