Skip to content

Commit 4a6ff0b

Browse files
author
fabiantheblind
committed
inital local commit
1 parent e4b1350 commit 4a6ff0b

File tree

10 files changed

+10647
-0
lines changed

10 files changed

+10647
-0
lines changed

.project

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>MPOTools</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
16+
<nature>com.adobe.cside.html.project.csidehtmlnature</nature>
17+
</natures>
18+
</projectDescription>

.settings/.jsdtscope

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="src" path="ExtensionContent"/>
6+
<classpathentry kind="output" path=""/>
7+
</classpath>

.staged-extension/CSXS/manifest.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<ExtensionManifest Version="4.0" ExtensionBundleId="com.example.MPOTools" ExtensionBundleVersion="1.0.0"
4+
ExtensionBundleName="MPOTools" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<ExtensionList>
6+
<Extension Id="com.example.MPOTools.extension1" Version="1.0" />
7+
</ExtensionList>
8+
<ExecutionEnvironment>
9+
<HostList>
10+
<Host Name="IDSN" Version="[9.1,10.0]" />
11+
</HostList>
12+
<LocaleList>
13+
<Locale Code="All" />
14+
</LocaleList>
15+
<RequiredRuntimeList>
16+
<RequiredRuntime Name="CSXS" Version="4.0" />
17+
18+
</RequiredRuntimeList>
19+
</ExecutionEnvironment>
20+
<DispatchInfoList>
21+
<Extension Id="com.example.MPOTools.extension1">
22+
<DispatchInfo >
23+
<Resources>
24+
<MainPath>./index.html</MainPath>
25+
<ScriptPath>./MPOTools.jsx</ScriptPath>
26+
</Resources>
27+
<Lifecycle>
28+
<AutoVisible>true</AutoVisible>
29+
</Lifecycle>
30+
<UI>
31+
<Type>Panel</Type>
32+
<Menu>MPOTools</Menu>
33+
<Geometry>
34+
<Size>
35+
<Height>200</Height>
36+
<Width>200</Width>
37+
</Size>
38+
</Geometry>
39+
</UI>
40+
</DispatchInfo>
41+
</Extension>
42+
</DispatchInfoList>
43+
</ExtensionManifest>

ExtensionContent/MPOTools.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
if(typeof($)=='undefined')
2+
$={};
3+
4+
$._ext = {
5+
//Evaluate a file and catch the exception.
6+
evalFile : function(path) {
7+
try {
8+
$.evalFile(path);
9+
} catch (e) {alert("Exception:" + e);}
10+
},
11+
// Evaluate all the files in the given folder
12+
evalFiles: function(jsxFolderPath) {
13+
var folder = new Folder(jsxFolderPath);
14+
if (folder.exists) {
15+
var jsxFiles = folder.getFiles("*.jsx");
16+
for (var i = 0; i < jsxFiles.length; i++) {
17+
var jsxFile = jsxFiles[i];
18+
$._ext.evalFile(jsxFile);
19+
}
20+
}
21+
}
22+
};

ExtensionContent/ext.js

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
2+
function onLoaded() {
3+
var csInterface = new CSInterface();
4+
5+
6+
var appName = csInterface.hostEnvironment.appName;
7+
8+
if(appName != "FLPR"){
9+
loadJSX();
10+
}
11+
12+
var appNames = ["IDSN"];
13+
for (var i = 0; i < appNames.length; i++) {
14+
var name = appNames[i];
15+
if (appName.indexOf(name) >= 0) {
16+
var btn = document.getElementById("btn_" + name);
17+
if (btn)
18+
btn.disabled = false;
19+
}
20+
}
21+
22+
23+
updateThemeWithAppSkinInfo(csInterface.hostEnvironment.appSkinInfo);
24+
// Update the color of the panel when the theme color of the product changed.
25+
csInterface.addEventListener(CSInterface.THEME_COLOR_CHANGED_EVENT, onAppThemeColorChanged);
26+
27+
}
28+
29+
30+
31+
/**
32+
* Update the theme with the AppSkinInfo retrieved from the host product.
33+
*/
34+
function updateThemeWithAppSkinInfo(appSkinInfo) {
35+
36+
//Update the background color of the panel
37+
var panelBackgroundColor = appSkinInfo.panelBackgroundColor.color;
38+
document.body.bgColor = toHex(panelBackgroundColor);
39+
40+
var styleId = "ppstyle";
41+
42+
var csInterface = new CSInterface();
43+
var appName = csInterface.hostEnvironment.appName;
44+
45+
if(appName == "PHXS"){
46+
addRule(styleId, "button, select, input[type=button], input[type=submit]", "border-radius:3px;");
47+
}
48+
if(appName == "PHXS" || appName == "PPRO" || appName == "PRLD") {
49+
////////////////////////////////////////////////////////////////////////////////////////////////
50+
// NOTE: Below theme related code are only suitable for Photoshop. //
51+
// If you want to achieve same effect on other products please make your own changes here. //
52+
////////////////////////////////////////////////////////////////////////////////////////////////
53+
54+
55+
var gradientBg = "background-image: -webkit-linear-gradient(top, " + toHex(panelBackgroundColor, 40) + " , " + toHex(panelBackgroundColor, 10) + ");";
56+
var gradientDisabledBg = "background-image: -webkit-linear-gradient(top, " + toHex(panelBackgroundColor, 15) + " , " + toHex(panelBackgroundColor, 5) + ");";
57+
var boxShadow = "-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);";
58+
var boxActiveShadow = "-webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);";
59+
60+
var isPanelThemeLight = panelBackgroundColor.red > 127;
61+
var fontColor, disabledFontColor;
62+
var borderColor;
63+
var inputBackgroundColor;
64+
var gradientHighlightBg;
65+
if(isPanelThemeLight) {
66+
fontColor = "#000000;";
67+
disabledFontColor = "color:" + toHex(panelBackgroundColor, -70) + ";";
68+
borderColor = "border-color: " + toHex(panelBackgroundColor, -90) + ";";
69+
inputBackgroundColor = toHex(panelBackgroundColor, 54) + ";";
70+
gradientHighlightBg = "background-image: -webkit-linear-gradient(top, " + toHex(panelBackgroundColor, -40) + " , " + toHex(panelBackgroundColor,-50) + ");";
71+
} else {
72+
fontColor = "#ffffff;";
73+
disabledFontColor = "color:" + toHex(panelBackgroundColor, 100) + ";";
74+
borderColor = "border-color: " + toHex(panelBackgroundColor, -45) + ";";
75+
inputBackgroundColor = toHex(panelBackgroundColor, -20) + ";";
76+
gradientHighlightBg = "background-image: -webkit-linear-gradient(top, " + toHex(panelBackgroundColor, -20) + " , " + toHex(panelBackgroundColor, -30) + ");";
77+
}
78+
79+
80+
//Update the default text style with pp values
81+
82+
addRule(styleId, ".default", "font-size:" + appSkinInfo.baseFontSize + "px" + "; color:" + fontColor + "; background-color:" + toHex(panelBackgroundColor) + ";");
83+
addRule(styleId, "button, select, input[type=text], input[type=button], input[type=submit]", borderColor);
84+
addRule(styleId, "button, select, input[type=button], input[type=submit]", gradientBg);
85+
addRule(styleId, "button, select, input[type=button], input[type=submit]", boxShadow);
86+
addRule(styleId, "button:enabled:active, input[type=button]:enabled:active, input[type=submit]:enabled:active", gradientHighlightBg);
87+
addRule(styleId, "button:enabled:active, input[type=button]:enabled:active, input[type=submit]:enabled:active", boxActiveShadow);
88+
addRule(styleId, "[disabled]", gradientDisabledBg);
89+
addRule(styleId, "[disabled]", disabledFontColor);
90+
addRule(styleId, "input[type=text]", "padding:1px 3px;");
91+
addRule(styleId, "input[type=text]", "background-color: " + inputBackgroundColor) + ";";
92+
addRule(styleId, "input[type=text]:focus", "background-color: #ffffff;");
93+
addRule(styleId, "input[type=text]:focus", "color: #000000;");
94+
95+
} else {
96+
// For AI, ID and FL use old implementation
97+
addRule(styleId, ".default", "font-size:" + appSkinInfo.baseFontSize + "px" + "; color:" + reverseColor(panelBackgroundColor) + "; background-color:" + toHex(panelBackgroundColor, 20));
98+
addRule(styleId, "button", "border-color: " + toHex(panelBgColor, -50));
99+
}
100+
}
101+
102+
function addRule(stylesheetId, selector, rule) {
103+
var stylesheet = document.getElementById(stylesheetId);
104+
105+
if (stylesheet) {
106+
stylesheet = stylesheet.sheet;
107+
if( stylesheet.addRule ){
108+
stylesheet.addRule(selector, rule);
109+
} else if( stylesheet.insertRule ){
110+
stylesheet.insertRule(selector + ' { ' + rule + ' }', stylesheet.cssRules.length);
111+
}
112+
}
113+
}
114+
115+
116+
function reverseColor(color, delta) {
117+
return toHex({red:Math.abs(255-color.red), green:Math.abs(255-color.green), blue:Math.abs(255-color.blue)}, delta);
118+
}
119+
120+
/**
121+
* Convert the Color object to string in hexadecimal format;
122+
*/
123+
function toHex(color, delta) {
124+
function computeValue(value, delta) {
125+
var computedValue = !isNaN(delta) ? value + delta : value;
126+
if (computedValue < 0) {
127+
computedValue = 0;
128+
} else if (computedValue > 255) {
129+
computedValue = 255;
130+
}
131+
132+
computedValue = computedValue.toString(16);
133+
return computedValue.length == 1 ? "0" + computedValue : computedValue;
134+
}
135+
136+
var hex = "";
137+
if (color) {
138+
with (color) {
139+
hex = computeValue(red, delta) + computeValue(green, delta) + computeValue(blue, delta);
140+
};
141+
}
142+
return "#" + hex;
143+
}
144+
145+
function onAppThemeColorChanged(event) {
146+
// Should get a latest HostEnvironment object from application.
147+
var skinInfo = JSON.parse(window.__adobe_cep__.getHostEnvironment()).appSkinInfo;
148+
// Gets the style information such as color info from the skinInfo,
149+
// and redraw all UI controls of your extension according to the style info.
150+
updateThemeWithAppSkinInfo(skinInfo);
151+
}
152+
153+
154+
155+
156+
/**
157+
* Load JSX file into the scripting context of the product. All the jsx files in
158+
* folder [ExtensionRoot]/jsx will be loaded.
159+
*/
160+
function loadJSX() {
161+
var csInterface = new CSInterface();
162+
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/jsx/";
163+
csInterface.evalScript('$._ext.evalFiles("' + extensionRoot + '")');
164+
}
165+
166+
function evalScript(script, callback) {
167+
new CSInterface().evalScript(script, callback);
168+
}
169+
170+
function onClickButton(ppid) {
171+
if(ppid == "FLPR"){
172+
var jsfl = 'fl.createDocument(); fl.getDocumentDOM().addNewText({left:100, top:100, right:300, bottom:300} , "Hello Flash!" ); ';
173+
evalScript(jsfl);
174+
} else {
175+
var extScript = "$._ext_" + ppid + ".run()";
176+
evalScript(extScript);
177+
}
178+
}

ExtensionContent/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
3+
<html>
4+
<head>
5+
<meta charset="utf-8">
6+
<script src="./ext.js"></script>
7+
<script src="./lib/CSInterface-4.0.0.js"></script>
8+
9+
<link id="ppstyle" rel="stylesheet" type="text/css" href="./style.css">
10+
<title>MPOTools</title>
11+
</head>
12+
13+
<body onLoad="onLoaded()">
14+
<div id="content">
15+
<ul>
16+
17+
18+
<li><button class="default" id="btn_IDSN" onClick="onClickButton('IDSN')" disabled="true">Run id code</button></li>
19+
20+
</ul>
21+
</div></body>
22+
23+
</html>

ExtensionContent/jsx/InDesign.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
$._ext_IDSN={
2+
run : function() {
3+
4+
/********** Replace below sample code with your own JSX code **********/
5+
var appName;
6+
appName = "Hello InDesign";
7+
alert(appName);
8+
/************************************************************************/
9+
10+
return appName;
11+
},
12+
};

0 commit comments

Comments
 (0)