• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Javascript not functioning on dropdown menu

Explorer ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

Hello people,

I have created a dropdown button with three states changing each when inactive, on hover and active and it is functioning well in a browser, but in Photoshop when active it won't show the activated state, instead it creates a rectangle around the button and also doe not open the menu. I guess there is problem between Javascript code and Photoshop compatibility, but am not so sure. Here is the Javascript code:

//dropdown

function dropdown_one(btn) {
  document
.getElementById("menu_list").classList.toggle("dcontent");
  btn
.classList.toggle("button-selected");
}
//condition
window
.onclick = function(event) {
 
if (!event.target.matches('.button')) {

  
var menu = document.getElementsByClassName("dropdown-content");
  
var i;
  
for (i = 0; i < menu.length; i++) {
  
var open_list = menu[i];
  
if (open_list.classList.contains('dcontent')) {
  open_list
.classList.remove('dcontent');
  
}
  
}
  
let selected = document.getElementsByClassName("button-selected");
  
for (let i = 0, len = selected.length; i < len; i++) {
  selected
[i].classList.remove("button-selected");
  
}
 
}
}

Please if someone can adapt this code to function in Photoshop.

Thank you,

teslaball

P.S. Here is an example on codepen.io to show you exactly how i want to function in Photoshop:

https://codepen.io/anon/pen/ggxYxJ

TOPICS
Actions and scripting

Views

624

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

Well, have you actually looked at the scripting guides? Your code doesn't really make much sense, since a panel button would for instance not be related to the document but to the application. I'm afraid you have some real reading to do...

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

Can you please help me on this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 25, 2017 Jan 25, 2017

Copy link to clipboard

Copied

I actually solved the problem by replacing let with var.

Now I have two problems, the first problem is when clicking on the dropdown button it is framed in an orange rectangle and the second problem is when a menu list is opened, it disappears only when clicked in the area of the extension, but when clicking outside in an area somewhere else in photoshop, it stays open.

Some can do the trick please?

Thanks,

teslaball

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2017 Jan 25, 2017

Copy link to clipboard

Copied

LATEST

Moved discussion to the scripting forum

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines