File: /home/mmickelson/theflexguy.com/apps/silicondesigner/villagepress/js/app/SDExternalInterface.js
// Called from JavaScript to Flex -----
function SDExternalInterface(){
}
SDExternalInterface.app;//static
SDExternalInterface.prototype.registerCallBackInstance = function( functionName ){//functionName must be a string!
document[SDExternalInterface.app].registerCallBackInstance( functionName );
}
// UPDATE INSTANCE: Saves all pages in the instance.
SDExternalInterface.prototype.updateInstance = function(){
document[SDExternalInterface.app].updateInstance();
}
// UPDATE LAYOUT NUM: Saves a specific layout number (similar to
// page number) in the instance. If none is provided, the selected
// page is saved.
SDExternalInterface.prototype.updateLayoutNum = function(layoutNum){
document[SDExternalInterface.app].updateLayoutNum(layoutNum);
}
// GET INSTANCE ID: Returns the instanceId of the current project.
SDExternalInterface.prototype.getInstanceId = function(){
return document[SDExternalInterface.app].getInstanceId();
}
// GET SESSION ID: Returns the instanceId of the current project.
SDExternalInterface.prototype.getSessionId = function(){
return document[SDExternalInterface.app].getSessionId();
}
// GET INSTANCE: Returns the layoutSet.xml of the instance.
SDExternalInterface.prototype.getInstance = function(){
return document[SDExternalInterface.app].getInstance();
}
// CHANGE THEME: Changes the current theme to the template provided.
SDExternalInterface.prototype.changeTheme = function(templateId){
document[SDExternalInterface.app].changeTheme(templateId);
}
// CHANGE LAYOUT: Changes the layout of the provided layout number
// to the provided layoutId. If no layoutNum is provided, the
// selected layoutNum is changed.
SDExternalInterface.prototype.changeLayout = function(layoutId, layoutNum){
document[SDExternalInterface.app].changeLayout(layoutId, layoutNum);
}
// RESET LAYOUT: Changes the layout of the supplied layout number to
// it’s original layout defined in the template. If no layout
// number is provided, the selected layout number will be changed.
SDExternalInterface.prototype.resetLayout = function(layoutNum){
document[SDExternalInterface.app].resetLayout(layoutNum);
}
// GET SELECTED LAYOUT: Returns the currently selected layout number.
SDExternalInterface.prototype.getSelectedLayout = function(){
return document[SDExternalInterface.app].getSelectedLayout();
}
// GO TO LAYOUT: Requests the application to select the provided
// layout number.
SDExternalInterface.prototype.goToLayout = function(layoutNum){
document[SDExternalInterface.app].goToLayout(layoutNum);
}
//GO TO SPREAD: Requests the application to move selection to the
// provided spread index.
SDExternalInterface.prototype.goToSpread = function(spreadIndex){
document[SDExternalInterface.app].goToSpread(spreadIndex);
}
// ALLOW NEW ITEMS: Tells the application if the user is allowed to
// add any new text, image or graphic items to the provided layout
// number or if none is provided, the selected layout number.
SDExternalInterface.prototype.allowNewItems = function(isAllowed, layoutNum){
document[SDExternalInterface.app].allowNewItems(isAllowed, layoutNum);
}
// ALLOW NEW TEXT ITEMS: Tells the application if the user is
// allowed to add any new text items to the provided layout number,
// or if none is provided, the selected layout number.
SDExternalInterface.prototype.allowNewTextItems = function(isAllowed, layoutNum){
document[SDExternalInterface.app].allowNewTextItems(isAllowed, layoutNum);
}
// ALLOW NEW IMAGE ITEMS: Tells the application if the user is
// allowed to add any new image items to the provided layout
// number, or if none is provided, the selected layout number.
SDExternalInterface.prototype.allowNewImageItems = function(isAllowed, layoutNum){
document[SDExternalInterface.app].allowNewImageItems(isAllowed, layoutNum);
}
// ALLOW NEW GRAPHIC ITEMS: Tells the application if the user is
// allowed to add any new graphic items to the provided layout
// number, or if none is provided, the selected layout number.
SDExternalInterface.prototype.allowNewGraphicItems = function(isAllowed, layoutNum){
document[SDExternalInterface.app].allowNewGraphicItems(isAllowed, layoutNum);
}
// SET PREVIEW MODE ENABLED: Enables or disables preview mode.
SDExternalInterface.prototype.setPreviewModeEnabled = function(enable){
document[SDExternalInterface.app].setPreviewModeEnabled(enable);
}
// POPULATE IMAGE ITEMS: Requests the image placeholders in the
// current instance to be populated with the images specified in
// the XML.
SDExternalInterface.prototype.populateImageItems = function(imagesXML){
document[SDExternalInterface.app].populateImageItems(imagesXML);
}
// SET LAYOUT DIE CUT: Sets the die cut to the supplied mask swf.
SDExternalInterface.prototype.setLayoutDieCut = function(webFileName){
document[SDExternalInterface.app].setLayoutDieCut(webFileName);
}
// SET ENVELOPE FLAP DIE CUT: Sets the envelope flap die cut to the
// supplied mask swf.
SDExternalInterface.prototype.setEnvelopeFlapDieCut = function(webFileName){
document[SDExternalInterface.app].setEnvelopeFlapDieCut(webFileName);
}
// SET ENVELOPE INTERIOR DESIGN: Sets the envelope interior to the
// supplied file.
SDExternalInterface.prototype.setEnvelopeInteriorDesign = function(webFileName, printFileName){
document[SDExternalInterface.app].setEnvelopeInteriorDesign(webFileName, printFileName);
}
// SHOW ENVELOPE RETURN ADDRESS: Shows or hides the return address
// of an envelope.
SDExternalInterface.prototype.showEnvelopeReturnAddress = function(visible){
document[SDExternalInterface.app].showEnvelopeReturnAddress(visible);
}
// IS DOCUMENT VALID: Returns whether or not a document has validation warnings
SDExternalInterface.prototype.isDocumentValid = function(){
return document[SDExternalInterface.app].isDocumentValid();
}
// ENABLE/DISABLE SPELL CHECK: activates and sets the location for spell check
SDExternalInterface.prototype.setSpellCheckState = function( enabled, languageCode ){
languageCode = (typeof languageCode === "undefined") ? "en_US" : languageCode;
document[SDExternalInterface.app].setSpellCheckState( enabled, languageCode );
}
// GET ERROR SUMMARY: Returns object array of validators in the currents errors array
SDExternalInterface.prototype.getErrorSummary = function(){
var results = document[SDExternalInterface.app].getErrorSummary();
console.log(results);
return results;
}
// CLEAR LOCAL SHARED OBJECT FOR THIS APP: Clears any data stored locally for this app including screen overlay settings
SDExternalInterface.prototype.clearLocalSharedObject = function(){
document[SDExternalInterface.app].clearLocalSharedObject();
}
// CALLED FROM Flex to JavaScript --------------------------------
// TRACK METRIC: Passes metric name and value to be passed to tracking api
// Implement your tracking code here
SDExternalInterface.prototype.trackMetric = function(label, value){
if( console !== undefined && console !== null ) {
console.log("SDExternalInterface.prototype.trackMetric called label: " + label + " value: " + value);
}
}
// INSTANCE ID CREATED: Gives the instance ID. Useful when
// starting with a templateId.
SDExternalInterface.prototype.instanceIdCreated = function(instanceId){
if( console !== undefined && console !== null ) {
console.log("instanceId created:");
console.log(instanceId);
}
}
// CONTINUE REQUESTED: User has clicked the continue button
SDExternalInterface.prototype.continueRequested = function(){
if( console !== undefined && console !== null ) {
console.log("continue requested");
}
}
// SAVE REQUESTED: User has clicked the save button
SDExternalInterface.prototype.saveRequested = function(){
if( console !== undefined && console !== null ) {
console.log("save requested");
}
}
// SAVE COMPLETE: A save has been made and completed
SDExternalInterface.prototype.saveComplete = function(instanceId){
if( console !== undefined && console !== null ) {
console.log("save complete for instance:");
console.log(instanceId);
}
}
// EXIT REQUESTED: User has clicked the button to leave the application.
// This does not trigger a save in the flex but could be done with updateInstance().
SDExternalInterface.prototype.exitRequested = function(){
window.history.back();
}
// PREVIEW REQUESTED: User has clicked the preview button
SDExternalInterface.prototype.previewRequested = function(layoutNum){
if( console !== undefined && console !== null ) {
console.log("preview requested for layout:");
console.log(layoutNum);
}
var instanceID = document[SDExternalInterface.app].getInstanceId();
var sessionID = document[SDExternalInterface.app].getSessionId();
if(typeof instanceID !== "undefined" && instanceID !== null && typeof sessionID !== "undefined" && sessionID !== null ){
var baseURL = ( flashvars.baseUrl.substr( flashvars.baseUrl.length - 1 ) != "/" ) ? flashvars.baseUrl + "/" : flashvars.baseUrl ;
if(typeof layoutNum != "undefined" && layoutNum != null) {
window.open( baseURL + "sdsession/" + sessionID + "/instance/" + instanceID + "/layoutnumber/" + layoutNum + "/output/pdf" );
} else {
window.open( baseURL + "sdsession/" + sessionID + "/instance/" + instanceID + "/output/pdf" );
}
}
}
// LAYOUT ACTIVITY: Notifies JS when layouts were added, removed, or
// selected. ActivityType can be "ADD"|"REMOVE"|"SELECTED".
SDExternalInterface.prototype.layoutActivity = function(activityType, startingLayoutNum, numLayouts){
}
// ITEM ACTIVITY: Notifies JS when text, image or graphic items were
// added, removed, or selected. ActivityType can be
// "ADD"|"REMOVE"|"SELECTED".
SDExternalInterface.prototype.itemActivity = function(activityType, itemXML){
}
// MESSAGE FROM DESIGNER: The Silicon Designer application can call
// this JavaScript function with helpful notifications or messages
// to help debug.
SDExternalInterface.prototype.messageFromFlex = function(message){
if( console !== undefined && console !== null ) {
console.log(message);
}
}