Created
May 26, 2012 03:55
-
-
Save kuyseng/2792084 to your computer and use it in GitHub Desktop.
javascript: indesign get library index dialog
This file contains hidden or 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
function get_lib_index_dialog() { | |
// v 0.1.2 tested. | |
var library_name = ""; | |
var all_library_names = []; | |
var my_index = -1; | |
for (var i = 0, len = app.libraries.length; i<len;i++) { | |
all_library_names.push(remove_file_extension(app.libraries[i].name).toUpperCase()); | |
}; | |
if(all_library_names.length ===1){return 0;} | |
if(all_library_names.length>1) { | |
var my_dialog = app.dialogs.add({name: "Select Library to import artworks:", canCancel:true}); | |
with(my_dialog.dialogColumns.add()){ | |
with(dialogRows.add()){ | |
with(dialogColumns.add()){ | |
staticTexts.add({staticLabel:"Library Name: "}); | |
}; | |
with(dialogColumns.add()){ | |
var my_dropdown = dropdowns.add({stringList:all_library_names, selectedIndex:0}); | |
}; | |
}; | |
}; | |
var defaultScriptPreference = app.scriptPreferences.userInteractionLevel; | |
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL; | |
var myResult = my_dialog.show(); | |
app.scriptPreferences.userInteractionLevel = defaultScriptPreference; | |
if(myResult == true) { | |
my_index = my_dropdown.selectedIndex; | |
my_dialog.destroy(); | |
return my_index; | |
}else{ | |
my_dialog.destroy(); | |
return -1; | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment