SlidingCurtain + visibility

Topics: Developer Forum
Jul 4, 2008 at 6:22 AM
Hello,

How can I determine whether the SlidingCurtain control is visible or not? In your example site, it's only visible when a user (Administrator/Editor) is logged in, but I cannot find the code where you set the control to visible or how the control itself determines whether it should be visible or not.

How can I make the SlidingCurtain control visible for Editors/Administrators? I already have code to determine whether the user is an admin or editor, I just need to know how to make it visible.

Best regards,

Geert
Coordinator
Jul 7, 2008 at 1:24 AM
ControlPanel.cs contains this code to determine it's state:

 

public static ControlPanelState GetState()
{
if (N2.Context.SecurityManager.IsEditor(User))
{
if (Request["edit"] == "true")
return ControlPanelState.Editing;
else if (Request["edit"] == "drag")
return ControlPanelState.DragDrop;
else if (Request["preview"] == "true")
return ControlPanelState.Previewing;
else
return ControlPanelState.Visible;
}
return ControlPanelState.Hidden;
}

I think the sliding curtain also uses this method and it should work on its own.

Jul 7, 2008 at 12:33 PM
Thanks for your answer.

I have implemented some custom code so more roles are allowed (you specify roles somewhat differently than me) using the Global.asax file. Now the little arrow is visibile, but nothing happens when I click it.

Any ideas? The javascript is located in the folder (since /edit/ directory is available).

Best regards

Geert
Coordinator
Jul 9, 2008 at 5:36 AM
Some javascript error? Are you using prototype by any chance?
Jul 9, 2008 at 7:44 AM
"Are you using prototype by any chance?"

What do you mean by this?
Jul 9, 2008 at 7:50 AM
Another update:

when I append ?edit=drag to the page in admin mode, I get a javascript error:

---------------------------
Error
---------------------------
A runtime error occurred.

Line: 11
Error: 'dropZones' is not defined

Any ideas?

Best regards

Coordinator
Jul 10, 2008 at 3:29 AM
When you added the sliding panel did you place a control panel inside it?

    <n2:SlidingCurtain runat="server">
        <n2:DragDropControlPanel runat="server"/>
    </n2:SlidingCurtain>
Jul 10, 2008 at 7:09 AM
The dropZones error is fixed now and I can see the drop zones. However, since I cannot expand the panel, I cannot drop my parts on the page.

So now my question is: why isn't the panel expanding when I click it? There are no javascript errors, nothing happens.
Jul 11, 2008 at 7:21 AM
Now I understand what you mean by "Are you using prototype by any chance?".

Yes, I was using prototype.js and I have removed the script. Now all is working fine.
Mar 9, 2009 at 10:47 AM
Hello Tischnoetentoet,

I am having the same problem. Can you please tell me how you have solved this issue?
Mar 23, 2009 at 7:10 AM
Hello hb_kalpana,

Sorry for my late reply, I was on vacation.

Are you by any chance using a 3rd party javascript file? For example, to show screenshots in a popup window or something like that? That was the cause for me.

Best regards,

Geert
May 15, 2009 at 3:03 PM

Hi

Sorry to append this to an old discussion but we recently experienced a similar issue.

We had a part added to a recursive droppable zone on the start page of a site, so that the part would be present on all pages on the site. This worked fine. However, if we selected 'organize parts' on the sliding curtain, we were presented with the following javascript error:

Error: dropZones is not defined
Line: 10

After investigating the issue it appeared that this was happening because the draggable zone's property AllowExternalManipulation was not set, and so the drop panel was not being added to the page, but the delegate in ControlPanelDragPluginAttribute to set the visibility of the 'organize parts' link was not picking up on this:

public override Control AddTo(Control container, PluginContext context)
        {
            Control control = base.AddTo(container, context);
            if(control != null)
                container.Page.PreRender += delegate { control.Visible = container.Page.Items[Zone.PageKey] != null;};
            return control;
        }

i.e. there was a zone added, it just couldn't be displayed on the page.

My first question is whether this is in fact desired behaviour, and if in fact we were doing something wrong to have encountered this problem in the first place?

We ended up applying the following change to ControlPanelDragPluginAttribute:

public override Control AddTo(Control container, PluginContext context)
        {
            Control control = base.AddTo(container, context);
            if (control != null)
            {
                container.Page.PreRender += delegate { control.Visible = SetVisibility(container); };
            }
            return control;
        }

private static bool SetVisibility(Control container)
        {
            var zones = container.Page.Items[Zone.PageKey] as IList<Zone>;
            if (zones != null)
            {
                foreach (var zone in zones)
                {
                    if (zone is DroppableZone)
                    {
                        var droppableZone = (DroppableZone) zone;
                        if (droppableZone.CanBeManipulated())
                        {
                            return true;
                        }
                    }
                    else
                    {
                        // Assuming we don't care if there exists another zone of a different type.
                        return true;
                    }
                }
            }
            return false;
        }

Added the else clause to prevent any additional issues arrising from adding other zones to the list, whether they are added currently or in the future.

The definition of CanBeManipulated() in DroppableZone is as follows:

public bool CanBeManipulated()
        {
            return AllowExternalManipulation || CurrentItem == CurrentPage;
        }

My second question is whether there was a better way of doing this, and if we may have introduced any bugs?

Thanks, Nigel.

Coordinator
May 15, 2009 at 4:06 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
May 15, 2009 at 4:10 PM

Nigel, this will probably change a bit to add support for ViewPages without server form but I'll keep your changes in mind.