Created
October 29, 2021 03:17
-
-
Save monokano/0dc425eb116915b186ddfe4813a34493 to your computer and use it in GitHub Desktop.
InDesignの「再リンク時に画像サイズを保持」をON/OFFするJavaScript
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
// 「再リンク時に画像サイズを保持」をON/OFFする | |
var isPreserve = app.imagePreferences.preserveBounds; | |
var status = ""; | |
if ( isPreserve ){ | |
status = "ON"; | |
}else{ | |
status = "OFF"; | |
} | |
var result = multiBtnDlg("再リンク時に画像サイズを保持", "現状:"+status, ["ON", "OFF", "Close"], 2); | |
if(result===0){ | |
app.imagePreferences.preserveBounds = true; | |
}else if(result===1){ | |
app.imagePreferences.preserveBounds = false; | |
} | |
// モーダルウインドウ | |
// https://uske-s.hatenablog.com/entry/2018/08/08/191022 | |
function multiBtnDlg(title, text, list, focus) { | |
var cDlg = new Window("dialog", title); | |
cDlg.add("statictext", undefined, text, {multiline: true}); | |
var btnGrp = cDlg.add("group"); | |
var btnList = []; | |
for (var i=0; i<list.length; i++) { | |
if (i === focus) { | |
btnList.push(btnGrp.add("button", undefined, list[i], {name: "ok"})); | |
} else { | |
btnList.push(btnGrp.add("button", undefined, list[i])); | |
} | |
eval( | |
"btnList[i].onClick = function() {\n"+ | |
" cDlg.close("+(i)+");\n"+ | |
"}"); | |
} | |
return cDlg.show(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
改良版あります。
https://gist.github.com/monokano/e02dc68be64160bd6557c4154ae73174