1window.LHEDailogs = {}; 2 3window.LHEDailogs['Anchor'] = function(pObj) 4{ 5 return { 6 title: BX.message.AnchorProps, 7 innerHTML : '<table>' + 8 '<tr>' + 9 '<td class="lhe-dialog-label lhe-label-imp">' + BX.message.AnchorName + ':</td>' + 10 '<td class="lhe-dialog-param"><input type="text" size="20" value="" id="lhed_anchor_name"></td>' + 11 '</tr></table>', 12 width: 300, 13 OnLoad: function() 14 { 15 pObj.pName = BX("lhed_anchor_name"); 16 pObj.pLEditor.focus(pObj.pName); 17 18 var pElement = pObj.pLEditor.GetSelectionObject(); 19 var value = ""; 20 if (pElement) 21 { 22 var bxTag = pObj.pLEditor.GetBxTag(pElement); 23 if (bxTag.tag == "anchor" && bxTag.params.value) 24 { 25 value = bxTag.params.value.replace(/([\s\S]*?name\s*=\s*("|'))([\s\S]*?)(\2[\s\S]*?(?:>\s*?<\/a)?(?:\/?))?>/ig, "$3"); 26 } 27 } 28 pObj.pName.value = value; 29 }, 30 OnSave: function() 31 { 32 var anchorName = pObj.pName.value.replace(/[^\w\d]/gi, '_'); 33 if(pObj.pSel) 34 { 35 if(anchorName.length > 0) 36 pObj.pSel.id = anchorName; 37 else 38 pObj.pLEditor.executeCommand('Delete'); 39 } 40 else if(anchorName.length > 0) 41 { 42 var id = pObj.pLEditor.SetBxTag(false, {tag: "anchor", params: {value : '<a name="' + anchorName + '"></a>'}}); 43 pObj.pLEditor.InsertHTML('<img id="' + id + '" src="' + pObj.pLEditor.oneGif + '" class="bxed-anchor" />'); 44 } 45 } 46 }; 47} 48 49window.LHEDailogs['Link'] = function(pObj) 50{ 51 var strHref = pObj.pLEditor.arConfig.bUseFileDialogs ? '<input type="text" size="26" value="" id="lhed_link_href"><input type="button" value="..." style="min-width: 20px; max-width: 40px;" onclick="window.LHED_Link_FDOpen();">' : '<input type="text" size="30" value="" id="lhed_link_href">'; 52 53 var str = '<table width="100%">' + 54 '<tr>' + 55 '<td class="lhe-dialog-label lhe-label-imp">' + BX.message.LinkText + ':</td>' + 56 '<td class="lhe-dialog-param"><input type="text" size="30" value="" id="lhed_link_text"></td>' + 57 '</tr>' + 58 '<tr>' + 59 '<td class="lhe-dialog-label lhe-label-imp">' + BX.message.LinkHref + ':</td>' + 60 '<td class="lhe-dialog-param">' + strHref + '</td>' + 61 '</tr>'; 62 63 if (!pObj.pLEditor.arConfig.bBBCode) 64 { 65 str += 66 '<tr>' + 67 '<td class="lhe-dialog-label">' + BX.message.LinkTitle + ':</td>' + 68 '<td class="lhe-dialog-param"><input type="text" size="30" value="" id="lhed_link_title"></td>' + 69 '</tr>' + 70 '<tr>' + 71 '<td class="lhe-dialog-label">' + BX.message.LinkTarget + '</td>' + 72 '<td class="lhe-dialog-param">' + 73 '<select id="lhed_link_target">' + 74 '<option value="">' + BX.message.LinkTarget_def + '</option>' + 75 '<option value="_blank">' + BX.message.LinkTarget_blank + '</option>' + 76 '<option value="_parent">' + BX.message.LinkTarget_parent + '</option>' + 77 '<option value="_self">' + BX.message.LinkTarget_self + '</option>' + 78 '<option value="_top">' + BX.message.LinkTarget_top + '</option>' + 79 '</select>' + 80 '</td>' + 81 '</tr>'; 82 } 83 str += '</table>'; 84 85 return { 86 title: BX.message.LinkProps, 87 innerHTML : str, 88 width: 420, 89 OnLoad: function() 90 { 91 pObj._selectionStart = pObj._selectionEnd = null; 92 pObj.bNew = true; 93 pObj.pText = BX("lhed_link_text"); 94 pObj.pHref = BX("lhed_link_href"); 95 96 pObj.pLEditor.focus(pObj.pHref); 97 98 if (!pObj.pLEditor.bBBCode) 99 { 100 pObj.pTitle = BX("lhed_link_title"); 101 pObj.pTarget = BX("lhed_link_target"); 102 } 103 104 if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode) 105 { 106 if (pObj.prevTextSelection) 107 pObj.pText.value = pObj.prevTextSelection; 108 109 if (pObj.pLEditor.pTextarea.selectionStart != undefined) 110 { 111 pObj._selectionStart = pObj.pLEditor.pTextarea.selectionStart; 112 pObj._selectionEnd = pObj.pLEditor.pTextarea.selectionEnd; 113 } 114 } 115 else // WYSIWYG 116 { 117 if(!pObj.pSel) 118 { 119 var bogusImg = pObj.pLEditor.pEditorDocument.getElementById('bx_lhe_temp_bogus_node'); 120 if (bogusImg) 121 { 122 pObj.pSel = BX.findParent(bogusImg, {tagName: 'A'}); 123 bogusImg.parentNode.removeChild(bogusImg); 124 } 125 } 126 127 var parA = (pObj.pSel && pObj.pSel.tagName.toUpperCase() != 'A') ? BX.findParent(pObj.pSel, {tagName : 'A'}) : false;
128 if (parA) 129 pObj.pSel = parA; 130 131 pObj.bNew = !pObj.pSel || pObj.pSel.tagName.toUpperCase() != 'A'; 132 133 // Select Link 134 if (!pObj.bNew && !BX.browser.IsIE()) 135 pObj.pLEditor.oPrevRange = pObj.pLEditor.SelectElement(pObj.pSel); 136 137 138 var 139 selectedText = false, 140 oRange = pObj.pLEditor.oPrevRange; 141 142 // Get selected text 143 if (oRange.startContainer && oRange.endContainer) // DOM Model 144 { 145 if (oRange.startContainer == oRange.endContainer && (oRange.endContainer.nodeType == 3 || oRange.endContainer.nodeType == 1)) 146 selectedText = oRange.startContainer.textContent.substring(oRange.startOffset, oRange.endOffset) || ''; 147 } 148 else // IE 149 { 150 if (oRange.text == oRange.htmlText) 151 selectedText = oRange.text || ''; 152 } 153 154 if (pObj.pSel && pObj.pSel.tagName.toUpperCase() == 'IMG') 155 selectedText = false; 156 157 if (selectedText === false) 158 { 159 var textRow = BX.findParent(pObj.pText, {tagName: 'TR'}); 160 textRow.parentNode.removeChild(textRow); 161 pObj.pText = false; 162 } 163 else 164 { 165 pObj.pText.value = selectedText || ''; 166 } 167 168 if (!pObj.bNew) 169 { 170 var bxTag = pObj.pLEditor.GetBxTag(pObj.pSel); 171 if (pObj.pText !== false) 172 pObj.pText.value = pObj.pSel.innerHTML; 173 174 if (pObj.pSel && pObj.pSel.childNodes && pObj.pSel.childNodes.length > 0) 175 { 176 for (var i = 0; i < pObj.pSel.childNodes.length; i++) 177 { 178 if (pObj.pSel.childNodes[i] && pObj.pSel.childNodes[i].nodeType != 3) 179 { 180 var textRow = BX.findParent(pObj.pText, {tagName: 'TR'}); 181 textRow.parentNode.removeChild(textRow); 182 pObj.pText = false; 183 break; 184 } 185 } 186 } 187 188 if (bxTag.tag == 'a') 189 { 190 pObj.pHref.value = bxTag.params.href; 191 if (!pObj.pLEditor.bBBCode) 192 { 193 pObj.pTitle.value = bxTag.params.title || ''; 194 pObj.pTarget.value = bxTag.params.target || ''; 195 } 196 } 197 else 198 { 199 pObj.pHref.value = pObj.pSel.getAttribute('href'); 200 if (!pObj.pLEditor.bBBCode) 201 { 202 pObj.pTitle.value = pObj.pSel.getAttribute('title') || ''; 203 pObj.pTarget.value = pObj.pSel.getAttribute('target') || ''; 204 } 205 } 206 } 207 } 208 }, 209 OnSave: function() 210 { 211 var 212 link, 213 href = pObj.pHref.value; 214 215 if (href.length < 1) // Need for showing error 216 return; 217 218 if (pObj.pText && pObj.pText.value.length <=0) 219 pObj.pText.value = href; 220 221 // BB code mode 222 if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode) 223 { 224 if (pObj._selectionStart != undefined && pObj._selectionEnd != undefined) 225 { 226 pObj.pLEditor.pTextarea.selectionStart = pObj._selectionStart; 227 pObj.pLEditor.pTextarea.selectionEnd = pObj._selectionEnd; 228 } 229 230 var res = ""; 231 if (!pObj.pText || pObj.pText && pObj.pText.value == href) 232 res = '[URL]' + href + '[/URL]'; 233 else 234 res = '[URL=' + href + ']' + pObj.pText.value + '[/URL]'; 235 pObj.pLEditor.WrapWith("", "", res); 236 } 237 else 238 { 239 // WYSIWYG mode 240 var arlinks = []; 241 if (pObj.pSel && pObj.pSel.tagName.toUpperCase() == 'A') 242 { 243 arlinks[0] = pObj.pSel; 244 } 245 else 246 { 247 var sRand = '#'+Math.random().toString().substring(5); 248 var pDoc = pObj.pLEditor.pEditorDocument; 249 250 if (pObj.pText !== false) // Simple case 251 { 252 pObj.pLEditor.InsertHTML('<a id="bx_lhe_' + sRand + '">#</a>'); 253 arlinks[0] = pDoc.getElementById('bx_lhe_' + sRand); 254 arlinks[0].removeAttribute("id"); 255 } 256 else 257 { 258 pDoc.execCommand('CreateLink', false, sRand); 259 var arLinks_ = pDoc.getElementsByTagName('A'); 260 for(var i = 0; i < arLinks_.length; i++) 261 if(arLinks_[i].getAttribute('href', 2) == sRand) 262 arlinks.push(arLinks_[i]); 263 } 264 } 265 266 var oTag, i, l = arlinks.length, link; 267 for (i = 0; i < l; i++) 268 { 269 link = arlinks[i]; 270 oTag = false; 271 272 if (pObj.pSel && i == 0) 273 { 274 oTag = pObj.pLEditor.GetBxTag(link); 275 if (oTag.tag != 'a' || !oTag.params) 276 oTag = false; 277 } 278 279 if (!oTag) 280 oTag = {tag: 'a', params: {}}; 281 282 oTag.params.href = href; 283 if (!pObj.pLEditor.bBBCode) 284 { 285 oTag.params.title = pObj.pTitle.value; 286 oTag.params.target = pObj.pTarget.value; 287 } 288 289 pObj.pLEditor.SetBxTag(link, oTag); 290 SetAttr(link, 'href', href); 291 // Add text 292 if (pObj.pText !== false) 293 link.innerHTML = BX.util.htmlspecialchars(pObj.pText.value); 294 295 if (!pObj.pLEditor.bBBCode) 296 { 297 SetAttr(link, 'title', pObj.pTitle.value); 298 SetAttr(link, 'target', pObj.pTarget.value); 299 } 300 } 301 } 302 } 303 }; 304} 305 306window.LHEDailogs['Image'] = function(pObj) 307{ 308 var sText = '', i, strSrc; 309 310 if (pObj.pLEditor.arConfig.bUseMedialib) 311 strSrc = '<input type="text" size="30" value="" id="lhed_img_src"><input class="lhe-br-but" type="button" value="..." onclick="window.LHED_Img_MLOpen();">'; 312 else if (pObj.pLEditor.arConfig.bUseFileDialogs) 313 strSrc = '<input type="text" size="30" value="" id="lhed_img_src"><input class="lhe-br-but" type="button" value="..." onclick="window.LHED_Img_FDOpen();">'; 314 else 315 strSrc = '<input type="text" size="33" value="" id="lhed_img_src">'; 316 317 for (i = 0; i < 200; i++){sText += 'text ';} 318 319 var str = '<table width="100%">' + 320 '<tr>' + 321 '<td class="lhe-dialog-label lhe-label-imp">' + BX.message.ImageSrc + ':</td>' + 322 '<td class="lhe-dialog-param">' + strSrc + '</td>' + 323 '</tr>'; 324 if (!pObj.pLEditor.arConfig.bBBCode) 325 { 326 str += 327 '<tr>' + 328 '<td class="lhe-dialog-label">' + BX.message.ImageTitle + ':</td>' + 329 '<td class="lhe-dialog-param"><input type="text" size="33" value="" id="lhed_img_title"></td>' + 330 '</tr>' + 331 '<tr>' + 332 '<td class="lhe-dialog-label">' + BX.message.ImgAlign + ':</td>' + 333 '<td class="lhe-dialog-param">' + 334 '<select id="lhed_img_align">' + 335 '<option value="">' + BX.message.LinkTarget_def + '</option>' + 336 '<option value="top">' + BX.message.ImgAlignTop + '</option>' + 337 '<option value="right">' + BX.message.ImgAlignRight + '</option>' + 338 '<option value="bottom">' + BX.message.ImgAlignBottom + '</option>' + 339 '<option value="left">' + BX.message.ImgAlignLeft + '</option>' + 340 '<option value="middle">' + BX.message.ImgAlignMiddle + '</option>' + 341 '</select>' + 342 '</td>' + 343 '</tr>' + 344 '<tr>' + 345 '<td colSpan="2" class="lhe-dialog-param"><span class="lhed-img-preview-label">' + BX.message.ImageSizing + ':</span>' + 346 '<div class="lhed-img-size-cont"><input type="text" size="4" value="" id="lhed_img_width"> x <input type="text" size="4" value="" id="lhed_img_height"> <input type="checkbox" id="lhed_img_save_prop" checked><label for="lhed_img_save_prop">' + BX.message.ImageSaveProp + '</label></div></td>' + 347 '</tr>'; 348 str += 349 '<tr>' + 350 '<td colSpan="2" class="lhe-dialog-param"><span class="lhed-img-preview-label">' + BX.message.ImagePreview + ':</span>' + 351 '<div class="lhed-img-preview-cont"><img id="lhed_img_preview" style="display:none" />' + sText + '</div>' + 352 '</td>' + 353 '</tr>'; 354 } 355 str += '</table>'; 356 357 var PreviewOnLoad = function() 358 { 359 var w = parseInt(this.style.width || this.getAttribute('width') || this.offsetWidth);
360 var h = parseInt(this.style.height || this.getAttribute('hright') || this.offsetHeight); 361 if (!w || !h) 362 return; 363 pObj.iRatio = w / h; // Remember proportion 364 pObj.curWidth = pObj.pWidth.value = w; 365 pObj.curHeight = pObj.pHeight.value = h; 366 }; 367 368 var PreviewReload = function() 369 { 370 var newSrc = pObj.pSrc.value; 371 if (!newSrc) return; 372 if (pObj.prevSrc != newSrc) 373 { 374 pObj.prevSrc = pObj.pPreview.src = newSrc; 375 pObj.pPreview.style.display = ""; 376 pObj.pPreview.removeAttribute("width"); 377 pObj.pPreview.removeAttribute("height"); 378 } 379 380 if (pObj.curWidth && pObj.curHeight) 381 { 382 pObj.pPreview.style.width = pObj.curWidth + 'px'; 383 pObj.pPreview.style.height = pObj.curHeight + 'px'; 384 } 385 386 if (!pObj.pLEditor.bBBCode) 387 { 388 SetAttr(pObj.pPreview, 'align', pObj.pAlign.value); 389 SetAttr(pObj.pPreview, 'title', pObj.pTitle.value); 390 } 391 }; 392 393 if (pObj.pLEditor.arConfig.bUseMedialib || pObj.pLEditor.arConfig.bUseFileDialogs) 394 { 395 window.LHED_Img_SetUrl = function(filename, path, site) 396 { 397 var url, srcInput = BX("lhed_img_src"), pTitle; 398 399 if (typeof filename == 'object') // Using medialibrary 400 { 401 url = filename.src; 402 if (pTitle = BX("lhed_img_title")) 403 pTitle.value = filename.name; 404 } 405 else // Using file dialog 406 { 407 url = (path == '/' ? '' : path) + '/'+filename; 408 } 409 410 srcInput.value = url; 411 if(srcInput.onchange) 412 srcInput.onchange(); 413 414 pObj.pLEditor.focus(srcInput, true); 415 }; 416 } 417 418 return { 419 title: BX.message.ImageProps, 420 innerHTML : str, 421 width: 500, 422 OnLoad: function() 423 { 424 pObj.bNew = !pObj.pSel || pObj.pSel.tagName.toUpperCase() != 'IMG'; 425 pObj.bSaveProp = true; 426 pObj.iRatio = 1; 427 428 pObj.pSrc = BX("lhed_img_src"); 429 pObj.pLEditor.focus(pObj.pSrc); 430 431 if (!pObj.pLEditor.bBBCode) 432 { 433 pObj.pPreview = BX("lhed_img_preview"); 434 pObj.pTitle = BX("lhed_img_title"); 435 pObj.pAlign = BX("lhed_img_align"); 436 pObj.pWidth = BX("lhed_img_width"); 437 pObj.pHeight = BX("lhed_img_height"); 438 pObj.pSaveProp = BX("lhed_img_save_prop"); 439 pObj.bSetInStyles = false; 440 pObj.pSaveProp.onclick = function() 441 { 442 pObj.bSaveProp = this.checked ? true : false; 443 if (pObj.bSaveProp) 444 pObj.pWidth.onchange(); 445 }; 446 pObj.pWidth.onchange = function() 447 { 448 var w = parseInt(this.value); 449 if (isNaN(w)) return; 450 pObj.curWidth = pObj.pWidth.value = w; 451 if (pObj.bSaveProp) 452 { 453 var h = Math.round(w / pObj.iRatio); 454 pObj.curHeight = pObj.pHeight.value = h; 455 } 456 PreviewReload(); 457 }; 458 pObj.pHeight.onchange = function() 459 { 460 var h = parseInt(this.value); 461 if (isNaN(h)) return; 462 pObj.curHeight = pObj.pHeight.value = h; 463 if (pObj.bSaveProp) 464 { 465 var w = parseInt(h * pObj.iRatio); 466 pObj.curWidth = pObj.pWidth.value = w; 467 } 468 PreviewReload(); 469 }; 470 pObj.pAlign.onchange = pObj.pTitle.onchange = PreviewReload; 471 pObj.pSrc.onchange = PreviewReload; 472 pObj.pPreview.onload = PreviewOnLoad; 473 } 474 else if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode && pObj.pLEditor.pTextarea.selectionStart != undefined) 475 { 476 pObj._selectionStart = pObj.pLEditor.pTextarea.selectionStart; 477 pObj._selectionEnd = pObj.pLEditor.pTextarea.selectionEnd; 478 } 479 480 if (!pObj.bNew) // Select Img 481 { 482 var bxTag = pObj.pLEditor.GetBxTag(pObj.pSel); 483 if (bxTag.tag !== 'img') 484 bxTag.params = {}; 485 486 pObj.pSrc.value = bxTag.params.src || ''; 487 if (!pObj.pLEditor.bBBCode) 488 { 489 pObj.pPreview.onload = function(){pObj.pPreview.onload = PreviewOnLoad;}; 490 if (pObj.pSel.style.width || pObj.pSel.style.height) 491 pObj.bSetInStyles = true; 492 pObj.bSetInStyles = false; 493 494 var w = parseInt(pObj.pSel.style.width || pObj.pSel.getAttribute('width') || pObj.pSel.offsetWidth); 495 var h = parseInt(pObj.pSel.style.height || pObj.pSel.getAttribute('height') || pObj.pSel.offsetHeight); 496 if (w && h) 497 { 498 pObj.iRatio = w / h; // Remember proportion 499 pObj.curWidth = pObj.pWidth.value = w; 500 pObj.curHeight = pObj.pHeight.value = h; 501 } 502 pObj.pTitle.value = bxTag.params.title || ''; 503 pObj.pAlign.value = bxTag.params.align || ''; 504 PreviewReload(); 505 } 506 } 507 }, 508 OnSave: function() 509 { 510 var src = pObj.pSrc.value, img, oTag; 511 512 if (src.length < 1) // Need for showing error 513 return; 514 515 // BB code mode 516 if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode) 517 { 518 if (pObj._selectionStart != undefined && pObj._selectionEnd != undefined) 519 { 520 pObj.pLEditor.pTextarea.selectionStart = pObj._selectionStart; 521 pObj.pLEditor.pTextarea.selectionEnd = pObj._selectionEnd; 522 } 523 pObj.pLEditor.WrapWith("", "", '[IMG]' + src + '[/IMG]'); 524 } 525 else 526 {
527 // WYSIWYG mode 528 if (pObj.pSel) 529 { 530 img = pObj.pSel; 531 oTag = pObj.pLEditor.GetBxTag(img); 532 if (oTag.tag != 'img' || !oTag.params) 533 oTag = false; 534 } 535 else 536 { 537 var tmpid = Math.random().toString().substring(4); 538 pObj.pLEditor.InsertHTML('<img id="' + tmpid + '" src="" />'); 539 img = pObj.pLEditor.pEditorDocument.getElementById(tmpid); 540 img.removeAttribute("id"); 541 } 542 SetAttr(img, "src", src); 543 544 if (!oTag) 545 oTag = {tag: 'img', params: {}}; 546 547 oTag.params.src = src; 548 549 if (!pObj.pLEditor.bBBCode) 550 { 551 if (pObj.bSetInStyles) 552 { 553 img.style.width = pObj.pWidth.value + 'px'; 554 img.style.height = pObj.pHeight.value + 'px'; 555 SetAttr(img, "width", ''); 556 SetAttr(img, "height", ''); 557 } 558 else 559 { 560 SetAttr(img, "width", pObj.pWidth.value); 561 SetAttr(img, "height", pObj.pHeight.value); 562 img.style.width = ''; 563 img.style.height = ''; 564 } 565 566 oTag.params.align = pObj.pAlign.value; 567 oTag.params.title = pObj.pTitle.value; 568 569 SetAttr(img, "align", pObj.pAlign.value); 570 SetAttr(img, "title", pObj.pTitle.value); 571 } 572 573 pObj.pLEditor.SetBxTag(img, oTag); 574 } 575 } 576 }; 577} 578 579window.LHEDailogs['Video'] = function(pObj) 580{ 581 var strPath; 582 if (pObj.pLEditor.arConfig.bUseMedialib) 583 strPath = '<input type="text" size="30" value="" id="lhed_video_path"><input class="lhe-br-but" type="button" value="..." onclick="window.LHED_Video_MLOpen();">'; 584 else if (pObj.pLEditor.arConfig.bUseFileDialogs) 585 strPath = '<input type="text" size="30" value="" id="lhed_video_path"><input class="lhe-br-but" type="button" value="..." onclick="window.LHED_VideoPath_FDOpen();">'; 586 else 587 strPath = '<input type="text" size="33" value="" id="lhed_video_path">'; 588 589 var strPreview = pObj.pLEditor.arConfig.bUseFileDialogs ? '<input type="text" size="30" value="" id="lhed_video_prev_path"><input type="button" value="..." style="width: 20px;" onclick="window.LHED_VideoPreview_FDOpen();">' : '<input type="text" size="33" value="" id="lhed_video_prev_path">'; 590 591 var sText = '', i; 592 for (i = 0; i < 200; i++){sText += 'text ';} 593 594 var str = '<table width="100%">' + 595 '<tr>' + 596 '<td class="lhe-dialog-label lhe-label-imp">' + BX.message.VideoPath + ':</td>' + 597 '<td class="lhe-dialog-param">' + strPath + '</td>' + 598 '</tr>'; 599 if (!pObj.pLEditor.arConfig.bBBCode) 600 { 601 str += 602 '<tr>' + 603 '<td class="lhe-dialog-label">' + BX.message.VideoPreviewPath + ':</td>' + 604 '<td class="lhe-dialog-param">' + strPreview + '</td>' + 605 '</tr>'; 606 } 607 str += 608 '<tr>' + 609 '<td class="lhe-dialog-label lhe-label-imp">' + BX.message.ImageSizing + ':</td>' + 610 '<td class="lhe-dialog-param">' + 611 '<div class="lhed-img-size-cont"><input type="text" size="4" value="" id="lhed_video_width"> x <input type="text" size="4" value="" id="lhed_video_height"></div></td>' + 612 '</tr>'; 613 if (!pObj.pLEditor.arConfig.bBBCode) 614 { 615 str += 616 '<tr>' + 617 '<td class="lhe-dialog-label"></td>' + 618 '<td class="lhe-dialog-param"><input type="checkbox" id="lhed_video_autoplay"><label for="lhed_video_autoplay">' + BX.message.VideoAutoplay + '</label></td>' + 619 '</tr>' + 620 '<tr>' + 621 '<td class="lhe-dialog-label">' + BX.message.VideoVolume + ':</td>' + 622 '<td class="lhe-dialog-param">' + 623 '<select id="lhed_video_volume">' + 624 '<option value="10">10</option><option value="20">20</option>' + 625 '<option value="30">30</option><option value="40">40</option>' + 626 '<option value="50">50</option><option value="60">60</option>' + 627 '<option value="70">70</option><option value="80">80</option>' + 628 '<option value="90" selected="selected">90</option><option value="100">100</option>' + 629 '</select> %' + 630 '</td>' + 631 '</tr>'; 632 } 633 634 window.LHED_Video_SetPath = function(filename, path, site) 635 { 636 var url, srcInput = BX("lhed_video_path"); 637 if (typeof filename == 'object') // Using medialibrary 638 url = filename.src; 639 else // Using file dialog 640 url = (path == '/' ? '' : path) + '/' + filename; 641 642 srcInput.value = url; 643 if(srcInput.onchange) 644 srcInput.onchange(); 645 646 pObj.pLEditor.focus(srcInput, true); 647 }; 648 649 return { 650 title: BX.message.VideoProps, 651 innerHTML : str, 652 width: 500, 653 OnLoad: function() 654 { 655 pObj.pSel = pObj.pLEditor.GetSelectionObject(); 656 pObj.bNew = true; 657 var bxTag = {}; 658 659 if (pObj.pSel) 660 bxTag = pObj.pLEditor.GetBxTag(pObj.pSel); 661
662 if (pObj.pSel && pObj.pSel.id) 663 bxTag = pObj.pLEditor.GetBxTag(pObj.pSel.id); 664 665 if (bxTag.tag == 'video' && bxTag.params) 666 pObj.bNew = false; 667 else 668 pObj.pSel = false; 669 670 pObj.pPath = BX("lhed_video_path"); 671 pObj.pLEditor.focus(pObj.pPath); 672 pObj.pWidth = BX("lhed_video_width"); 673 pObj.pHeight = BX("lhed_video_height"); 674 675 if (!pObj.pLEditor.bBBCode) 676 { 677 pObj.pPrevPath = BX("lhed_video_prev_path"); 678 pObj.pVolume = BX("lhed_video_volume"); 679 pObj.pAutoplay = BX("lhed_video_autoplay"); 680 } 681 else if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode && pObj.pLEditor.pTextarea.selectionStart != undefined) 682 { 683 pObj._selectionStart = pObj.pLEditor.pTextarea.selectionStart; 684 pObj._selectionEnd = pObj.pLEditor.pTextarea.selectionEnd; 685 } 686 687 if (!pObj.bNew) 688 { 689 pObj.arParams = bxTag.params || {}; 690 691 var path, prPath, vol, w, h, autoplay; 692 if (pObj.arParams.flashvars) //FLV 693 { 694 path = pObj.arParams.flashvars.file; 695 w = pObj.arParams.width || ''; 696 h = pObj.arParams.height || ''; 697 prPath = pObj.arParams.flashvars.image || ''; 698 vol = pObj.arParams.flashvars.volume || '90'; 699 autoplay = pObj.arParams.flashvars.autostart || false; 700 } 701 else 702 { 703 path = pObj.arParams.JSConfig.file; 704 w = pObj.arParams.JSConfig.width || ''; 705 h = pObj.arParams.JSConfig.height || ''; 706 prPath = pObj.arParams.JSConfig.image || ''; 707 vol = pObj.arParams.JSConfig.volume || '90'; 708 autoplay = pObj.arParams.JSConfig.autostart || false; 709 } 710 pObj.pPath.value = path; 711 pObj.pWidth.value = w; 712 pObj.pHeight.value = h; 713 714 if (!pObj.pLEditor.bBBCode) 715 { 716 if (pObj.pPrevPath) 717 pObj.pPrevPath.value = prPath; 718 pObj.pVolume.value = vol; 719 pObj.pAutoplay.checked = autoplay ? true : false; 720 } 721 } 722 }, 723 OnSave: function() 724 { 725 var 726 path = pObj.pPath.value, 727 w = parseInt(pObj.pWidth.value) || 240, 728 h = parseInt(pObj.pHeight.value) || 180, 729 pVid, ext, 730 arVidConf = pObj.pLEditor.arConfig.videoSettings; 731 732 if (path.length < 1) // Need for showing error 733 return; 734 735 if (pObj.pSel) 736 { 737 pVid = pObj.pSel; 738 } 739 else 740 { 741 pObj.videoId = "bx_video_" + Math.round(Math.random() * 100000); 742 743 pObj.pLEditor.InsertHTML('<img id="' + pObj.videoId + '" src="' + pObj.pLEditor.oneGif + '" class="bxed-video" />'); 744 745 pVid = pObj.pLEditor.pEditorDocument.getElementById(pObj.videoId); 746 } 747 748 if (arVidConf.maxWidth && w && parseInt(w) > parseInt(arVidConf.maxWidth)) 749 w = arVidConf.maxWidth; 750 if (arVidConf.maxHeight && h && parseInt(h) > parseInt(arVidConf.maxHeight)) 751 h = arVidConf.maxHeight; 752 753 var oVideo = {width: w, height: h}; 754 if (path.indexOf('http://') != -1 || path.indexOf('.') != -1) 755 { 756 ext = (path.indexOf('.') != -1) ? path.substr(path.lastIndexOf('.') + 1).toLowerCase() : false; 757 if (ext && (ext == 'wmv' || ext == 'wma')) // WMV 758 { 759 oVideo.JSConfig = {file: path}; 760 if (!pObj.pLEditor.bBBCode) 761 { 762 if (pObj.pPrevPath) 763 oVideo.JSConfig.image = pObj.pPrevPath.value || ''; 764 oVideo.JSConfig.volume = pObj.pVolume.value; 765 oVideo.JSConfig.autostart = pObj.pAutoplay.checked ? true : false; 766 oVideo.JSConfig.width = w; 767 oVideo.JSConfig.height = h; 768 } 769 } 770 else 771 { 772 oVideo.flashvars= {file: path}; 773 if (!pObj.pLEditor.bBBCode) 774 { 775 if (pObj.pPrevPath) 776 oVideo.flashvars.image = pObj.pPrevPath.value || ''; 777 oVideo.flashvars.volume = pObj.pVolume.value; 778 oVideo.flashvars.autostart = pObj.pAutoplay.checked ? true : false; 779 } 780 } 781 782 pVid.title= BX.message.Video + ': ' + path; 783 pVid.style.width = w + 'px'; 784 pVid.style.height = h + 'px'; 785 if (pObj.pPrevPath && pObj.pPrevPath.value.length > 0) 786 pVid.style.backgroundImage = 'url(' + pObj.pPrevPath.value + ')'; 787 788 oVideo.id = pObj.videoId; 789 pVid.id = pObj.pLEditor.SetBxTag(false, {tag: 'video', params: oVideo}); 790 } 791 else 792 { 793 pObj.pLEditor.InsertHTML(''); 794 } 795 } 796 }; 797} 798 799// Table 800window.LHEDailogs['Table'] = function(pObj) 801{ 802 return { 803 title: BX.message.InsertTable, 804 innerHTML : '<table>' + 805 '<tr>' + 806 '<td class="lhe-dialog-label lhe-label-imp"><label for="' + pObj.pLEditor.id + 'lhed_table_cols">' + BX.message.TableCols + ':</label></td>' + 807 '<td class="lhe-dialog-param"><input type="text" size="4" value="3" id="' + pObj.pLEditor.id + 'lhed_table_cols"></td>' + 808 '<td class="lhe-dialog-label lhe-label-imp"><label for="' + pObj.pLEditor.id + 'lhed_table_rows">' + BX.message.TableRows + ':</label></td>' + 809 '<td class="lhe-dialog-param"><input type="text" size="4" value="3" id="' + pObj.pLEditor.id + 'lhed_table_rows"></td>' + 810 '</tr>' + 811 '<tr>' + 812 '<td colSpan="4">' + 813 '<span>
813' + BX.message.TableModel + ': </span>' + 814 '<div class="lhed-model-cont" id="' + pObj.pLEditor.id + 'lhed_table_model" ><div>' + 815 '</td>' + 816 '</tr></table>', 817 width: 350, 818 OnLoad: function(oDialog) 819 { 820 pObj.pCols = BX(pObj.pLEditor.id + "lhed_table_cols"); 821 pObj.pRows = BX(pObj.pLEditor.id + "lhed_table_rows"); 822 pObj.pModelDiv = BX(pObj.pLEditor.id + "lhed_table_model"); 823 824 pObj.pLEditor.focus(pObj.pCols, true); 825 826 if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode && pObj.pLEditor.pTextarea.selectionStart != undefined) 827 { 828 pObj._selectionStart = pObj.pLEditor.pTextarea.selectionStart; 829 pObj._selectionEnd = pObj.pLEditor.pTextarea.selectionEnd; 830 } 831 832 var BuildModel = function() 833 { 834 BX.cleanNode(pObj.pModelDiv); 835 var 836 rows = parseInt(pObj.pRows.value), 837 cells = parseInt(pObj.pCols.value); 838 839 if (rows > 0 && cells > 0) 840 { 841 var tbl = pObj.pModelDiv.appendChild(BX.create("TABLE", {props: {className: "lhe-table-model"}})); 842 var i, j, row, cell; 843 for(i = 0; i < rows; i++) 844 { 845 row = tbl.insertRow(-1); 846 for(j = 0; j < cells; j++) 847 row.insertCell(-1).innerHTML = " "; 848 } 849 } 850 }; 851 852 pObj.pCols.onkeyup = pObj.pRows.onkeyup = BuildModel; 853 BuildModel(); 854 }, 855 OnSave: function() 856 { 857 var 858 rows = parseInt(pObj.pRows.value), 859 cells = parseInt(pObj.pCols.value), 860 t1 = "<", t2 = ">", res = "", cellHTML = "<br _moz_editor_bogus_node=\"on\" />"; 861 862 if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode) 863 { 864 t1 = "["; 865 t2 = "]"; 866 cellHTML = " "; 867 } 868 869 if (rows > 0 && cells > 0) 870 { 871 res = "\n" + t1 + "TABLE" + t2 + "\n"; 872 873 var i, j; 874 for(i = 0; i < rows; i++) 875 { 876 res += "\t" + t1 + "TR" + t2 + "\n"; 877 for(j = 0; j < cells; j++) 878 res += "\t\t" + t1 + "TD" + t2 + cellHTML + t1 + "/TD" + t2 + "\n"; 879 res += "\t" + t1 + "/TR" + t2 + "\n"; 880 } 881 882 res += t1 + "/TABLE" + t2 + "\n"; 883 } 884 885 if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode) 886 { 887 if (pObj._selectionStart != undefined && pObj._selectionEnd != undefined) 888 { 889 pObj.pLEditor.pTextarea.selectionStart = pObj._selectionStart; 890 pObj.pLEditor.pTextarea.selectionEnd = pObj._selectionEnd; 891 } 892 pObj.pLEditor.WrapWith("", "", res); 893 } 894 else if (pObj.pLEditor.sEditorMode == 'code' && !pObj.pLEditor.bBBCode) 895 { 896 // ? 897 } 898 else // WYSIWYG 899 { 900 pObj.pLEditor.InsertHTML(res + "</br>"); 901 } 902 } 903 }; 904} 905 906// Ordered and unordered lists for BBCodes 907window.LHEDailogs['List'] = function(pObj) 908{ 909 return { 910 title: pObj.arParams.bOrdered ? BX.message.OrderedList : BX.message.UnorderedList, 911 innerHTML : '<table class="lhe-dialog-list-table"><tr>' + 912 '<td>' + BX.message.ListItems + ':</td>' + 913 '</tr><tr>' + 914 '<td class="lhe-dialog-list-items"><div id="' + pObj.pLEditor.id + 'lhed_list_items"></div></td>' + 915 '</tr><tr>' + 916 '<td align="right"><a href="javascript:void(0);" title="' + BX.message.AddLITitle + '" id="' + pObj.pLEditor.id + 'lhed_list_more">' + BX.message.AddLI + '</a>' + 917 '</tr><table>', 918 width: 350, 919 OnLoad: function(oDialog) 920 { 921 if (pObj.pLEditor.sEditorMode == 'code' && pObj.pLEditor.bBBCode && pObj.pLEditor.pTextarea.selectionStart != undefined) 922 { 923 pObj._selectionStart = pObj.pLEditor.pTextarea.selectionStart; 924 pObj._selectionEnd = pObj.pLEditor.pTextarea.selectionEnd; 925 } 926 927 pObj.pItemsCont = BX(pObj.pLEditor.id + "lhed_list_items"); 928 pObj.pMore = BX(pObj.pLEditor.id + "lhed_list_more"); 929 930 BX.cleanNode(pObj.pItemsCont); 931 pObj.pList = pObj.pItemsCont.appendChild(BX.create(pObj.arParams.bOrdered ? "OL" : "UL")); 932 933 var firstItemText = ""; 934 if (pObj.prevTextSelection) 935 firstItemText = pObj.prevTextSelection; 936 937 var addItem = function(val, pPrev, bFocus, bCheck) 938 { 939 var pLi = BX.create("LI"); 940 var pInput = pLi.appendChild(BX.create("INPUT", {props: {type: 'text', value: val || "", size: 35}})); 941 942 if (pPrev && pPrev.nextSibling) 943 pObj.pList.insertBefore(pLi, pPrev.nextSibling); 944 else 945 pObj.pList.appendChild(pLi); 946 947 pInput.onkeyup = function(e) 948 { 949 if (!e) 950 e = window.event; 951 952 if (e.keyCode == 13) // Enter 953 { 954 addItem("", this.parentNode, true, true); 955 return BX.PreventDefault(e); 956 } 957 } 958 959 pLi.appendChild(BX.create("IMG", {props: {src: pObj.pLEditor.oneGif, className: "lhe-dialog-list-del", title: BX.message.DelListItem}})).onclick = function() 960 { 961 // del list item 962 var pLi = BX.findParent(this, {tagName: 'LI'}); 963 if (pLi) 964 pLi.parentNode.removeChild(pLi); 965 }; 966 967 if(bFocus !== false) 968 pObj.pLEditor.focus(pInput); 969 970 if (bCheck === true) 971 { 972 var arInp = pObj.pList.getElementsByTagName("INPUT"), i, l = arInp.length; 973 for (i = 0; i < l; i++) 974 arInp[i].onfocus = (i == l - 1) ? function(){addItem("", false, false, true);} : null; 975 } 976 }; 977 978 addItem(firstItemText, false, firstItemText == ""); 979 addItem("", false, firstItemText != ""); 980 addItem("", false, false, true); 981 982 pObj.pMore.onclick = function(){addItem("", false, true, true);}; 983 }, 984 OnSave: function() 985 { 986 var 987 res = "", 988 arInputs = pObj.pList.getElementsByTagName("INPUT"), 989 i, l = arInputs.length; 990 991 if (l == 0) 992 return; 993 994 res = "\n[LIST"; 995 if (pObj.arParams.bOrdered) 996 res += "=1"; 997 res += "]\n"; 998 999 var i, j; 1000 for (i = 0; i < l; i++) 1001 { 1002 if (arInputs[i].value != "" || i == 0) 1003 res += "[*]" + arInputs[i].value + "\n"; 1004 } 1005 res += "[/LIST]" + "\n"; 1006 1007 if (pObj._selectionStart != undefined && pObj._selectionEnd != undefined) 1008 { 1009 pObj.pLEditor.pTextarea.selectionStart = pObj._selectionStart; 1010 pObj.pLEditor.pTextarea.selectionEnd = pObj._selectionEnd; 1011 } 1012 pObj.pLEditor.WrapWith("", "", res); 1013 } 1014 }; 1015} 1016 1017
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.