Last active
March 1, 2017 21:36
-
-
Save bjoerntx/19b956ed949b0074fd88405c0eae2052 to your computer and use it in GitHub Desktop.
This file contains 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 InsertSubTextPart(name, protect) { | |
// retrieve the JS Selection object | |
var sel = TXTextControl.selection | |
// check, if something has been selected | |
sel.getBounds(function (e) { | |
if (e.length == 0) { | |
alert('SubTextPart cannot be added - please select text.'); | |
return; | |
} | |
else { | |
// save the current selection | |
TXTextControl.saveSelection( | |
TXTextControl.streamType.InternalUnicodeFormat, | |
function (e) { | |
var serviceURL = "/Home/InsertSubTextPart"; | |
$.ajax({ | |
type: "POST", | |
url: serviceURL, | |
contentType: 'application/json', | |
data: JSON.stringify({ | |
Name: name, | |
BinaryDocument: e.data, | |
Protected: protect | |
}), | |
success: successFunc, | |
error: errorFunc | |
}); | |
function successFunc(data, status) { | |
// load the created SubTextPart into the current Selection | |
TXTextControl.loadSelection( | |
TXTextControl.StreamType.InternalUnicodeFormat, data); | |
} | |
function errorFunc() { | |
alert('Error'); | |
} | |
}); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment