////main.js: //////////////////////////////////////////// function Initialize() { document.body.style.backgroundColor = "#" + UIColorToHexString(csInterface.hostEnvironment.appSkinInfo.panelBackgroundColor); Persistent(true); Register(true, gRegisteredEvents.toString()); } (function () { 'use strict'; var csInterface = new CSInterface(); function init() { loadJSX(); // f_DocName(); f_Browse(); f_create(); f_btnMakeRefShape(); f_btnCreateComps(); getSessionCookies(); toggleText("cbAddStyle", "etAddStyle");//toogle gap text field disable/enable themeManager.init(); } init(); }()); function f_Browse() { var csInterface = new CSInterface(); $("#btnBrowse").click(function () { csInterface.evalScript('getFolder()', function (result) { $("#folderName").val(result); }); }); } * Load JSX file into the scripting context of the product. All the jsx files in * folder [ExtensionRoot]/host/include/ will be loaded. */ function loadJSX() { var csInterface = new CSInterface(); var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/host/include/"; csInterface.evalScript('$.myNamespace.evalFiles("' + extensionRoot + '")'); // var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/host/include/"; // csInterface.evalScript('$.ext.evalFiles("' + extensionRoot + '")'); // csInterface.evalScript(extensionFile); } function toggleScale(thsiId) { toggle = $("#" + thsiId).is(":checked"); $("#etMockupScale").prop("disabled", toggle); //Set the css opacity. if (toggle) { $("#scale_lbl").css('opacity', '0.3'); } else { $("#scale_lbl").css('opacity', '1.0'); } } }); //main.jsx ////////////////////////////// I renamed getFolder to getFolder to test anbd define iy in myFunc.jsx var home = true; if ($.getenv("USERNAME") == "danl") { home = false; } var scriptDir = "f:/Google Drive/Adobe/Scripts/"; if (!home) { scriptDir = "c:/My Doc/Google Drive/Adobe/Scripts/"; } if (typeof ($) == 'undefined') $ = {}; function getFolder1() { try { var defaultFolder = File(app.activeDocument.path); } catch (someError) { var defaultFolder = File("~"); } mf = function (f) { return /\.ai$/i.test(f.name) }, f = Folder.selectDialog("Import Folder", defaultFolder) if (f != null) { return f.fsName; } else { // if (f) return f.fullName; return ""; } } function getDocName() { return app.documents.length ? app.activeDocument.name : "No docs open!"; } function runMockupFunc(whichFunc) { var scriptFile = "runFunc.jsx"; var runScript = File(scriptDir + scriptFile); // alert("scriptDir:\n" + runScript); $.evalFile(runScript); } $.myNamespace = { //Evaluate a file and catch the exception. evalFile : function(path) { try { $.evalFile(path); } catch (e) {alert('Exception:' + e);} }, // Evaluate all the files in the given folder evalFiles: function(jsxFolderPath) { var folder = new Folder(jsxFolderPath); if (folder.exists) { var jsxFiles = folder.getFiles('*.jsx'); for (var i = 0; i < jsxFiles.length; i++) { var jsxFile = jsxFiles; $.myNamespace.evalFile(jsxFile); } } } }; ///////////////////// ////myFunc.jsx under /host/include/ function getFolder() { try { var defaultFolder = File(app.activeDocument.path); alert(defaultFolder); } catch (someError) { var defaultFolder = File("~"); } mf = function (f) { return /\.ai$/i.test(f.name) }, f = Folder.selectDialog("Import Folder", defaultFolder) if (f != null) { return f.fsName; } else { // if (f) return f.fullName; return ""; } } function getDocName() { return app.documents.length ? app.activeDocument.name : "No docs open!"; }
... View more