File: /home/mmickelson/theflexguy.com/apps/silicondesigner/sg/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 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();
}
// CALLED FROM Flex to JavaScript --------------------------------
// INSTANCE ID CREATED: Gives the instance ID. Useful when
// starting with a templateId.
SDExternalInterface.prototype.instanceIdCreated = function(instanceId){
// console.log("instanceId created:");
// console.log(instanceId);
}
// CONTINUE REQUESTED: User has clicked the continue button
SDExternalInterface.prototype.continueRequested = function(){
// console.log("continue requested");
}
// SAVE REQUESTED: User has clicked the save button
SDExternalInterface.prototype.saveRequested = function(){
// console.log("save requested");
}
// PREVIEW REQUESTED: User has clicked the preview button
SDExternalInterface.prototype.previewRequested = function(){
// console.log("preview requested");
}
// 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){
// console.log(message);
}
SDExternalInterface.prototype.saveProjectAs = function(projectName, instanceId){
console.log(projectName);
console.log(instanceId);
}
SDExternalInterface.prototype.checkout = function(instanceId, jsonAddresses, returnAddressType, returnAddress){
console.log(instanceId);
console.log(unescape(jsonAddresses));
console.log(returnAddressType);
console.log(returnAddress);
}