includes/clientside/tinymce/plugins/advlink/js/advlink.js
changeset 543 dffcbfbc4e59
parent 476 f26a69c40431
child 778 57ce13805b6f
equal deleted inserted replaced
542:5841df0ab575 543:dffcbfbc4e59
    12 	if (url = tinyMCEPopup.getParam("external_link_list_url"))
    12 	if (url = tinyMCEPopup.getParam("external_link_list_url"))
    13 		document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
    13 		document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
    14 }
    14 }
    15 
    15 
    16 function changeClass() {
    16 function changeClass() {
    17 	var formObj = document.forms[0];
    17 	var f = document.forms[0];
    18 	formObj.classes.value = getSelectValue(formObj, 'classlist');
    18 
       
    19 	f.classes.value = getSelectValue(f, 'classlist');
    19 }
    20 }
    20 
    21 
    21 function init() {
    22 function init() {
    22 	tinyMCEPopup.resizeToInnerSize();
    23 	tinyMCEPopup.resizeToInnerSize();
    23 
    24 
   107 
   108 
   108 		selectByValue(formObj, 'classlist', inst.dom.getAttrib(elm, 'class'), true);
   109 		selectByValue(formObj, 'classlist', inst.dom.getAttrib(elm, 'class'), true);
   109 		selectByValue(formObj, 'targetlist', inst.dom.getAttrib(elm, 'target'), true);
   110 		selectByValue(formObj, 'targetlist', inst.dom.getAttrib(elm, 'target'), true);
   110 	} else
   111 	} else
   111 		addClassesToList('classlist', 'advlink_styles');
   112 		addClassesToList('classlist', 'advlink_styles');
   112 
       
   113 	window.focus();
       
   114 }
   113 }
   115 
   114 
   116 function checkPrefix(n) {
   115 function checkPrefix(n) {
   117 	if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_email')))
   116 	if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_email')))
   118 		n.value = 'mailto:' + n.value;
   117 		n.value = 'mailto:' + n.value;
   234 		}
   233 		}
   235 
   234 
   236 		regExp += "\\);?";
   235 		regExp += "\\);?";
   237 
   236 
   238 		// Build variable array
   237 		// Build variable array
   239 		var variables = new Array();
   238 		var variables = [];
   240 		variables["_function"] = fnName;
   239 		variables["_function"] = fnName;
   241 		var variableValues = link.replace(new RegExp(regExp, "gi"), replaceStr).split('<delim>');
   240 		var variableValues = link.replace(new RegExp(regExp, "gi"), replaceStr).split('<delim>');
   242 		for (var i=0; i<variableNames.length; i++)
   241 		for (var i=0; i<variableNames.length; i++)
   243 			variables[variableNames[i]] = variableValues[i];
   242 			variables[variableNames[i]] = variableValues[i];
   244 
   243 
   248 	return null;
   247 	return null;
   249 }
   248 }
   250 
   249 
   251 function parseOptions(opts) {
   250 function parseOptions(opts) {
   252 	if (opts == null || opts == "")
   251 	if (opts == null || opts == "")
   253 		return new Array();
   252 		return [];
   254 
   253 
   255 	// Cleanup the options
   254 	// Cleanup the options
   256 	opts = opts.toLowerCase();
   255 	opts = opts.toLowerCase();
   257 	opts = opts.replace(/;/g, ",");
   256 	opts = opts.replace(/;/g, ",");
   258 	opts = opts.replace(/[^0-9a-z=,]/g, "");
   257 	opts = opts.replace(/[^0-9a-z=,]/g, "");
   259 
   258 
   260 	var optionChunks = opts.split(',');
   259 	var optionChunks = opts.split(',');
   261 	var options = new Array();
   260 	var options = [];
   262 
   261 
   263 	for (var i=0; i<optionChunks.length; i++) {
   262 	for (var i=0; i<optionChunks.length; i++) {
   264 		var parts = optionChunks[i].split('=');
   263 		var parts = optionChunks[i].split('=');
   265 
   264 
   266 		if (parts.length == 2)
   265 		if (parts.length == 2)
   404 	// Create new anchor elements
   403 	// Create new anchor elements
   405 	if (elm == null) {
   404 	if (elm == null) {
   406 		tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
   405 		tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
   407 
   406 
   408 		elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
   407 		elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
   409 		for (i=0; i<elementArray.length; i++) {
   408 		for (i=0; i<elementArray.length; i++)
   410 			elm = elementArray[i];
   409 			setAllAttribs(elm = elementArray[i]);
   411 
       
   412 			// Move cursor to end
       
   413 			try {
       
   414 				tinyMCEPopup.editor.selection.collapse(false);
       
   415 			} catch (ex) {
       
   416 				// Ignore
       
   417 			}
       
   418 
       
   419 			// Move cursor behind the new anchor
       
   420 			// Don't remember why this was needed so it's now removed
       
   421 			/*
       
   422 			if (tinyMCE.isGecko) {
       
   423 				var sp = inst.getDoc().createTextNode(" ");
       
   424 
       
   425 				if (elm.nextSibling)
       
   426 					elm.parentNode.insertBefore(sp, elm.nextSibling);
       
   427 				else
       
   428 					elm.parentNode.appendChild(sp);
       
   429 
       
   430 				// Set range after link
       
   431 				var rng = inst.getDoc().createRange();
       
   432 				rng.setStartAfter(elm);
       
   433 				rng.setEndAfter(elm);
       
   434 
       
   435 				// Update selection
       
   436 				var sel = inst.getSel();
       
   437 				sel.removeAllRanges();
       
   438 				sel.addRange(rng);
       
   439 			}
       
   440 			*/
       
   441 
       
   442 			setAllAttribs(elm);
       
   443 		}
       
   444 	} else
   410 	} else
   445 		setAllAttribs(elm);
   411 		setAllAttribs(elm);
       
   412 
       
   413 	// Don't move caret if selection was image
       
   414 	if (elm.childNodes.length != 1 || elm.firstChild.nodeName != 'IMG') {
       
   415 		inst.focus();
       
   416 		inst.selection.select(elm);
       
   417 		inst.selection.collapse(0);
       
   418 		tinyMCEPopup.storeSelection();
       
   419 	}
   446 
   420 
   447 	tinyMCEPopup.execCommand("mceEndUndoLevel");
   421 	tinyMCEPopup.execCommand("mceEndUndoLevel");
   448 	tinyMCEPopup.close();
   422 	tinyMCEPopup.close();
   449 }
   423 }
   450 
   424