1;(function(){ 2 window["UC"] = (window["UC"] || {}); 3 if (window["FCList"]) 4 return; 5 6 var safeEditing = true, 7 safeEditingCurrentObj = null, 8 quoteData = null, 9 repo = {}; 10 11 window.FCList = function (params, add) { 12 this.CID = params["CID"]; 13 this.ENTITY_XML_ID = params["ENTITY_XML_ID"]; 14 this.container = params["container"]; 15 this.nav = params["nav"]; 16 this.mid = params["mid"]; 17 this.order = params["order"]; 18 this.status = "ready"; 19 this.msg = (!!this.nav ? this.nav.innerHTML : ''); 20 this.params = (add || {}); 21 this.pullNewRecords = {}; 22 this.rights = params["rights"]; 23 this.DATE_TIME_FORMAT = (this.params["DATE_TIME_FORMAT"] || null); 24 this.comments = {}; 25 this.bindEvents = [ 26 [ 27 this.nav, "click", BX.proxy(function (e) { 28 BX.eventCancelBubble(e); 29 BX.PreventDefault(e); 30 this.get(); 31 return false; 32 }, this) 33 ] 34 ]; 35 this.windowEvents = { 36 OnUCUserIsWriting : BX.delegate(function(ENTITY_XML_ID/*, id*/) { 37 if (this.ENTITY_XML_ID == ENTITY_XML_ID) { 38 BX.ajax({ 39 url: '/bitrix/components/bitrix/main.post.list/activity.php', 40 method: 'POST', 41 dataType: 'json', 42 data: { 43 AJAX_POST : "Y", 44 ENTITY_XML_ID : this.ENTITY_XML_ID, 45 MODE : "PUSH&PULL", 46 sessid : BX.bitrix_sessid(), 47 sign : params["sign"], 48 "PATH_TO_USER" : this.params["PATH_TO_USER"], 49 "AVATAR_SIZE" : this.params["AVATAR_SIZE"], 50 "NAME_TEMPLATE" : this.params["NAME_TEMPLATE"], 51 "SHOW_LOGIN" : this.params["SHOW_LOGIN"] 52 } 53 }); 54 } 55 }, this), 56 OnUCAfterRecordAdd : BX.delegate(function(ENTITY_XML_ID, data) { 57 if (this.ENTITY_XML_ID == ENTITY_XML_ID) { 58 this.add(data["messageId"], data, true, "simple"); 59 } 60 }, this), 61 OnUCFormSubmit : BX.delegate(function(ENTITY_XML_ID/*, ENTITY_ID, obj, data*/) { 62 if (this.ENTITY_XML_ID == ENTITY_XML_ID) { 63 this.pullNewRecords[ENTITY_XML_ID + '-0'] = "busy"; 64 } 65 }, this), 66 OnUCFormResponse : BX.delegate(function(ENTITY_XML_ID, ENTITY_ID/*, obj, data*/) { 67 if (this.ENTITY_XML_ID == ENTITY_XML_ID) 68 { 69 this.pullNewRecords[ENTITY_XML_ID + '-0'] = "ready"; 70 this.pullNewRecords[ENTITY_XML_ID + '-' + ENTITY_ID] = "done"; 71 } 72 }, this), 73 OnUCUserQuote : BX.delegate(function(ENTITY_XML_ID) { 74 if (this.ENTITY_XML_ID == ENTITY_XML_ID && this.quote && this.quote.popup) 75 { 76 this.quote.popup.hide(); 77 } 78 }, this), 79 'onPullEvent-unicomments' : BX.delegate(function(command, params) { 80 if (this.ENTITY_XML_ID == params["ENTITY_XML_ID"] && (params["USER_ID"] + '') != (BX.message("USER_ID") + '')) 81 { 82 if (command == 'comment' && params["ID"]) 83 { 84 this.pullNewRecord(params); 85 } 86 else if (command == 'answer') 87 { 88 this.pullNewAuthor(params["USER_ID"], params["NAME"], params["AVATAR"]); 89 } 90 } 91 }, this) 92 }; 93 94 if (this.params && this.params["NOTIFY_TAG"] && !!this.params["NOTIFY_TEXT"] && !!window["UC"]["Informer"]) 95 { 96 this.windowEvents['OnUCCommentWasPulled'] = BX.delegate(function(id, data) 97 { 98 if (this.ENTITY_XML_ID == id[0]) { window["UC"]["Informer"].check(id, data, this.params["NOTIFY_TAG"], this.params["NOTIFY_TEXT"]) } 99 }, this); 100 window["UC"]["InformerTags"][this.params["NOTIFY_TAG"]] = (window["UC"]["InformerTags"][this.params["NOTIFY_TAG"]] || []); 101 } 102 var ii; 103 for (ii = 0; ii < this.bindEvents.length; ii++) 104 { 105 BX.bind(this.bindEvents[ii][0], this.bindEvents[ii][1], this.bindEvents[ii][2]); 106 } 107 for (ii in this.windowEvents) 108 { 109 if (this.windowEvents.hasOwnProperty(ii)) 110 { 111 BX.addCustomEvent(window, ii, this.windowEvents[ii]); 112 } 113 } 114 115 if (location.hash && parseInt(location.hash.replace("#com", "")) > 0) 116 this.checkHash(parseInt(location.hash.replace("#com", ""))); 117 118 if (this.params["BIND_VIEWER"] == "Y" && BX["viewElementBind"]) 119 { 120 BX.viewElementBind( 121 BX('record-' + this.ENTITY_XML_ID + '-new').parentNode, {}, 122 function(node){ 123 return BX.type.isElementNode(node) && (node.getAttribute('data-bx-viewer') || node.getAttribute('data-bx-image')); 124 } 125 ); 126 } 127 128 this.init(params); 129 130 if (this.mid > 0 && BX('record-' + [this.ENTITY_XML_ID, this.mid].join('-') + '-cover')) 131 { 132 var n = BX('record-' + [this.ENTITY_XML_ID, this.mid].join('-') + '-cover').parentNode.firstChild, 133 r = new RegExp("record-(" + this.ENTITY_XML_ID + ")-([0-9]+)-cover", "gi"); 134 while (BX(n)) 135 { 136 if (n["hasAttribute"] && n.hasAttribute("id") && r.test(n.getAttribute("id"))) 137 { 138 (n.getAttribute("id") + "").replace(r, function(str, ENTITY_XML_ID, mid) { 139 traceForReading([ENTITY_XML_ID, mid]); 140 }); 141 } 142 n = n.nextSibling; 143 } 144 } 145 if (repo[this.ENTITY_XML_ID]) 146 repo[this.ENTITY_XML_ID].destroy(); 147 repo[this.ENTITY_XML_ID] = this; 148 149 return this; 150 }; 151 window.FCList.prototype = { 152 destroy : function() 153 { 154 var ii, node; 155 while ((node = this.bindEvents.pop()) && node) 156 { 157 BX.unbindAll(node[0]); 158 node[0] = null; 159 node[2] = null; 160 } 161 for (ii in this.windowEvents) 162 { 163 if (this.windowEvents.hasOwnProperty(ii)) 164 { 165 BX.removeCustomEvent(window, ii, this.windowEvents[ii]); 166 this.windowEvents[ii] = null; 167 } 168 } 169 this.windowEvents = null; 170 delete repo[this.ENTITY_XML_ID]; 171 BX.onCustomEvent(window, "OnUCHasBeenDestroyed", [this.ENTITY_XML_ID, this]); 172 }, 173 init : function() 174 {
175 if (this.params["SHOW_POST_FORM"] == "Y") 176 { 177 this.quote.show = BX.delegate(function(e, params) { 178 setTimeout(BX.delegate( function() { this.quoteShow(e, params); }, this ), 50); 179 }, this 180 ); 181 var res = BX('record-' + this.ENTITY_XML_ID + '-new'), 182 nodes = BX.findChildren(res.parentNode, {"tagName" : "DIV", "className" : "feed-com-block-cover"}, false); 183 nodes = (!!nodes ? nodes : []); 184 nodes.push(res); 185 if (!!this.container) 186 nodes.push(this.container); 187 188 for (var ii = 0; ii < nodes.length; ii++) 189 { 190 BX.bind(nodes[ii], "mouseup", this.quote.show); 191 } 192 // dnd 193 var dnd = BX('record-' + this.ENTITY_XML_ID + '-switcher'); 194 if (dnd && !dnd.bxDndIsBound) 195 { 196 dnd.bxDndIsBound = "Y"; 197 BX.bind(dnd, "dragenter", BX.delegate(this.reply, this)); 198 } 199 BX.addCustomEvent(window, "onQuote"+this.ENTITY_XML_ID, this.quote.show); 200 } // only for small informer at the left bottom screens part 201 }, 202 quote : { 203 show : BX.DoNothing(), 204 popup : null 205 }, 206 quoteCheck : function() { 207 var text = '', range, author = null; 208 if (window.getSelection) 209 { 210 range = window.getSelection(); 211 text = range.toString(); 212 } 213 else if (document.selection) 214 { 215 range = document.selection; 216 text = range.createRange().text; 217 } 218 if (text != "") 219 { 220 var parent = BX('record-' + this.ENTITY_XML_ID + '-new'), 221 endParent = BX.findParent(range.focusNode, {"tagName" : "DIV", "className" : "feed-com-block-cover"}, parent.parentNode), 222 startParent = BX.findParent(range.anchorNode, {"tagName" : "DIV", "className" : "feed-com-block-cover"}, parent.parentNode); 223 if (endParent != startParent || BX(endParent) && !endParent.hasAttribute("id")) 224 { 225 text = ""; 226 } 227 else if (BX(endParent)) 228 { 229 var node = BX(endParent.getAttribute("id").replace(/\-cover$/, "-actions-reply")); 230 if (node) 231 { 232 author = { 233 id : parseInt(node.getAttribute("bx-mpl-author-id")), 234 name : node.getAttribute("bx-mpl-author-name") 235 }; 236 } 237 } 238 } 239 if (text == "") 240 { 241 if (!!this.quote.popup) 242 this.quote.popup.hide(); 243 return false; 244 } 245 return {text : text, author : author}; 246 }, 247 quoteShow : function(e, params) { 248 params = (params || this.quoteCheck()); 249 250 if (!params || !params['text']) 251 { 252 quoteData = null; 253 return; 254 } 255 quoteData = params; 256 257 if (this.quote.popup == null) 258 { 259 this.quote.popup = new MPLQuote({ 260 id : this.ENTITY_XML_ID, 261 closeByEsc : true, 262 autoHide : true, 263 autoHideTimeout : 2500, 264 events : { 265 click : BX.delegate(function(e) { 266 BX.PreventDefault(e); 267 BX.eventCancelBubble(e); 268 safeEditingCurrentObj = safeEditing; 269 BX.onCustomEvent(window, "OnUCUserQuote", [this.ENTITY_XML_ID, params['author'], params['text'], safeEditingCurrentObj]); 270 this.quote.popup.hide(); 271 return false; 272 }, this) 273 }, 274 classEvents : { 275 onQuoteHide : BX.proxy(function() { quoteData = null; this.quote.popup = null; }, this) 276 } 277 }); 278 } 279 this.quote.popup.show(e); 280 }, 281 display : function(status, startHeight) 282 { 283 var fxStart = 0, fxFinish = 0, 284 time = 0, 285 el = this.container; 286 status = (status == "hide" ? "hide" : "show"); 287 if (status == "hide") 288 { 289 fxStart = parseInt(this.container.offsetHeight); 290 time = fxStart / 2000; 291 292 time = (time < 0.3 ? 0.3 : (time > 0.5 ? 0.5 : time)); 293 el.style.overflow = 'hidden'; 294 295 (new BX["easing"]({ 296 duration : time*1000, 297 start : {height:fxStart, opacity:100}, 298 finish : {height:fxFinish, opacity:0}, 299 transition : BX.easing.makeEaseOut(BX.easing.transitions.quart), 300 step : function(state){ 301 el.style.maxHeight = state.height + "px"; 302 el.style.opacity = state.opacity / 100; 303 }, 304 complete : BX.proxy(function(){ 305 el.style.cssText = ''; 306 el.style.display = "none"; 307 BX.onCustomEvent(this, 'OnUCListWasHidden', [this, [], el]); 308 }, this) 309 })).animate(); 310 } 311 else 312 { 313 fxStart = parseInt(startHeight || 20); 314 315 el.style.display = "block"; 316 el.style.overflow = 'hidden'; 317 el.style.maxHeight = fxStart; 318 319 fxFinish = parseInt(this.container.offsetHeight); 320 time = (fxFinish - fxStart) / (2000 - fxStart); 321 time = (time < 0.3 ? 0.3 : (time > 0.8 ? 0.8 : time)); 322 (new BX["easing"]({ 323 duration : time*1000, 324 start : {height:fxStart, opacity:(fxStart > 0 ? 100 : 0)}, 325 finish : {height:fxFinish, opacity:100}, 326 transition : BX.easing.makeEaseOut(BX.easing.transitions.quart), 327 step : function(state){ 328 el.style.maxHeight = state.height + "px"; 329 el.style.opacity = state.opacity / 100; 330 }, 331 complete : BX.proxy(function(){ 332 el.style.cssText = ''; 333 el.style.maxHeight = 'none'; 334 BX.onCustomEvent(this, 'OnUCListWasShown', [this, [], el]); 335 }, this) 336 })).animate(); 337 } 338 }, 339 get : function() 340 { 341 if (this.status == "done") 342 { 343 if (this.nav.getAttribute("bx-visibility-status") == "visible") { 344 this.display("hide"); 345 BX.adjust(this.nav, {attrs : {"bx-visibility-status" : "none"}, html : this.msg}); 346 } else { 347 this.display("show"); 348 BX.adjust(this.nav, {attrs : {"bx-visibility-status" : "visible"}, html : BX.message("BLOG_C_HIDE")}); 349 } 350 } 351 else if (this.status == "ready") 352 { 353 this.send(); 354 } 355 return false;
356 }, 357 send : function() { 358 this.status = "busy"; 359 BX.addClass(this.nav, "feed-com-all-hover"); 360 var data = BX.ajax.prepareData({ 361 AJAX_POST : "Y", 362 ENTITY_XML_ID : this.ENTITY_XML_ID, 363 MODE : "LIST", 364 FILTER : (this.order == "ASC" ? {">ID" : this.mid} : {"<ID" : this.mid}), 365 sessid : BX.bitrix_sessid() } ), 366 url = BX.util.htmlspecialcharsback(this.nav.getAttribute("href")); 367 url = (url.indexOf('#') !== -1 ? url.substr(0, url.indexOf('#')) : url); 368 var result = {url : url, data : data}; 369 BX.onCustomEvent(this, "OnUCListHasToBeEnlarged", [this, result]); 370 url = result.url; 371 data = result.data; 372 BX.ajax({ 373 url: (url + (url.indexOf('?') !== -1 ? "&" : "?") + data), 374 method: 'GET', 375 dataType: 'json', 376 data: '', 377 onsuccess: BX.proxy(this.build, this), 378 onfailure: BX.proxy(this.complete, this) 379 }); 380 }, 381 build : function(data) { 382 this.status = "ready"; 383 this.wait("hide"); 384 BX.removeClass(this.nav, "feed-com-all-hover"); 385 if (!!data && data["status"] == "success") 386 { 387 var res = (!!data["navigation"] ? BX.create('DIV', {html : data["navigation"]}) : null), 388 ob = BX.processHTML(data["messageList"], false); 389 390 var offsetHeight = this.container.offsetHeight, 391 container = BX.create("DIV", {html : ob.HTML}); 392 if (this.order == "ASC" || !this.container.firstChild) 393 { 394 this.container.appendChild(container); 395 } 396 else 397 { 398 this.container.insertBefore(container, this.container.firstChild); 399 } 400 BX.onCustomEvent(window, "OnUCFeedChanged", [[this.ENTITY_XML_ID, this.mid]]); 401 402 403 this.display('show', offsetHeight); 404 if (!!res) 405 res = res.firstChild; 406 if (!!res) 407 BX.adjust(this.nav, {attrs : {href : res.getAttribute("href")}, html : res.innerHTML}); 408 else { 409 BX.adjust(this.nav, { 410 attrs : {href : "#", "bx-visibility-status" : "visible"}, html : BX.message("BLOG_C_HIDE"), 411 events : { click : function(e) { 412 BX.eventCancelBubble(e); 413 BX.PreventDefault(e); 414 return false; 415 }}}); 416 this.status = "done"; 417 } 418 var cnt = 0, 419 func = BX.delegate(function() 420 { 421 cnt++; 422 if (cnt < 100) 423 { 424 if (this.container.childNodes.length > 0) 425 { 426 BX.ajax.processScripts(ob.SCRIPT); 427 var first = container.firstChild, 428 last = container.lastChild, 429 min = 0, 430 max = 0; 431 if (first && first.hasAttribute("id")) 432 { 433 min = parseInt(first.getAttribute("id"). 434 replace("record-" + this.ENTITY_XML_ID + "-", ""). 435 replace("-cover", "") 436 ); 437 min = (min > 0 ? min : 0); 438 } 439 if (last && last.hasAttribute("id")) 440 { 441 max = parseInt(last.getAttribute("id"). 442 replace("record-" + this.ENTITY_XML_ID + "-", ""). 443 replace("-cover", "") 444 ); 445 max = (max > 0 ? max : 0); 446 } 447 if (min > max) 448 { 449 max = max + min; 450 min = max - min; 451 max = max - min; 452 } 453 container.setAttribute("bx-mpl-min", min + ''); 454 container.setAttribute("bx-mpl-max", max + ''); 455 container.setAttribute("bx-mpl-loaded", "Y"); 456 BX.onCustomEvent(this, "OnUCListWasBuilt", [this, data, container]); 457 } 458 else 459 BX.defer(func)(); 460 } 461 }, this); 462 BX.defer(func)(); 463 } 464 }, 465 complete : function() { 466 this.status = "done"; 467 BX.removeClass(this.nav, "feed-com-all-hover"); 468 this.wait("hide"); 469 }, 470 wait : function(status) { 471 status = (status == "show" ? "show" : "hide"); 472 return status; 473 }, 474 reply : function(node) { 475 safeEditingCurrentObj = safeEditing; 476 if (BX.type.isElementNode(node)) 477 BX.onCustomEvent(window, 'OnUCUserReply', [this.ENTITY_XML_ID, node.getAttribute("bx-mpl-author-id"), node.getAttribute("bx-mpl-author-name"), safeEditingCurrentObj]); 478 else 479 BX.onCustomEvent(window, 'OnUCUserReply', [this.ENTITY_XML_ID, undefined, undefined, safeEditingCurrentObj]); 480 }, 481 /* 482 * @params array data Like an { 483 errorMessage : "ERROR_MESSAGE", 484 okMessage : "OK_MESSAGE", 485 status : true, 486 message : "html text", 487 messageBBCode : "bbcode text", 488 messageId : {ENTITY_XML_ID, RESULT}, 489 messageFields : {}} 490 */ 491 add : function(id, data, edit, animation) { 492 if (!(!!data && !!id && parseInt(id[1]) > 0)) 493 return false;
494 495 var 496 container = BX('record-' + id.join('-') + '-cover'), 497 html = (!!data["message"] ? data["message"] : window.fcParseTemplate( 498 { messageFields : data["messageFields"] }, 499 { 500 RIGHTS : this.rights, 501 DATE_TIME_FORMAT : this.DATE_TIME_FORMAT, 502 VIEW_URL : this.params.VIEW_URL, 503 EDIT_URL : this.params.EDIT_URL, 504 MODERATE_URL : this.params.MODERATE_URL, 505 DELETE_URL : this.params.DELETE_URL, 506 AUTHOR_URL : this.params.AUTHOR_URL, 507 AUTHOR_URL_PARAMS : this.params.AUTHOR_URL_PARAMS, 508 509 NAME_TEMPLATE : this.params.NAME_TEMPLATE, 510 SHOW_LOGIN : this.params.SHOW_LOGIN 511 }, 512 this.getTemplate() 513 )), 514 ob = BX.processHTML(html, false), 515 results, 516 newCommentsContainer = BX('record-' + id[0] + '-new'), 517 acts = ["MODERATE", "EDIT", "DELETE"], 518 needToCheck = false, 519 height = 0; 520 for (var ii in acts) 521 { 522 if (acts.hasOwnProperty(ii)) 523 { 524 if (this.rights[acts[ii]] == "OWNLAST") 525 { 526 needToCheck = true; 527 break; 528 } 529 } 530 } 531 if (needToCheck) 532 { 533 results = (!!newCommentsContainer.lastChild && newCommentsContainer.lastChild.className == "feed-com-block-cover" ? [newCommentsContainer.lastChild] : []); 534 var res, res2; 535 if (this.addCheckPreviousNodes !== true) 536 { 537 results = BX.findChildren(newCommentsContainer.parentNode, {tagName : "DIV", "className" : "feed-com-block-cover"}, false); 538 var results2 = BX.findChildren(newCommentsContainer, {tagName : "DIV", "className" : "feed-com-block-cover"}, false); 539 results = (!!results ? results : []); results2 = (!!results2 ? results2 : []); 540 while (results2.length > 0 && (res = results2.pop()) && !!res) 541 results.push(res); 542 this.addCheckPreviousNodes = true; 543 } 544 while ((res = results.pop()) && res) 545 { 546 res2 = BX(res.id.replace("-cover", "-actions")); 547 if (!!res2) 548 { 549 if (this.rights["EDIT"] == "OWNLAST") 550 res2.setAttribute("bx-mpl-edit-show", "N"); 551 if (this.rights["MODERATE"] == "OWNLAST") 552 res2.setAttribute("bx-mpl-moderate-show", "N"); 553 if (this.rights["DELETE"] == "OWNLAST") 554 res2.setAttribute("bx-mpl-delete-show", "N"); 555 } 556 } 557 } 558 559 var changeOpacity = false; 560 if (!container) 561 { 562 container = BX.create("DIV", { 563 attrs : {id : ("record-" + id.join('-') + '-cover'), "className" : "feed-com-block-cover"}, 564 style : {opacity : 0, height : 0, overflow: "hidden"}, 565 html : ob.HTML}); 566 newCommentsContainer.appendChild(container); 567 changeOpacity = true; 568 } 569 else 570 { 571 var containerBody = BX.create("DIV", { 572 attrs : {id : ("record-" + id.join('-') + '-cover'), "className" : "feed-com-block-cover"}, 573 style : {display : "none"}, 574 html : ob.HTML}), containerForRemove = container; 575 container.parentNode.insertBefore(containerBody, container); 576 container.removeAttribute("id"); 577 height = container.scrollHeight; 578 BX.hide(container); 579 BX.show(containerBody); 580 container = containerBody; 581 setTimeout(function() { 582 BX.remove(containerForRemove); 583 }, 1000); 584 } 585 586 if (animation !== "simple") 587 { 588 var curPos = BX.pos(container), 589 scroll = BX.GetWindowScrollPos(), 590 size = BX.GetWindowInnerSize(); 591 (new BX["easing"]({ 592 duration : 1000, 593 start : { opacity : (changeOpacity ? 0 : 100), height : height}, 594 finish : { opacity: 100, height : container.scrollHeight}, 595 transition : BX.easing.makeEaseOut(BX.easing.transitions.quart), 596 step : function(state){ 597 container.style.height = state.height + "px"; 598 container.style.opacity = state.opacity / 100; 599 if (scroll.scrollTop > 0 && curPos.top < (scroll.scrollTop + size.innerHeight)) 600 window.scrollTo(0, scroll.scrollTop + state.height); 601 }, 602 603 complete : function(){ 604 container.style.cssText = ''; 605 } 606 })).animate(); 607 } 608 else 609 { 610 (new BX["easing"]({ 611 duration : 500, 612 start : { height : height, opacity : (changeOpacity ? 0 : 100)}, 613 finish : { height : container.scrollHeight, opacity : 100}, 614 transition : BX.easing.makeEaseOut(BX.easing.transitions.cubic), 615 step : function(state) { 616 container.style.height = state.height + "px"; 617 container.style.opacity = state.opacity / 100; 618 }, 619 complete : BX.proxy(function() { 620 container.style.cssText = ''; 621 BX.onCustomEvent(this, 'OnUCRecordWasShown', [this.ENTITY_XML_ID, id, container]); 622 }, this) 623 })).animate(); 624 } 625 626 627 var cnt = 0, 628 func = function() 629 { 630 cnt++; 631 if (cnt < 100) 632 { 633 var node = BX("record-" + id.join('-') + '-cover'); 634 if (node && node.childNodes.length > 0) 635 { 636 BX.ajax.processScripts(ob.SCRIPT); 637 if (this.params["BIND_VIEWER"] == "Y" && BX["viewElementBind"]) 638 { 639 BX.viewElementBind( 640 node, {}, 641 function(node){ 642 return BX.type.isElementNode(node) && (node.getAttribute('data-bx-viewer') || node.getAttribute('data-bx-image')); 643 } 644 ); 645 } 646 } 647 else 648 BX.defer(func, this)(); 649 } 650 BX.onCustomEvent(window, 'OnUCRecordHasDrawn', [this.ENTITY_XML_ID, id, data["messageFields"]]); 651 BX.onCustomEvent(window, "OnUCFeedChanged", [id]); 652 }; 653 BX.defer(func, this)(); 654 return true; 655 }, 656 pullNewAuthor : function(authorId, authorName, authorAvatar) { 657 BX.onCustomEvent(window, 'OnUCUsersAreWriting', [this.ENTITY_XML_ID, authorId, authorName, authorAvatar]); 658 }, 659 pullNewRecord : function(params) { 660 var id = [this.ENTITY_XML_ID, parseInt(params["ID"])]; 661 if (!!this.pullNewRecords[id.join('-')] && this.pullNewRecords[id.join('-')] == "busy") 662 return true; 663 else if (!!this.pullNewRecords[id[0] + '-0'] && this.pullNewRecords[id[0] + '-0'] == "busy") 664 return setTimeout(BX.proxy(function () {this.pullNewRecord(p
664arams)}, this), 100); 665 666 BX.onCustomEvent(window, "OnUCBeforeCommentWillBePulled", [id, params]); 667 668 if (params["NEED_REQUEST"] == "Y") 669 { 670 if ( 671 params['URL']['LINK'].indexOf('#GROUPS_PATH#') >= 0 672 && !!BX.message('MPL_WORKGROUPS_PATH') 673 ) 674 params['URL']['LINK'] = params['URL']['LINK'].replace('#GROUPS_PATH#', BX.message('MPL_WORKGROUPS_PATH')); 675 676 this.pullNewRecords[id.join('-')] = "busy"; 677 var data = BX.ajax.prepareData( { 678 AJAX_POST : "Y", 679 ENTITY_XML_ID : this.ENTITY_XML_ID, 680 MODE : "RECORD", 681 FILTER : {"ID" : params["ID"]}, 682 sessid : BX.bitrix_sessid() }), 683 url = params['URL']['LINK']; 684 url = (url.indexOf('#') !== -1 ? url.substr(0, url.indexOf('#')) : url); 685 BX.ajax({ 686 url: (url + (url.indexOf('?') !== -1 ? "&" : "?") + data), 687 method: 'GET', 688 dataType: 'json', 689 data: '', 690 onsuccess: BX.delegate(function(data){ 691 if (!!BX('record-' + id.join('-') + '-cover')) 692 return; 693 this.add([this.ENTITY_XML_ID, parseInt(params["ID"])], data); 694 var node = BX('record-' + id.join('-') + '-cover'), 695 node1 = BX.findChild(node, {className: 'feed-com-block'}, true, false); 696 BX.addClass(node, 'comment-new-answer'); 697 BX.addClass(node1, 'feed-com-block-pointer-to-new feed-com-block-new'); 698 this.pullNewRecords[id.join('-')] = "done"; 699 if (BX('record-' + id[0] + '-corner')) 700 { 701 BX.addClass(BX('record-' + id[0] + '-corner'), (BX.hasClass(node1, "feed-com-block-new") ? "feed-post-block-yellow-corner" :"")); 702 BX('record-' + id[0] + '-corner').removeAttribute("id"); 703 } 704 BX.onCustomEvent(window, "OnUCCommentWasPulled", [id, data]); 705 }, this) 706 }); 707 } 708 else if (params["ACTION"] == "DELETE") 709 { 710 if (BX('record-' + this.ENTITY_XML_ID + '-' + params["ID"])) 711 BX.fx.hide(BX('record-' + this.ENTITY_XML_ID + '-' + params["ID"]), 'scroll', {time : 0.2}); 712 713 BX.onCustomEvent(window, 'OnUCommentWasDeleted', [this.ENTITY_XML_ID, [this.ENTITY_XML_ID, params["ID"]], params]); 714 BX.onCustomEvent(window, "OnUCFeedChanged", [params["ID"]]); 715 } 716 else if (params["ACTION"] == "HIDE") 717 { 718 var node0 = BX('record-' + this.ENTITY_XML_ID + '-' + params["ID"]), 719 node2 = node0 ? BX.findChild(node0, {"tagName" : "DIV", "className" : "feed-com-block"}, true) : null; 720 721 if (BX(node2)) 722 { 723 if (BX.hasClass(node2, ("blog-comment-user-" + BX.message("USER_ID")))) 724 { 725 BX.removeClass(node2, "feed-com-block-approved"); 726 BX.addClass(node2, "feed-com-block-hidden"); 727 } 728 else 729 { 730 BX.fx.hide(node0, 'scroll', {time : 0.2}); 731 BX.onCustomEvent(window, 'OnUCommentWasHidden', [this.ENTITY_XML_ID, [this.ENTITY_XML_ID, params["ID"]], params]); 732 BX.onCustomEvent(window, "OnUCFeedChanged", [params["ID"]]); 733 } 734 } 735 } 736 else if (params["ACTION"] == "EDIT" && !BX('record-' + this.ENTITY_XML_ID + '-' + params["ID"])) 737 { 738 BX.DoNothing(); 739 } 740 //else if (params["ACTION"] == "MODERATE" && !BX('record-' + this.ENTITY_XML_ID + '-' + params["ID"])) 741 //{ 742 // TODO: We have to show moderated messages in a right order 743 //} 744 else 745 { 746 if (params && !(params["AUTHOR"] && (params["AUTHOR"]["ID"] + '') == (BX.message("USER_ID") + ''))) 747 params["NEW"] = "Y"; 748 this.add(id, {"messageFields" : params}); 749 var node = BX('record-' + id.join('-') + '-cover'), 750 node1 = BX.findChild(node, {className: 'feed-com-block'}, true, false); 751 if (BX('record-' + id[0] + '-corner')) 752 { 753 BX.addClass(BX('record-' + id[0] + '-corner'), (params["NEW"] == "Y" ? "feed-post-block-yellow-corner" :"")); 754 BX('record-' + id[0] + '-corner').removeAttribute("id"); 755 } 756 BX.addClass(node, 'comment-new-answer'); 757 if (params["NEW"] == "Y") 758 { 759 BX.addClass(node1, 'feed-com-block-pointer-to-new feed-com-block-new'); 760 } 761 this.pullNewRecords[id.join('-')] = "done"; 762 BX.onCustomEvent(window, "OnUCCommentWasPulled", [id, {"messageFields" : params}]) 763 } 764 return true; 765 }, 766 act : function(url, id, act) { 767 if (url.substr(0, 1) != '/') 768 { 769 try { eval(url); return false; } 770 catch(e) {} 771 if (BX.type.isFunction(url)) { 772 url(this, id, act); 773 return false;
774 } 775 } 776 this.showWait(id); 777 act = (act === "EDIT" ? "EDIT" : (act === "DELETE" ? "DELETE" : "MODERATE")); 778 id = parseInt(id); 779 var data = BX.ajax.prepareData( { 780 sessid : BX.bitrix_sessid(), 781 MODE : "RECORD", 782 NOREDIRECT : "Y", 783 AJAX_POST : "Y", 784 FILTER : {"ID" : id}, 785 ENTITY_XML_ID : this.ENTITY_XML_ID } ); 786 url = (url.indexOf('#') !== -1 ? url.substr(0, url.indexOf('#')) : url); 787 788 BX.ajax({ 789 'method': 'GET', 790 'url': (url + (url.indexOf('?') !== -1 ? "&" : "?") + data), 791 'data': '', 792 dataType: 'json', 793 onsuccess: BX.proxy(function(data) { 794 this.closeWait(id); 795 if (!!data && typeof data == "object" && data["status"] != undefined) 796 { 797 if (act !== "EDIT") 798 { 799 var container = BX('record-' + this.ENTITY_XML_ID + '-' + id + '-cover'); 800 if (!!data['message'] && !!container) 801 { 802 var 803 ob = BX.processHTML(data["message"], false); 804 container.innerHTML = ob.HTML; 805 var cnt = 0, 806 func = function() 807 { 808 cnt++; 809 if (cnt < 100) 810 { 811 if (container.childNodes.length > 0) 812 BX.ajax.processScripts(ob.SCRIPT); 813 else 814 BX.defer(func)(); 815 } 816 }; 817 BX.defer(func)(); 818 data['okMessage'] = ''; 819 } 820 else if (act == "DELETE" && !!data['okMessage']) 821 { 822 BX.hide(BX('record-' + this.ENTITY_XML_ID + '-' + id)); 823 BX.onCustomEvent(window, 'OnUCommentWasDeleted', [this.ENTITY_XML_ID, [this.ENTITY_XML_ID, id]]); 824 } 825 } 826 BX.onCustomEvent(window, 'OnUCAfterRecordEdit', [this.ENTITY_XML_ID, id, data, act]); 827 BX.onCustomEvent(window, "OnUCFeedChanged", [id]); 828 } 829 this.busy = false; 830 }, this), 831 onfailure: BX.delegate(function(){this.closeWait(id);}, this) 832 }); 833 return false; 834 }, 835 checkHash : function(ENTITY_ID) { 836 var id = [this.ENTITY_XML_ID, ENTITY_ID], 837 node = BX('record-' + id.join('-') + '-cover'); 838 if (!!node) 839 { 840 var curPos = BX.pos(node); 841 window.scrollTo(0, curPos["top"]); 842 node = BX.findChild(node, {className: 'feed-com-block'}, true, false); 843 BX.removeClass(node, "feed-com-block-pointer-to-new feed-com-block-new"); 844 BX.addClass(node, "feed-com-block-pointer"); 845 } 846 }, 847 getTemplate : function() 848 { 849 return BX.message("MPL_RECORD_TEMPLATE"); 850 }, 851 showWait : function(id) 852 { 853 window.fcShowWait(BX('record-' + this.ENTITY_XML_ID + '-' + id + '-actions')); 854 }, 855 closeWait : function(id) 856 { 857 window.fcCloseWait(BX('record-' + this.ENTITY_XML_ID + '-' + id + '-actions')||null); 858 } 859 }; 860 861 window.FCList.getQuoteData = function(){ return quoteData; }; 862 window.FCList.getInstance = function(params, add) { 863 if (!repo[params["ENTITY_XML_ID"]]) 864 new window.FCList(params, add); 865 return repo[params["ENTITY_XML_ID"]]; 866 }; 867 868 869 window["fcExpandComment"] = function(id, source) { 870 if (!BX('record-' + id + '-text')) { 871 return; 872 } 873 874 var el2 = BX('record-' + id + '-text'), 875 el = el2.parentNode, 876 fxStart = 200, 877 fxFinish = parseInt(el2.offsetHeight), 878 start1 = {height:fxStart}, 879 finish1 = {height:fxFinish}; 880 if (!!source) 881 BX.remove(source); 882 883 var time = (fxFinish - fxStart) / (2000 - fxStart); 884 time = (time < 0.3 ? 0.3 : (time > 0.8 ? 0.8 : time)); 885 886 el.style.maxHeight = start1.height+'px'; 887 el.style.overflow = 'hidden'; 888 889 (new BX["easing"]({ 890 duration : time*1000, 891 start : start1, 892 finish : finish1, 893 transition : BX.easing.makeEaseOut(BX.easing.transitions.quart), 894 step : function(state){ 895 el.style.maxHeight = state.height + "px"; 896 el.style.opacity = state.opacity / 100; 897 }, 898 complete : function(){ 899 el.style.cssText = ''; 900 el.style.maxHeight = 'none'; 901 BX.onCustomEvent(window, 'OnUCRecordWasExpanded', [el]); 902 BX.LazyLoad.showImages(true); 903 } 904 })).animate(); 905 906 BX.onCustomEvent(window, "OnUCFeedChanged", [id.split('-')]); 907 }; 908 909 var lastWaitElement = null; 910 window["fcShowWait"] = function(el) { 911 if (el && !BX.type.isElementNode(el)) 912 el = null; 913 el = el || this; 914 915 if (BX.type.isElementNode(el)) 916 { 917 BX.defer(function(){el.disabled = true})(); 918 var waiter_parent = BX.findParent(el, BX.is_relative); 919 920 el.bxwaiter = (waiter_parent || document.body).appendChild(BX.create('DIV', { 921 props: {className: 'feed-com-loader'},
922 style: {position: 'absolute'} 923 })); 924 lastWaitElement = el; 925 926 return el.bxwaiter; 927 } 928 return true; 929 }; 930 931 window["fcCloseWait"] = function(el) { 932 if (el && !BX.type.isElementNode(el)) 933 el = null; 934 el = el || lastWaitElement || this; 935 936 if (BX.type.isElementNode(el)) 937 { 938 if (el.bxwaiter && el.bxwaiter.parentNode) 939 { 940 el.bxwaiter.parentNode.removeChild(el.bxwaiter); 941 el.bxwaiter = null; 942 } 943 944 el.disabled = false; 945 if (lastWaitElement == el) 946 lastWaitElement = null; 947 } 948 }; 949 950 window["fcShowActions"] = function(ENTITY_XML_ID, ID, el) { 951 var panels = []; 952 if (el.getAttribute('bx-mpl-view-show') == 'Y') 953 { 954 panels.push({ 955 text : BX.message("MPL_MES_HREF"), 956 href : el.getAttribute('bx-mpl-view-url').replace(/\\#(.+)$/gi, "") + "#com" + ID 957 }); 958 panels.push({ 959 text : '<span id="record-popup-' + ENTITY_XML_ID + '-' + ID + '-link-text">' + BX.message("B_B_MS_LINK") + '</span>', 960 onclick : function() { 961 var 962 id = 'record-popup-' + ENTITY_XML_ID + '-' + ID + '-link', 963 it = BX.proxy_context, 964 height = parseInt(!!it.getAttribute("bx-height") ? it.getAttribute("bx-height") : it.offsetHeight); 965 966 if (it.getAttribute("bx-status") != "shown") 967 { 968 it.setAttribute("bx-status", "shown"); 969 if (!BX(id) && !!BX(id + '-text')) 970 { 971 var 972 node = BX(id + '-text'), 973 pos = BX.pos(node), 974 pos2 = BX.pos(node.parentNode), 975 nodes = BX.findChildren(node.parentNode.parentNode.parentNode, {className : "menu-popup-item-text"}, true), 976 urlView = el.getAttribute('bx-mpl-view-url').replace(/#(.+)$/gi, "") + "#com" + ID; 977 pos["height"] = pos2["height"] - 1; 978 if (nodes) 979 { 980 var width = 0, pos3; 981 for (var ii = 0; ii < nodes.length; ii++) 982 { 983 pos3 = BX.pos(nodes[ii]); 984 width = Math.max(width, pos3["width"]); 985 } 986 pos2["width"] = width; 987 } 988 BX.adjust(it, { 989 attrs : {"bx-height" : it.offsetHeight}, 990 style : { overflow : "hidden", display : 'block'}, 991 children : [ 992 BX.create('BR'), 993 BX.create('DIV', { attrs : {id : id}, 994 children : [ 995 BX.create('SPAN', {attrs : {"className" : "menu-popup-item-left"}}), 996 BX.create('SPAN', {attrs : {"className" : "menu-popup-item-icon"}}), 997 BX.create('SPAN', {attrs : {"className" : "menu-popup-item-text"}, 998 children : [ 999 BX.create('INPUT', { 1000 attrs : { 1001 id : id + '-input', 1002 type : "text", 1003 value : (urlView.indexOf('http') < 0 ? (location.protocol + '//' + location.host) : '') + urlView} , 1004 style : { 1005 height : pos2["height"] + 'px', 1006 width : pos2["width"] + 'px' 1007 }, 1008 events : { click : function(e){ this.select(); BX.PreventDefault(e);} } 1009 } 1010 ) 1011 ] 1012 }) 1013 ] 1014 }), 1015 BX.create('SPAN', {"className" : "menu-popup-item-right"}) 1016 ] 1017 }); 1018 } 1019 (new BX["fx"]({ 1020 time: 0.2, 1021 step: 0.05, 1022 type: 'linear', 1023 start: height, 1024 finish: height * 2, 1025 callback: BX.delegate(function(height) {this.style.height = height + 'px';}, it) 1026 })).start(); 1027 BX.fx.show(BX(id), 0.2); 1028 BX(id + '-input').select(); 1029 } 1030 else 1031 { 1032 it.setAttribute("bx-status", "hidden"); 1033 (new BX["fx"]({ 1034 time: 0.2, 1035 step: 0.05, 1036 type: 'linear', 1037 start: it.offsetHeight, 1038 finish: height, 1039 callback: BX.delegate(function(height) {this.style.height = height + 'px';}, it) 1040 })).start(); 1041 BX.fx.hide(BX(id), 0.2); 1042 } 1043 } 1044 }); 1045 } 1046 if (el.getAttribute('bx-mpl-edit-show') == 'Y') 1047 panels.push({ 1048 text : BX.message("BPC_MES_EDIT"), 1049 onclick : function() { window['UC'][ENTITY_XML_ID].act(el.getAttribute('bx-mpl-edit-url'), ID, 'EDIT'); this.popupWindow.close(); return false;} 1050 }); 1051 if (el.getAttribute('bx-mpl-moderate-show') == 'Y') 1052 { 1053 var hidden = el.getAttribute('bx-mpl-moderate-approved') == 'hidden'; 1054 panels.push({ 1055 text : (hidden ? BX.message("BPC_MES_SHOW") : BX.message("BPC_MES_HIDE")), 1056 onclick : function() { window['UC'][ENTITY_XML_ID]. 1057 act(el.getAttribute('bx-mpl-moderate-url').
1058 replace("#action#", (hidden ? "show" : "hide")). 1059 replace("#ACTION#", (hidden ? "SHOW" : "HIDE")), ID, 'MODERATE'); 1060 this.popupWindow.close();} 1061 }); 1062 } 1063 if (el.getAttribute('bx-mpl-delete-show') == 'Y') 1064 { 1065 panels.push({ 1066 text : BX.message("BPC_MES_DELETE"), 1067 onclick : function() { 1068 if(window.confirm(BX.message("BPC_MES_DELETE_POST_CONFIRM"))) 1069 window['UC'][ENTITY_XML_ID].act(el.getAttribute('bx-mpl-delete-url'), ID, 'DELETE'); 1070 this.popupWindow.close(); return false; 1071 } 1072 }); 1073 } 1074 1075 if ( 1076 el.getAttribute('bx-mpl-createtask-show') == 'Y' 1077 && typeof oLF != 'undefined' 1078 ) 1079 { 1080 panels.push({ 1081 text : BX.message("BPC_MES_CREATE_TASK"), 1082 onclick : function() { 1083 oLF.createTask({ 1084 entityType: 'BLOG_COMMENT', 1085 entityId: ID 1086 }); 1087 this.popupWindow.close(); return false; 1088 } 1089 }); 1090 } 1091 1092 if (panels.length > 0) { 1093 for (var ii in panels) 1094 { 1095 if (panels.hasOwnProperty(ii)) 1096 { 1097 panels[ii]['className'] = 'blog-comment-popup-menu'; 1098 } 1099 } 1100 BX.PopupMenu.show('action-' + ENTITY_XML_ID + '-' + ID, el, 1101 panels, 1102 { 1103 offsetLeft: -18, 1104 offsetTop: 2, 1105 lightShadow: false, 1106 angle: {position: 'top', offset: 50}, 1107 events : { 1108 onPopupClose : function() { this.destroy();BX.PopupMenu.Data['action-' + ENTITY_XML_ID + '-' + ID] = null; } 1109 } 1110 } 1111 ); 1112 } 1113 }; 1114 1115 /** 1116 * Parse template with params 1117 * We work with such template as array( 1118 * "messageFields" => array( 1119 "#ID#" => 1120 $res["ID"], 1121 "#FULL_ID#" => 1122 $arParams["ENTITY_XML_ID"]."-".$res["ID"], 1123 "#ENTITY_XML_ID#" => 1124 $arParams["ENTITY_XML_ID"], 1125 "#NEW#" => 1126 ($res["NEW"] == "Y" ? "new" : "old"), 1127 "#APPROVED#" => 1128 ($res["APPROVED"] != "Y" ? "hidden" : "approved"), 1129 "#DATE#" => 1130 (ConvertTimeStamp($res["POST_TIMESTAMP"], "SHORT") == $todayString ? $res["POST_TIME"] : $res["POST_DATE"]), 1131 "#TEXT#" => 1132 $res["POST_MESSAGE_TEXT"], 1133 "#CLASSNAME#" => 1134 (isset($res["CLASSNAME"]) ? " ".$res["CLASSNAME"] : ""), 1135 "#VIEW_URL#" => 1136 str_replace(array("#ID#", "#id#"), $res["ID"], $arParams["VIEW_URL"]), 1137 "#VIEW_SHOW#" => 1138 ($arParams["URL_VIEW"] == "" ? "N" : "Y"), 1139 "#EDIT_URL#" => 1140 str_replace(array("#ID#", "#id#"), $res["ID"], $arParams["EDIT_URL"]), 1141 "#EDIT_SHOW#" => 1142 ($arParams["RIGHTS"]["EDIT"] == "Y" || $arParams["RIGHTS"]["EDIT"] == "ALL" || 1143 $arParams["RIGHTS"]["EDIT"] == "OWN" && $USER->GetID() == $res["AUTHOR"]["ID"] ? "Y" : "N"), 1144 "#MODERATE_URL#" => 1145 str_replace(array("#ID#", "#id#"), $res["ID"], $arParams["MODERATE_URL"]), 1146 "#MODERATE_SHOW#" => 1147 ($arParams["RIGHTS"]["MODERATE"] == "Y" || $arParams["RIGHTS"]["MODERATE"] == "ALL" || 1148 $arParams["RIGHTS"]["MODERATE"] == "OWN" && $USER->GetID() == $res["AUTHOR"]["ID"] ? "Y" : "N"), 1149 "#DELETE_URL#" => 1150 str_replace(array("#ID#", "#id#"), $res["ID"], $arParams["DELETE_URL"]), 1151 "#DELETE_SHOW#" => 1152 ($arParams["RIGHTS"]["MODERATE"] == "Y" || $arParams["RIGHTS"]["MODERATE"] == "ALL" || 1153 $arParams["RIGHTS"]["MODERATE"] == "OWN" && $USER->GetID() == $res["AUTHOR"]["ID"] ? "Y" : "N"), 1154 "#BEFORE_HEADER#" => $res["BEFORE_HEADER"], 1155 "#BEFORE_ACTIONS#" => $res["BEFORE_ACTIONS"], 1156 "#AFTER_ACTIONS#" => $res["AFTER_ACTIONS"], 1157 "#AFTER_HEADER#" => $res["AFTER_HEADER"], 1158 "#BEFORE#" => $res["BEFORE"], 1159 "#AFTER#" => $res["AFTER"], 1160 "#BEFORE_RECORD#" => $res["BEFORE_RECORD"], 1161 "#AFTER_RECORD#" => $res["AFTER_RECORD"], 1162 "#AUTHOR_ID#" => 1163 $res["AUTHOR"]["ID"], 1164 "#AUTHOR_AVATAR_IS#" => 1165 (empty($res["AUTHOR"]["AVATAR"]) ? "N" : "Y"), 1166 "#AUTHOR_AVATAR#" => 1167 $res["AUTHOR"]["AVATAR"], 1168 "#AUTHOR_URL#" => 1169 str_replace( 1170 array("#ID#", "#id#", "#USER_ID#", "#user_id#"), 1171 array($res["ID"], $res["ID"], $res["AUTHOR"]["ID"], $res["AUTHOR"]["ID"]), 1172 $arParams["AUTHOR_URL"]), 1173 "#AUTHOR_NAME#" => 1174 CUser::FormatName( 1175 $arParams["NAME_TEMPLATE"], 1176 array( 1177 "NAME" => $res["AUTHOR"]["NAME"], 1178 "LAST_NAME" => $res["AUTHOR"]["LAST_NAME"], 1179 "SECOND_NAME" => $res["AUTHOR"]["SECOND_NAME"], 1180 "LOGIN" => $res["AUTHOR"]["LOGIN"], 1181 "NAME_LIST_FORMATTED" => "" 1182 ), 1183 ($arParams["SHOW_LOGIN"] != "N"), 1184 false),
1185 "#SHOW_POST_FORM#" => 1186 $arParams["SHOW_POST_FORM"], 1187 "#AUTHOR_EXTRANET_STYLE#" => 1188 ($res["AUTHOR"]["IS_EXTRANET"] == "Y" ? ' feed-com-name-extranet' : ''), 1189 "background:url('') no-repeat center;" => 1190 "" 1191 * ) 1192 * ) 1193 * @param data 1194 * @param params 1195 * @param txt 1196 * @return string 1197 */ 1198 window["fcParseTemplate"] = function(data, params, txt) { 1199 params = (params || {}); 1200 1201 params["RIGHTS"] = (params["RIGHTS"] || {}); 1202 for (var ii = 0, rights = ["MODERATE", "EDIT", "DELETE"]; ii < rights.length; ii++) 1203 { 1204 params["RIGHTS"][rights[ii]] = 1205 BX.util.in_array(params["RIGHTS"][rights[ii]], ["Y", "ALL", "OWN", "OWNLAST"]) ? params["RIGHTS"][rights[ii]] : "N"; 1206 } 1207 1208 params["DATE_TIME_FORMAT"] = (!!params["DATE_TIME_FORMAT"] ? params["DATE_TIME_FORMAT"] : 'd F Y G:i'); 1209 params["TIME_FORMAT"] = (!!params["DATE_TIME_FORMAT"] && params["DATE_TIME_FORMAT"].indexOf('a') >= 0 ? 'g:i a' : 'G:i'); 1210 1211 params["VIEW_URL"] = (params["VIEW_URL"] || ''); 1212 params["EDIT_URL"] = (params["EDIT_URL"] || ''); 1213 params["MODERATE_URL"] = (params["MODERATE_URL"] || ''); 1214 params["DELETE_URL"] = (params["DELETE_URL"] || ''); 1215 params["AUTHOR_URL"] = (params["AUTHOR_URL"] || ''); 1216 1217 params["NAME_TEMPLATE"] = (params["NAME_TEMPLATE"] || ''); 1218 params["SHOW_LOGIN"] = (params["SHOW_LOGIN"] || ''); 1219 var res = (data && data["messageFields"] ? data["messageFields"] : data), 1220 replacement = { 1221 "ID" : '', 1222 "FULL_ID" : '', 1223 "ENTITY_XML_ID" : '', 1224 "NEW" : "old", 1225 "APPROVED" : 'Y', 1226 "DATE" : '', 1227 "TEXT" : '', 1228 "CLASSNAME" : '', 1229 "VIEW_URL" : '', 1230 "VIEW_SHOW" : 'N', 1231 "EDIT_URL" : '', 1232 "EDIT_SHOW" : 'N', 1233 "MODERATE_URL" : '', 1234 "MODERATE_SHOW" : 'N', 1235 "DELETE_URL" : '', 1236 "DELETE_SHOW" : 'N', 1237 "BEFORE_HEADER" : '', 1238 "BEFORE_ACTIONS" : '', 1239 "AFTER_ACTIONS" : '', 1240 "AFTER_HEADER" : '', 1241 "BEFORE" : '', 1242 "AFTER" : '', 1243 "BEFORE_RECORD" : '', 1244 "AFTER_RECORD" : '', 1245 "AUTHOR_ID" : 0, 1246 "AUTHOR_AVATAR_IS" : 'N', 1247 "AUTHOR_AVATAR" : '', 1248 "AUTHOR_URL" : '', 1249 "AUTHOR_NAME" : '', 1250 "AUTHOR_EXTRANET_STYLE" : '', 1251 "SHOW_POST_FORM" : 'Y', 1252 "VOTE_ID" : "", 1253 "AUTHOR_TOOLTIP_PARAMS" : '', 1254 "background:url('') no-repeat center;" : "" 1255 }; 1256 if (!!res && !!data["messageFields"]) 1257 { 1258 res["AUTHOR"] = (!!res["AUTHOR"] ? res["AUTHOR"] : {}); 1259 var timestamp = parseInt(res["POST_TIMESTAMP"]) + parseInt(BX.message('USER_TZ_OFFSET')) + parseInt(BX.message('SERVER_TZ_OFFSET')); 1260 1261 var dateFormat = [ 1262 ['today', (params["TIME_FORMAT"].indexOf("today") < 0 ? 'today, '+params["TIME_FORMAT"] : params["TIME_FORMAT"])], 1263 ['yesterday', (params["TIME_FORMAT"].indexOf("yesterday") < 0 ? 'yesterday, '+params["TIME_FORMAT"] : params["TIME_FORMAT"])], 1264 ['', params["DATE_TIME_FORMAT"]] 1265 ]; 1266 1267 var authorStyle = ''; 1268 if (typeof res["AUTHOR"]["TYPE"] != 'undefined') 1269 { 1270 if (res["AUTHOR"]["TYPE"] == 'EMAIL') 1271 { 1272 authorStyle = ' feed-com-name-email'; 1273 } 1274 else if (res["AUTHOR"]["TYPE"] == 'EXTRANET') 1275 { 1276 authorStyle = ' feed-com-name-extranet'; 1277 } 1278 } 1279 else if (res["AUTHOR"]["IS_EXTRANET"] == "Y") 1280 { 1281 authorStyle = ' feed-com-name-extranet'; 1282 } 1283 1284 replacement = { 1285 "ID" : res["ID"], 1286 "FULL_ID" : res["FULL_ID"].join('-'), 1287 "ENTITY_XML_ID" : res["ENTITY_XML_ID"], 1288 "NEW" : res["NEW"] == "Y" ? "new" : "old", 1289 "APPROVED" : (res["APPROVED"] != "Y" ? "hidden" : "approved"), 1290 "DATE" : BX.date.format( 1291 dateFormat, 1292 timestamp, false, true 1293 ), 1294 "TEXT" : res["POST_MESSAGE_TEXT"].replace(/\001/gi, "").replace(/#/gi, "\001"), 1295 "CLASSNAME" : (res["CLASSNAME"] ? " " + res["CLASSNAME"] : ""), 1296 "VIEW_URL" : params["VIEW_URL"].replace("#ID#", res["ID"]).replace("#id#", res["ID"]), 1297 "VIEW_SHOW" : (params["VIEW_URL"] !== '' ? "Y" : "N"), 1298 "EDIT_URL" : params["EDIT_URL"].replace("#ID#", res["ID"]).replace("#id#", res["ID"]), 1299 "EDIT_SHOW" : (params["RIGHTS"]["EDIT"] == "Y" || params["RIGHTS"]["EDIT"] == "ALL" || 1300 params["RIGHTS"]["EDIT"] == "OWN" && BX.message("USER_ID") == res["AUTHOR"]["ID"] ? "Y" : "N"), 1301 "MODERATE_URL" : params["MODERATE_URL"].replace("#ID#", res["ID"]).replace("#id#", res["ID"]), 1302 "MODERATE_SHOW" : (params["RIGHTS"]["MODERATE"] == "Y" || params["RIGHTS"]["MODERATE"] == "ALL" || 1303 params["RIGHTS"]["MODERATE"] == "OWN" && BX.message("USER_ID") == res["AUTHOR"]["ID"] ? "Y" : "N"),
1304 "DELETE_URL" : params["DELETE_URL"].replace("#ID#", res["ID"]).replace("#id#", res["ID"]), 1305 "DELETE_SHOW" : (params["RIGHTS"]["DELETE"] == "Y" || params["RIGHTS"]["DELETE"] == "ALL" || 1306 params["RIGHTS"]["DELETE"] == "OWN" && BX.message("USER_ID") == res["AUTHOR"]["ID"] ? "Y" : "N"), 1307 "BEFORE_HEADER" : res['BEFORE_HEADER'], 1308 "BEFORE_ACTIONS" : res['BEFORE_ACTIONS'], 1309 "AFTER_ACTIONS" : res['AFTER_ACTIONS'], 1310 "AFTER_HEADER" : res['AFTER_HEADER'], 1311 "BEFORE" : res['BEFORE'], 1312 "AFTER" : res['AFTER'], 1313 "BEFORE_RECORD" : res['BEFORE_RECORD'], 1314 "AFTER_RECORD" : res['AFTER_RECORD'], 1315 "AUTHOR_ID" : res["AUTHOR"]["ID"], 1316 "AUTHOR_AVATAR_IS" : (!!res["AUTHOR"]["AVATAR"] ? "Y" : "N"), 1317 "AUTHOR_AVATAR" : (!!res["AUTHOR"]["AVATAR"] ? res["AUTHOR"]["AVATAR"] : '/bitrix/images/1.gif'), 1318 "AUTHOR_URL" : params["AUTHOR_URL"]. 1319 replace("#ID#", res["ID"]). 1320 replace("#id#", res["ID"]). 1321 replace("#USER_ID#", res["AUTHOR"]["ID"]). 1322 replace("#user_id#", res["AUTHOR"]["ID"]) + ( 1323 typeof res["AUTHOR"]["EXTERNAL_AUTH_ID"] != 'undefined' 1324 && res["AUTHOR"]["EXTERNAL_AUTH_ID"] == 'email' 1325 && typeof params["AUTHOR_URL_PARAMS"] != 'undefined' 1326 ? (params["AUTHOR_URL"].indexOf("?") >= 0 ? '&' : '?') + 'entityType=' + params["AUTHOR_URL_PARAMS"]["entityType"] + '&entityId=' + params["AUTHOR_URL_PARAMS"]["entityId"] 1327 : '' 1328 ), 1329 "AUTHOR_NAME" : BX.formatName(res["AUTHOR"], params["NAME_TEMPLATE"], params["SHOW_LOGIN"]), 1330 "AUTHOR_EXTRANET_STYLE" : authorStyle, 1331 "VOTE_ID" : (res["RATING"] && res["RATING"]["VOTE_ID"] ? res["RATING"]["VOTE_ID"] : ""), 1332 "AUTHOR_TOOLTIP_PARAMS" : (typeof res["AUTHOR_TOOLTIP_PARAMS"] != 'undefined' ? res["AUTHOR_TOOLTIP_PARAMS"] : '{}'), 1333 "background:url('') no-repeat center;" : "" 1334 }; 1335 } 1336 else 1337 { 1338 for (ii in replacement) 1339 { 1340 if (replacement.hasOwnProperty(ii)) 1341 { 1342 replacement[ii] = (!!data[ii] ? data[ii] : replacement[ii]); 1343 } 1344 } 1345 } 1346 for (ii in replacement) 1347 { 1348 if (replacement.hasOwnProperty(ii)) 1349 { 1350 replacement[ii] = (!!replacement[ii] ? replacement[ii] : ''); 1351 } 1352 } 1353 replacement["SHOW_POST_FORM"] = (BX('record-' + replacement["ENTITY_XML_ID"] + '-0-placeholder') ? "Y" : "N"); 1354 for (var ij in replacement) 1355 { 1356 if (replacement.hasOwnProperty(ij)) 1357 { 1358 txt = txt.replace(new RegExp('#' + ij + '#', "g"), replacement[ij]); 1359 } 1360 } 1361 return txt.replace("background:url('') no-repeat center;", "").replace(/\001/gi, "#"); 1362 }; 1363 1364 window["fcPull"] = function(ENTITY_XML_ID, data) { 1365 BX.ajax({ 1366 url: '/bitrix/components/bitrix/main.post.list/templates/.default/component_epilog.php', 1367 method: 'POST', 1368 data: { 1369 AJAX_POST : "Y", 1370 ENTITY_XML_ID : ENTITY_XML_ID, 1371 MODE : "PUSH&PULL", 1372 sessid : BX.bitrix_sessid(), 1373 DATA : data 1374 } 1375 }); 1376 }; 1377 1378 var newCommentsToCheckForReading = { data : [], screen : {}, timeout : 0 }, 1379 traceForReading = function(id) { 1380 newCommentsToCheckForReading.data.push(id); 1381 newCommentsToCheckForReading.screen = (newCommentsToCheckForReading.screen || { 1382 scrollTop : BX.GetWindowScrollPos().scrollTop, 1383 time : new Date().getTime() 1384 }); 1385 newCommentsToCheckForReading.screen["checked"] = false; 1386 newCommentsToCheckForReading.timeout = (newCommentsToCheckForReading.timeout || setTimeout(markReadComments, 1000)); 1387 }; 1388 BX.addCustomEvent(window, 'OnUCRecordHasDrawn', function(ENTITY_XML_ID, id){traceForReading(id);}); 1389 1390 var markReadComments = function() { 1391 var scroll = BX.GetWindowScrollPos(); 1392 if(scroll.scrollTop != newCommentsToCheckForReading.screen["scrollTop"]) 1393 { 1394 newCommentsToCheckForReading.screen["time"] = new Date().getTime(); 1395 newCommentsToCheckForReading.screen["scrollTop"] = scroll.scrollTop; 1396 newCommentsToCheckForReading.screen["checked"] = false; 1397 } 1398 else if(!newCommentsToCheckForReading.screen["checked"] && 1399 (new Date().getTime() - newCommentsToCheckForReading.screen["time"] > 3000)) 1400 { 1401 newCommentsToCheckForReading.screen["time"] = new Date().getTime(); 1402 newCommentsToCheckForReading.screen["checked"] = true; 1403 1404 var commentsReadToCounter = 0, 1405 size = BX.GetWindowInnerSize(), 1406 res = [], 1407 node, pos, node1, i; 1408 for (i = 0; i < newCommentsToCheckForReading.data.length; i++) 1409 { 1410 node = BX('record-' + newCommentsToCheckForReading.data[i].join('-') + '-cover'); 1411 if (node) 1412 { 1413 pos = BX.pos(node); 1414 if (pos.top >= scroll.scrollTop && pos.top <= (scroll.scrollTop +size.innerHe
1414ight - 20)) 1415 { 1416 BX.onCustomEvent(window, 'OnUCCommentWasRead', [newCommentsToCheckForReading.data[i], node]); 1417 BX.removeClass(node, 'comment-new-answer'); 1418 node1 = BX.findChild(node, {className: 'feed-com-block'}, true, false); 1419 BX.removeClass(node1, 'feed-com-block-pointer-to-new feed-com-block-new'); 1420 BX.addClass(node1, 'feed-com-block-read'); 1421 commentsReadToCounter++; 1422 } 1423 else 1424 { 1425 res.push(newCommentsToCheckForReading.data[i]); 1426 } 1427 } 1428 } 1429 newCommentsToCheckForReading.data = res; 1430 if(commentsReadToCounter > 0) 1431 BX.onCustomEvent(window, 'onCounterDecrement', [commentsReadToCounter]); 1432 } 1433 1434 if (newCommentsToCheckForReading.data.length > 0) 1435 newCommentsToCheckForReading.timeout = setTimeout(markReadComments, 1000); 1436 else 1437 { 1438 newCommentsToCheckForReading.timeout = 0; 1439 } 1440 }; 1441 1442 var MPLQuote = function(params) { 1443 this.params = params; 1444 this.id = params["id"]; 1445 this.closeByEsc = !!params["closeByEsc"]; 1446 this.autoHide = !!params["autoHide"]; 1447 this.autoHideTimeout = (!!params["autoHideTimeout"] ? parseInt(params["autoHideTimeout"]) : 0); 1448 1449 if (this.params.classEvents) 1450 { 1451 for (var eventName in this.params.classEvents) 1452 if (this.params.classEvents.hasOwnProperty(eventName)) 1453 BX.addCustomEvent(this, eventName, this.params.classEvents[eventName]); 1454 } 1455 1456 this.node = document.createElement("A"); 1457 BX.adjust(this.node, { 1458 props : { 1459 id : this.id 1460 }, 1461 style : { 1462 zIndex: BX.PopupWindow.getOption("popupZindex") + this.params.zIndex, 1463 position: "absolute", 1464 display: "none", 1465 top: "0px", 1466 left: "0px" 1467 }, 1468 attrs : { 1469 "className" : "mpl-quote-block", 1470 href : "#" 1471 }, 1472 events : this.params.events 1473 }); 1474 1475 document.body.appendChild(this.node); 1476 }; 1477 MPLQuote.prototype = { 1478 show : function(e){ 1479 var pos = this.getPosition(this.node, e); 1480 BX.adjust(this.node, {style : {top : pos.y + 'px', left : pos.x + 'px', display : 'block'}}); 1481 BX.addClass(this.node, "mpl-quote-block-show"); 1482 if (this.closeByEsc && !this.isCloseByEscBinded) 1483 { 1484 this.isCloseByEscBinded = BX.delegate(this._onKeyUp, this); 1485 BX.bind(document, "keyup", this.isCloseByEscBinded); 1486 } 1487 1488 if (this.params.autoHide && !this.isAutoHideBinded) 1489 { 1490 setTimeout( 1491 BX.proxy(function() { 1492 BX.bind(this.node, "click", this.cancelBubble); 1493 this.isAutoHideBinded = BX.delegate(this.hide, this); 1494 BX.bind(document, "click", this.isAutoHideBinded); 1495 }, this), 0 1496 ); 1497 } 1498 1499 if (this.autoHideTimeout > 0 && this.autoHideTimeoutInt <= 0) 1500 { 1501 if (!this.autoHideTimeoutBinded) 1502 this.autoHideTimeoutBinded = BX.delegate(this.hide, this); 1503 this.autoHideTimeoutInt = setTimeout(this.autoHideTimeoutBinded, this.autoHideTimeout); 1504 } 1505 }, 1506 hide : function(event) { 1507 if (!this.isShown()) 1508 return; 1509 1510 if (event && !(BX.getEventButton(event) & BX.MSLEFT)) 1511 return; 1512 1513 this.node.style.display = "none"; 1514 1515 if (this.isCloseByEscBinded) 1516 { 1517 BX.unbind(document, "keyup", this.isCloseByEscBinded); 1518 this.isCloseByEscBinded = false; 1519 } 1520 1521 if (this.autoHideTimeout > 0) 1522 { 1523 clearTimeout(this.autoHideTimeoutInt); 1524 this.autoHideTimeoutInt = 0; 1525 } 1526 setTimeout(BX.proxy(this._hide, this), 0); 1527 }, 1528 _hide : function() 1529 { 1530 BX.onCustomEvent(this, "onQuoteHide", [this]); 1531 if (this.params.autoHide && this.isAutoHideBinded) 1532 { 1533 BX.unbind(this.node, "click", this.cancelBubble); 1534 BX.unbind(document, "click", this.isAutoHideBinded); 1535 this.isAutoHideBinded = false; 1536 } 1537 BX.remove(this.node); 1538 }, 1539 getPosition : function(node, e) { 1540 var nodePos; 1541 if (e.pageX == null) { 1542 var doc = document.documentElement, body = document.body; 1543 var x = e.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); 1544 var y = e.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); 1545 nodePos = {x: x, y: y}; 1546 } else { 1547 nodePos = {x: e.pageX, y: e.pageY}; 1548 }
1549 return {'x': nodePos.x + 5, 'y':nodePos.y - 16}; 1550 }, 1551 isShown : function() 1552 { 1553 return this.node.style.display == "block"; 1554 }, 1555 cancelBubble : function(event) 1556 { 1557 if(!event) 1558 event = window.event; 1559 1560 if (event.stopPropagation) 1561 event.stopPropagation(); 1562 else 1563 event.cancelBubble = true; 1564 }, 1565 _onKeyUp : function(event) 1566 { 1567 event = event || window.event; 1568 if (event.keyCode == 27) 1569 this.hide(event); 1570 } 1571 }; 1572 1573 window.mplCheckForQuote = function(e, node, ENTITY_XML_ID, author_id) { 1574 e = (document.all ? window.event : e); 1575 var text = '', range, author = null; 1576 1577 if (window.getSelection) { 1578 range = window.getSelection(); 1579 text = range.toString(); 1580 } else if (document.selection) { 1581 range = document.selection; 1582 text = range.createRange().text; 1583 } 1584 if (text != "") 1585 { 1586 var endParent = BX.findParent(range.focusNode, {"tagName" : node.tagName, "className" : node.className}, node), 1587 startParent = BX.findParent(range.anchorNode, {"tagName" : node.tagName, "className" : node.className}, node); 1588 if (endParent != startParent || endParent != node) { 1589 text = ""; 1590 } else { 1591 if (!!author_id && BX(author_id, true)) 1592 { 1593 var tmp = BX(author_id, true); 1594 if (!!tmp && tmp.hasAttribute("bx-post-author-id")) 1595 { 1596 author = { 1597 id : parseInt(tmp.getAttribute("bx-post-author-id")), 1598 name : tmp.innerHTML 1599 } 1600 } 1601 } 1602 } 1603 } 1604 if (text != "") { 1605 BX.onCustomEvent(window, "onQuote" + ENTITY_XML_ID, [e, {text : text, author : author}]); 1606 return true; 1607 } 1608 return false; 1609 }; 1610 1611 window.mplReplaceUserPath = function(text) { 1612 if ( 1613 typeof text != 'string' 1614 || text.length <= 0 1615 ) 1616 { 1617 return ''; 1618 } 1619 1620 if (BX('MPL_IS_EXTRANET_SITE') == 'Y') 1621 { 1622 text = text.replace('/company/personal/user/', '/extranet/contacts/personal/user/'); 1623 } 1624 else 1625 { 1626 text = text.replace('/extranet/contacts/personal/user/', '/company/personal/user/'); 1627 } 1628 1629 text = text.replace( 1630 new RegExp("[\\w\/]*\/mobile\/users\/\\?user_id=(\\d+)", 'igm'), 1631 ( 1632 BX('MPL_IS_EXTRANET_SITE') == 'Y' 1633 ? '/extranet/contacts/personal/user/$1/' 1634 : '/company/personal/user/$1/' 1635 ) 1636 ); 1637 1638 return text; 1639 }; 1640 1641 BX.onCustomEvent("main.post.list/default", ["script.js"]); 1642})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.