Created
July 11, 2012 19:15
-
-
Save sniffdk/3092516 to your computer and use it in GitHub Desktop.
Umbraco - javascript functions for localmedia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dialogHandler(id) { | |
var iesucks = new Date().getTime(); | |
$.ajax('/-/NodeService/GetTinyMceMediaStringFromId', { | |
type: "GET", | |
dataType: "json", | |
async: false, | |
data: { | |
id: id, | |
iesucks: iesucks | |
}, | |
success: function (data) { | |
id = data; | |
if (id == "-1") return; | |
var returnValues = id.split("|"); | |
if (returnValues.length > 1) { | |
if (returnValues[1] != '') | |
setFormValue('href', returnValues[1]); | |
else | |
setFormValue('href', returnValues[0]); | |
setFormValue('localUrl', returnValues[0]); | |
setFormValue('title', returnValues[2]); | |
} else { | |
if (id.substring(id.length - 1, id.length) == "|") | |
id = id.substring(0, id.length - 1); | |
setFormValue('href', id); | |
setFormValue('localUrl', id); | |
//umbraco.presentation.webservices.legacyAjaxCalls.NiceUrl(id, updateInternalLink, updateInternalLinkError); | |
} | |
} | |
}); | |
} | |
function validateUmbracoLink(link) { | |
if (link.indexOf('{localLink') > -1) { | |
// check for / prefix | |
if (link.substring(0, 1) == "/") { | |
link = link.substring(1, link.length); | |
} | |
// update internal link ref | |
setFormValue('localUrl', link); | |
currentLink = link; | |
// show friendly url | |
umbraco.presentation.webservices.legacyAjaxCalls.NiceUrl(link.substring(11, link.length - 1), updateInternalLink, updateInternalLinkError); | |
return "Updating internal link..."; | |
} | |
else if (link.indexOf('{localMedia') > -1) { | |
var iesucks = new Date().getTime(); | |
var name; | |
$.ajax('/-/NodeService/GetTinyMceMediaStringFromLink', { | |
type: "GET", | |
dataType: "json", | |
async: false, | |
data: { | |
link: link, | |
iesucks: iesucks | |
}, | |
success: function (data) { | |
// update internal link ref | |
setFormValue('localUrl', data.Url); | |
currentLink = data.Url; | |
updateInternalLink(data.Path); | |
name = data.Path; | |
} | |
}); | |
return name; | |
} else { | |
return link; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment