1
+ − 1
/* Functions for the advlink plugin popup */
+ − 2
+ − 3
var templates = {
+ − 4
"window.open" : "window.open('${url}','${target}','${options}')"
+ − 5
};
+ − 6
+ − 7
function preinit() {
+ − 8
// Initialize
+ − 9
tinyMCE.setWindowArg('mce_windowresize', false);
+ − 10
+ − 11
// Import external list url javascript
+ − 12
var url = tinyMCE.getParam("external_link_list_url");
+ − 13
if (url != null) {
+ − 14
// Fix relative
+ − 15
if (url.charAt(0) != '/' && url.indexOf('://') == -1)
+ − 16
url = tinyMCE.documentBasePath + "/" + url;
+ − 17
+ − 18
document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></sc'+'ript>');
+ − 19
}
+ − 20
}
+ − 21
+ − 22
function changeClass() {
+ − 23
var formObj = document.forms[0];
+ − 24
formObj.classes.value = getSelectValue(formObj, 'classlist');
+ − 25
}
+ − 26
+ − 27
function init() {
+ − 28
tinyMCEPopup.resizeToInnerSize();
+ − 29
+ − 30
var formObj = document.forms[0];
+ − 31
var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
+ − 32
var elm = inst.getFocusElement();
+ − 33
var action = "insert";
+ − 34
var html;
+ − 35
+ − 36
document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','advlink');
+ − 37
document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','advlink');
+ − 38
document.getElementById('linklisthrefcontainer').innerHTML = getLinkListHTML('linklisthref','href');
+ − 39
document.getElementById('anchorlistcontainer').innerHTML = getAnchorListHTML('anchorlist','href');
+ − 40
document.getElementById('targetlistcontainer').innerHTML = getTargetListHTML('targetlist','target');
+ − 41
+ − 42
// Link list
+ − 43
html = getLinkListHTML('linklisthref','href');
+ − 44
if (html == "")
+ − 45
document.getElementById("linklisthrefrow").style.display = 'none';
+ − 46
else
+ − 47
document.getElementById("linklisthrefcontainer").innerHTML = html;
+ − 48
+ − 49
// Resize some elements
+ − 50
if (isVisible('hrefbrowser'))
+ − 51
document.getElementById('href').style.width = '260px';
+ − 52
+ − 53
if (isVisible('popupurlbrowser'))
+ − 54
document.getElementById('popupurl').style.width = '180px';
+ − 55
+ − 56
elm = tinyMCE.getParentElement(elm, "a");
+ − 57
if (elm != null && elm.nodeName == "A")
+ − 58
action = "update";
+ − 59
+ − 60
formObj.insert.value = tinyMCE.getLang('lang_' + action, 'Insert', true);
+ − 61
+ − 62
setPopupControlsDisabled(true);
+ − 63
+ − 64
if (action == "update") {
+ − 65
var href = tinyMCE.getAttrib(elm, 'href');
+ − 66
+ − 67
href = convertURL(href, elm, true);
+ − 68
+ − 69
// Use mce_href if found
+ − 70
var mceRealHref = tinyMCE.getAttrib(elm, 'mce_href');
+ − 71
if (mceRealHref != "") {
+ − 72
href = mceRealHref;
+ − 73
+ − 74
if (tinyMCE.getParam('convert_urls'))
+ − 75
href = convertURL(href, elm, true);
+ − 76
}
+ − 77
+ − 78
var onclick = tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onclick'));
+ − 79
+ − 80
// Setup form data
+ − 81
setFormValue('href', href);
+ − 82
setFormValue('title', tinyMCE.getAttrib(elm, 'title'));
+ − 83
setFormValue('id', tinyMCE.getAttrib(elm, 'id'));
+ − 84
setFormValue('style', tinyMCE.serializeStyle(tinyMCE.parseStyle(tinyMCE.getAttrib(elm, "style"))));
+ − 85
setFormValue('rel', tinyMCE.getAttrib(elm, 'rel'));
+ − 86
setFormValue('rev', tinyMCE.getAttrib(elm, 'rev'));
+ − 87
setFormValue('charset', tinyMCE.getAttrib(elm, 'charset'));
+ − 88
setFormValue('hreflang', tinyMCE.getAttrib(elm, 'hreflang'));
+ − 89
setFormValue('dir', tinyMCE.getAttrib(elm, 'dir'));
+ − 90
setFormValue('lang', tinyMCE.getAttrib(elm, 'lang'));
+ − 91
setFormValue('tabindex', tinyMCE.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
+ − 92
setFormValue('accesskey', tinyMCE.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
+ − 93
setFormValue('type', tinyMCE.getAttrib(elm, 'type'));
+ − 94
setFormValue('onfocus', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onfocus')));
+ − 95
setFormValue('onblur', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onblur')));
+ − 96
setFormValue('onclick', onclick);
+ − 97
setFormValue('ondblclick', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'ondblclick')));
+ − 98
setFormValue('onmousedown', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onmousedown')));
+ − 99
setFormValue('onmouseup', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onmouseup')));
+ − 100
setFormValue('onmouseover', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onmouseover')));
+ − 101
setFormValue('onmousemove', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onmousemove')));
+ − 102
setFormValue('onmouseout', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onmouseout')));
+ − 103
setFormValue('onkeypress', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onkeypress')));
+ − 104
setFormValue('onkeydown', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onkeydown')));
+ − 105
setFormValue('onkeyup', tinyMCE.cleanupEventStr(tinyMCE.getAttrib(elm, 'onkeyup')));
+ − 106
setFormValue('target', tinyMCE.getAttrib(elm, 'target'));
+ − 107
setFormValue('classes', tinyMCE.getAttrib(elm, 'class'));
+ − 108
+ − 109
// Parse onclick data
+ − 110
if (onclick != null && onclick.indexOf('window.open') != -1)
+ − 111
parseWindowOpen(onclick);
+ − 112
else
+ − 113
parseFunction(onclick);
+ − 114
+ − 115
// Select by the values
+ − 116
selectByValue(formObj, 'dir', tinyMCE.getAttrib(elm, 'dir'));
+ − 117
selectByValue(formObj, 'rel', tinyMCE.getAttrib(elm, 'rel'));
+ − 118
selectByValue(formObj, 'rev', tinyMCE.getAttrib(elm, 'rev'));
+ − 119
selectByValue(formObj, 'linklisthref', href);
+ − 120
+ − 121
if (href.charAt(0) == '#')
+ − 122
selectByValue(formObj, 'anchorlist', href);
+ − 123
+ − 124
addClassesToList('classlist', 'advlink_styles');
+ − 125
+ − 126
selectByValue(formObj, 'classlist', tinyMCE.getAttrib(elm, 'class'), true);
+ − 127
selectByValue(formObj, 'targetlist', tinyMCE.getAttrib(elm, 'target'), true);
+ − 128
} else
+ − 129
addClassesToList('classlist', 'advlink_styles');
+ − 130
+ − 131
window.focus();
+ − 132
}
+ − 133
+ − 134
function setFormValue(name, value) {
+ − 135
document.forms[0].elements[name].value = value;
+ − 136
}
+ − 137
+ − 138
function convertURL(url, node, on_save) {
+ − 139
return eval("tinyMCEPopup.windowOpener." + tinyMCE.settings['urlconverter_callback'] + "(url, node, on_save);");
+ − 140
}
+ − 141
+ − 142
function parseWindowOpen(onclick) {
+ − 143
var formObj = document.forms[0];
+ − 144
+ − 145
// Preprocess center code
+ − 146
if (onclick.indexOf('return false;') != -1) {
+ − 147
formObj.popupreturn.checked = true;
+ − 148
onclick = onclick.replace('return false;', '');
+ − 149
} else
+ − 150
formObj.popupreturn.checked = false;
+ − 151
+ − 152
var onClickData = parseLink(onclick);
+ − 153
+ − 154
if (onClickData != null) {
+ − 155
formObj.ispopup.checked = true;
+ − 156
setPopupControlsDisabled(false);
+ − 157
+ − 158
var onClickWindowOptions = parseOptions(onClickData['options']);
+ − 159
var url = onClickData['url'];
+ − 160
+ − 161
if (tinyMCE.getParam('convert_urls'))
+ − 162
url = convertURL(url, null, true);
+ − 163
+ − 164
formObj.popupname.value = onClickData['target'];
+ − 165
formObj.popupurl.value = url;
+ − 166
formObj.popupwidth.value = getOption(onClickWindowOptions, 'width');
+ − 167
formObj.popupheight.value = getOption(onClickWindowOptions, 'height');
+ − 168
+ − 169
formObj.popupleft.value = getOption(onClickWindowOptions, 'left');
+ − 170
formObj.popuptop.value = getOption(onClickWindowOptions, 'top');
+ − 171
+ − 172
if (formObj.popupleft.value.indexOf('screen') != -1)
+ − 173
formObj.popupleft.value = "c";
+ − 174
+ − 175
if (formObj.popuptop.value.indexOf('screen') != -1)
+ − 176
formObj.popuptop.value = "c";
+ − 177
+ − 178
formObj.popuplocation.checked = getOption(onClickWindowOptions, 'location') == "yes";
+ − 179
formObj.popupscrollbars.checked = getOption(onClickWindowOptions, 'scrollbars') == "yes";
+ − 180
formObj.popupmenubar.checked = getOption(onClickWindowOptions, 'menubar') == "yes";
+ − 181
formObj.popupresizable.checked = getOption(onClickWindowOptions, 'resizable') == "yes";
+ − 182
formObj.popuptoolbar.checked = getOption(onClickWindowOptions, 'toolbar') == "yes";
+ − 183
formObj.popupstatus.checked = getOption(onClickWindowOptions, 'status') == "yes";
+ − 184
formObj.popupdependent.checked = getOption(onClickWindowOptions, 'dependent') == "yes";
+ − 185
+ − 186
buildOnClick();
+ − 187
}
+ − 188
}
+ − 189
+ − 190
function parseFunction(onclick) {
+ − 191
var formObj = document.forms[0];
+ − 192
var onClickData = parseLink(onclick);
+ − 193
+ − 194
// TODO: Add stuff here
+ − 195
}
+ − 196
+ − 197
function getOption(opts, name) {
+ − 198
return typeof(opts[name]) == "undefined" ? "" : opts[name];
+ − 199
}
+ − 200
+ − 201
function setPopupControlsDisabled(state) {
+ − 202
var formObj = document.forms[0];
+ − 203
+ − 204
formObj.popupname.disabled = state;
+ − 205
formObj.popupurl.disabled = state;
+ − 206
formObj.popupwidth.disabled = state;
+ − 207
formObj.popupheight.disabled = state;
+ − 208
formObj.popupleft.disabled = state;
+ − 209
formObj.popuptop.disabled = state;
+ − 210
formObj.popuplocation.disabled = state;
+ − 211
formObj.popupscrollbars.disabled = state;
+ − 212
formObj.popupmenubar.disabled = state;
+ − 213
formObj.popupresizable.disabled = state;
+ − 214
formObj.popuptoolbar.disabled = state;
+ − 215
formObj.popupstatus.disabled = state;
+ − 216
formObj.popupreturn.disabled = state;
+ − 217
formObj.popupdependent.disabled = state;
+ − 218
+ − 219
setBrowserDisabled('popupurlbrowser', state);
+ − 220
}
+ − 221
+ − 222
function parseLink(link) {
+ − 223
link = link.replace(new RegExp(''', 'g'), "'");
+ − 224
+ − 225
var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
+ − 226
+ − 227
// Is function name a template function
+ − 228
var template = templates[fnName];
+ − 229
if (template) {
+ − 230
// Build regexp
+ − 231
var variableNames = template.match(new RegExp("'?\\$\\{[A-Za-z0-9\.]*\\}'?", "gi"));
+ − 232
var regExp = "\\s*[A-Za-z0-9\.]*\\s*\\(";
+ − 233
var replaceStr = "";
+ − 234
for (var i=0; i<variableNames.length; i++) {
+ − 235
// Is string value
+ − 236
if (variableNames[i].indexOf("'${") != -1)
+ − 237
regExp += "'(.*)'";
+ − 238
else // Number value
+ − 239
regExp += "([0-9]*)";
+ − 240
+ − 241
replaceStr += "$" + (i+1);
+ − 242
+ − 243
// Cleanup variable name
+ − 244
variableNames[i] = variableNames[i].replace(new RegExp("[^A-Za-z0-9]", "gi"), "");
+ − 245
+ − 246
if (i != variableNames.length-1) {
+ − 247
regExp += "\\s*,\\s*";
+ − 248
replaceStr += "<delim>";
+ − 249
} else
+ − 250
regExp += ".*";
+ − 251
}
+ − 252
+ − 253
regExp += "\\);?";
+ − 254
+ − 255
// Build variable array
+ − 256
var variables = new Array();
+ − 257
variables["_function"] = fnName;
+ − 258
var variableValues = link.replace(new RegExp(regExp, "gi"), replaceStr).split('<delim>');
+ − 259
for (var i=0; i<variableNames.length; i++)
+ − 260
variables[variableNames[i]] = variableValues[i];
+ − 261
+ − 262
return variables;
+ − 263
}
+ − 264
+ − 265
return null;
+ − 266
}
+ − 267
+ − 268
function parseOptions(opts) {
+ − 269
if (opts == null || opts == "")
+ − 270
return new Array();
+ − 271
+ − 272
// Cleanup the options
+ − 273
opts = opts.toLowerCase();
+ − 274
opts = opts.replace(/;/g, ",");
+ − 275
opts = opts.replace(/[^0-9a-z=,]/g, "");
+ − 276
+ − 277
var optionChunks = opts.split(',');
+ − 278
var options = new Array();
+ − 279
+ − 280
for (var i=0; i<optionChunks.length; i++) {
+ − 281
var parts = optionChunks[i].split('=');
+ − 282
+ − 283
if (parts.length == 2)
+ − 284
options[parts[0]] = parts[1];
+ − 285
}
+ − 286
+ − 287
return options;
+ − 288
}
+ − 289
+ − 290
function buildOnClick() {
+ − 291
var formObj = document.forms[0];
+ − 292
+ − 293
if (!formObj.ispopup.checked) {
+ − 294
formObj.onclick.value = "";
+ − 295
return;
+ − 296
}
+ − 297
+ − 298
var onclick = "window.open('";
+ − 299
var url = formObj.popupurl.value;
+ − 300
+ − 301
if (tinyMCE.getParam('convert_urls'))
+ − 302
url = convertURL(url, null, true);
+ − 303
+ − 304
onclick += url + "','";
+ − 305
onclick += formObj.popupname.value + "','";
+ − 306
+ − 307
if (formObj.popuplocation.checked)
+ − 308
onclick += "location=yes,";
+ − 309
+ − 310
if (formObj.popupscrollbars.checked)
+ − 311
onclick += "scrollbars=yes,";
+ − 312
+ − 313
if (formObj.popupmenubar.checked)
+ − 314
onclick += "menubar=yes,";
+ − 315
+ − 316
if (formObj.popupresizable.checked)
+ − 317
onclick += "resizable=yes,";
+ − 318
+ − 319
if (formObj.popuptoolbar.checked)
+ − 320
onclick += "toolbar=yes,";
+ − 321
+ − 322
if (formObj.popupstatus.checked)
+ − 323
onclick += "status=yes,";
+ − 324
+ − 325
if (formObj.popupdependent.checked)
+ − 326
onclick += "dependent=yes,";
+ − 327
+ − 328
if (formObj.popupwidth.value != "")
+ − 329
onclick += "width=" + formObj.popupwidth.value + ",";
+ − 330
+ − 331
if (formObj.popupheight.value != "")
+ − 332
onclick += "height=" + formObj.popupheight.value + ",";
+ − 333
+ − 334
if (formObj.popupleft.value != "") {
+ − 335
if (formObj.popupleft.value != "c")
+ − 336
onclick += "left=" + formObj.popupleft.value + ",";
+ − 337
else
+ − 338
onclick += "left='+(screen.availWidth/2-" + (formObj.popupwidth.value/2) + ")+',";
+ − 339
}
+ − 340
+ − 341
if (formObj.popuptop.value != "") {
+ − 342
if (formObj.popuptop.value != "c")
+ − 343
onclick += "top=" + formObj.popuptop.value + ",";
+ − 344
else
+ − 345
onclick += "top='+(screen.availHeight/2-" + (formObj.popupheight.value/2) + ")+',";
+ − 346
}
+ − 347
+ − 348
if (onclick.charAt(onclick.length-1) == ',')
+ − 349
onclick = onclick.substring(0, onclick.length-1);
+ − 350
+ − 351
onclick += "');";
+ − 352
+ − 353
if (formObj.popupreturn.checked)
+ − 354
onclick += "return false;";
+ − 355
+ − 356
// tinyMCE.debug(onclick);
+ − 357
+ − 358
formObj.onclick.value = onclick;
+ − 359
+ − 360
if (formObj.href.value == "")
+ − 361
formObj.href.value = url;
+ − 362
}
+ − 363
+ − 364
function setAttrib(elm, attrib, value) {
+ − 365
var formObj = document.forms[0];
+ − 366
var valueElm = formObj.elements[attrib.toLowerCase()];
+ − 367
+ − 368
if (typeof(value) == "undefined" || value == null) {
+ − 369
value = "";
+ − 370
+ − 371
if (valueElm)
+ − 372
value = valueElm.value;
+ − 373
}
+ − 374
+ − 375
if (value != "") {
+ − 376
elm.setAttribute(attrib.toLowerCase(), value);
+ − 377
+ − 378
if (attrib == "style")
+ − 379
attrib = "style.cssText";
+ − 380
+ − 381
if (attrib.substring(0, 2) == 'on')
+ − 382
value = 'return true;' + value;
+ − 383
+ − 384
if (attrib == "class")
+ − 385
attrib = "className";
+ − 386
+ − 387
eval('elm.' + attrib + "=value;");
+ − 388
} else
+ − 389
elm.removeAttribute(attrib);
+ − 390
}
+ − 391
+ − 392
function getAnchorListHTML(id, target) {
+ − 393
var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
+ − 394
var nodes = inst.getBody().getElementsByTagName("a");
+ − 395
+ − 396
var html = "";
+ − 397
+ − 398
html += '<select id="' + id + '" name="' + id + '" class="mceAnchorList" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.' + target + '.value=';
+ − 399
html += 'this.options[this.selectedIndex].value;">';
+ − 400
html += '<option value="">---</option>';
+ − 401
+ − 402
for (var i=0; i<nodes.length; i++) {
+ − 403
if ((name = tinyMCE.getAttrib(nodes[i], "name")) != "")
+ − 404
html += '<option value="#' + name + '">' + name + '</option>';
+ − 405
}
+ − 406
+ − 407
html += '</select>';
+ − 408
+ − 409
return html;
+ − 410
}
+ − 411
+ − 412
function insertAction() {
+ − 413
var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
+ − 414
var elm = inst.getFocusElement();
+ − 415
+ − 416
elm = tinyMCE.getParentElement(elm, "a");
+ − 417
+ − 418
tinyMCEPopup.execCommand("mceBeginUndoLevel");
+ − 419
+ − 420
// Create new anchor elements
+ − 421
if (elm == null) {
+ − 422
if (tinyMCE.isSafari)
+ − 423
tinyMCEPopup.execCommand("mceInsertContent", false, '<a href="#mce_temp_url#">' + inst.selection.getSelectedHTML() + '</a>');
+ − 424
else
+ − 425
tinyMCEPopup.execCommand("createlink", false, "#mce_temp_url#");
+ − 426
+ − 427
var elementArray = tinyMCE.getElementsByAttributeValue(inst.getBody(), "a", "href", "#mce_temp_url#");
+ − 428
for (var i=0; i<elementArray.length; i++) {
+ − 429
var elm = elementArray[i];
+ − 430
+ − 431
// Move cursor behind the new anchor
+ − 432
if (tinyMCE.isGecko) {
+ − 433
var sp = inst.getDoc().createTextNode(" ");
+ − 434
+ − 435
if (elm.nextSibling)
+ − 436
elm.parentNode.insertBefore(sp, elm.nextSibling);
+ − 437
else
+ − 438
elm.parentNode.appendChild(sp);
+ − 439
+ − 440
// Set range after link
+ − 441
var rng = inst.getDoc().createRange();
+ − 442
rng.setStartAfter(elm);
+ − 443
rng.setEndAfter(elm);
+ − 444
+ − 445
// Update selection
+ − 446
var sel = inst.getSel();
+ − 447
sel.removeAllRanges();
+ − 448
sel.addRange(rng);
+ − 449
}
+ − 450
+ − 451
setAllAttribs(elm);
+ − 452
}
+ − 453
} else
+ − 454
setAllAttribs(elm);
+ − 455
+ − 456
tinyMCE._setEventsEnabled(inst.getBody(), false);
+ − 457
tinyMCEPopup.execCommand("mceEndUndoLevel");
+ − 458
tinyMCEPopup.close();
+ − 459
}
+ − 460
+ − 461
function setAllAttribs(elm) {
+ − 462
var formObj = document.forms[0];
+ − 463
var href = formObj.href.value;
+ − 464
var target = getSelectValue(formObj, 'targetlist');
+ − 465
+ − 466
// Make anchors absolute
+ − 467
if (href.charAt(0) != '#')
+ − 468
href = convertURL(href, elm);
+ − 469
+ − 470
setAttrib(elm, 'href', href);
+ − 471
setAttrib(elm, 'mce_href', href);
+ − 472
setAttrib(elm, 'title');
+ − 473
setAttrib(elm, 'target', target == '_self' ? '' : target);
+ − 474
setAttrib(elm, 'id');
+ − 475
setAttrib(elm, 'style');
+ − 476
setAttrib(elm, 'class', getSelectValue(formObj, 'classlist'));
+ − 477
setAttrib(elm, 'rel');
+ − 478
setAttrib(elm, 'rev');
+ − 479
setAttrib(elm, 'charset');
+ − 480
setAttrib(elm, 'hreflang');
+ − 481
setAttrib(elm, 'dir');
+ − 482
setAttrib(elm, 'lang');
+ − 483
setAttrib(elm, 'tabindex');
+ − 484
setAttrib(elm, 'accesskey');
+ − 485
setAttrib(elm, 'type');
+ − 486
setAttrib(elm, 'onfocus');
+ − 487
setAttrib(elm, 'onblur');
+ − 488
setAttrib(elm, 'onclick');
+ − 489
setAttrib(elm, 'ondblclick');
+ − 490
setAttrib(elm, 'onmousedown');
+ − 491
setAttrib(elm, 'onmouseup');
+ − 492
setAttrib(elm, 'onmouseover');
+ − 493
setAttrib(elm, 'onmousemove');
+ − 494
setAttrib(elm, 'onmouseout');
+ − 495
setAttrib(elm, 'onkeypress');
+ − 496
setAttrib(elm, 'onkeydown');
+ − 497
setAttrib(elm, 'onkeyup');
+ − 498
+ − 499
// Refresh in old MSIE
+ − 500
if (tinyMCE.isMSIE5)
+ − 501
elm.outerHTML = elm.outerHTML;
+ − 502
}
+ − 503
+ − 504
function getSelectValue(form_obj, field_name) {
+ − 505
var elm = form_obj.elements[field_name];
+ − 506
+ − 507
if (elm == null || elm.options == null)
+ − 508
return "";
+ − 509
+ − 510
return elm.options[elm.selectedIndex].value;
+ − 511
}
+ − 512
+ − 513
function getLinkListHTML(elm_id, target_form_element, onchange_func) {
+ − 514
if (typeof(tinyMCELinkList) == "undefined" || tinyMCELinkList.length == 0)
+ − 515
return "";
+ − 516
+ − 517
var html = "";
+ − 518
+ − 519
html += '<select id="' + elm_id + '" name="' + elm_id + '"';
+ − 520
html += ' class="mceLinkList" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.' + target_form_element + '.value=';
+ − 521
html += 'this.options[this.selectedIndex].value;';
+ − 522
+ − 523
if (typeof(onchange_func) != "undefined")
+ − 524
html += onchange_func + '(\'' + target_form_element + '\',this.options[this.selectedIndex].text,this.options[this.selectedIndex].value);';
+ − 525
+ − 526
html += '"><option value="">---</option>';
+ − 527
+ − 528
for (var i=0; i<tinyMCELinkList.length; i++)
+ − 529
html += '<option value="' + tinyMCELinkList[i][1] + '">' + tinyMCELinkList[i][0] + '</option>';
+ − 530
+ − 531
html += '</select>';
+ − 532
+ − 533
return html;
+ − 534
+ − 535
// tinyMCE.debug('-- image list start --', html, '-- image list end --');
+ − 536
}
+ − 537
+ − 538
function getTargetListHTML(elm_id, target_form_element) {
+ − 539
var targets = tinyMCE.getParam('theme_advanced_link_targets', '').split(';');
+ − 540
var html = '';
+ − 541
+ − 542
html += '<select id="' + elm_id + '" name="' + elm_id + '" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.' + target_form_element + '.value=';
+ − 543
html += 'this.options[this.selectedIndex].value;">';
+ − 544
+ − 545
html += '<option value="_self">' + tinyMCE.getLang('lang_advlink_target_same') + '</option>';
+ − 546
html += '<option value="_blank">' + tinyMCE.getLang('lang_advlink_target_blank') + ' (_blank)</option>';
+ − 547
html += '<option value="_parent">' + tinyMCE.getLang('lang_advlink_target_parent') + ' (_parent)</option>';
+ − 548
html += '<option value="_top">' + tinyMCE.getLang('lang_advlink_target_top') + ' (_top)</option>';
+ − 549
+ − 550
for (var i=0; i<targets.length; i++) {
+ − 551
var key, value;
+ − 552
+ − 553
if (targets[i] == "")
+ − 554
continue;
+ − 555
+ − 556
key = targets[i].split('=')[0];
+ − 557
value = targets[i].split('=')[1];
+ − 558
+ − 559
html += '<option value="' + key + '">' + value + ' (' + key + ')</option>';
+ − 560
}
+ − 561
+ − 562
html += '</select>';
+ − 563
+ − 564
return html;
+ − 565
}
+ − 566
+ − 567
// While loading
+ − 568
preinit();