Exemple #1
0
 private void AppendActionCursor(StringBuilder builder)
 {
     if (_widgetStyle.OwnerWidget.Events[EventType.OnClick] != null)
     {
         foreach (IInteractionCase interactionCase in _widgetStyle.OwnerWidget.Events[EventType.OnClick].Cases)
         {
             foreach (IInteractionAction action in interactionCase.Actions)
             {
                 if (action.ActionType == ActionType.OpenAction)
                 {
                     IInteractionOpenAction openAction = action as IInteractionOpenAction;
                     if (openAction != null && openAction.LinkType != LinkType.None)
                     {
                         builder.Append("\"cursor\":\"pointer\",");
                     }
                 }
                 else if (action.ActionType == ActionType.CloseAction)
                 {
                     builder.Append("\"cursor\":\"pointer\",");
                 }
                 else if (action.ActionType == ActionType.ShowHideAction)
                 {
                     IInteractionShowHideAction showAction = action as IInteractionShowHideAction;
                     if (showAction != null && showAction.TargetObjects.Count > 0)
                     {
                         // Only check the first item as all targets has the same setting for now.
                         IShowHideActionTarget target = showAction.TargetObjects[0];
                         if (target != null && target.VisibilityType != VisibilityType.None)
                         {
                             builder.Append("\"cursor\":\"pointer\",");
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            switch (_action.ActionType)
            {
            case ActionType.OpenAction:
            {
                IInteractionOpenAction openAction = _action as IInteractionOpenAction;
                if (openAction == null || openAction.LinkType == LinkType.None)
                {
                    return("");
                }

                builder.Append("{");
                builder.AppendFormat("\"action\":\"{0}\",", GetJsAction(_action.ActionType));

                if (openAction.LinkType == LinkType.LinkToPage)
                {
                    // http://bts1.navercorp.com/nhnbts/browse/DSTUDIO-2061
                    // If action is "Link to a page", I will always set "target" to  "openCurrentWindow" in js action.
                    builder.AppendFormat("\"target\":\"{0}\",", GetJsTarget(ActionOpenIn.CurrentWindow));

                    if (_service.RenderingDocument.Pages.Contains(openAction.LinkPageGuid))
                    {
                        builder.AppendFormat("\"url\":\"{0}\",", openAction.LinkPageGuid.ToString());
                    }
                }
                else if (openAction.LinkType == LinkType.LinkToUrl)
                {
                    builder.AppendFormat("\"target\":\"{0}\",", GetJsTarget(openAction.OpenIn));

                    if (!String.IsNullOrEmpty(openAction.ExternalUrl))
                    {
                        // Add http so that browser could know this is a external url
                        string url = openAction.ExternalUrl;
                        if (!url.StartsWith(@"http://"))
                        {
                            url = @"http://" + url;
                        }
                        builder.AppendFormat("\"url\":\"{0}\",", url);
                    }
                }

                JsHelper.RemoveLastComma(builder);
                builder.Append("}");
                break;
            }

            case ActionType.ShowHideAction:
            {
                IInteractionShowHideAction showHideAction = _action as IInteractionShowHideAction;
                if (showHideAction == null || showHideAction.TargetObjects.Count <= 0)
                {
                    return("");
                }

                // If all target objects VisibilityType is none, we don't issue action as well
                IShowHideActionTarget firstTarget = showHideAction.TargetObjects.FirstOrDefault <IShowHideActionTarget>(x => x.VisibilityType != VisibilityType.None);
                if (firstTarget == null)
                {
                    return("");
                }

                builder.Append("{");

                builder.AppendFormat("\"action\":\"{0}\",", GetJsAction(_action.ActionType));

                builder.Append("\"objectList\":[");
                foreach (IShowHideActionTarget target in showHideAction.TargetObjects)
                {
                    builder.Append("{");

                    builder.AppendFormat("\"id\":\"{0}\",", target.Guid.ToString());
                    builder.AppendFormat("\"type\":\"{0}\",", target.VisibilityType.ToString());
                    builder.AppendFormat("\"animateType\":\"{0}\",", target.AnimateType.ToString());
                    builder.AppendFormat("\"animateTime\":{0},", target.AnimateTime);

                    builder.Append("},");
                }

                JsHelper.RemoveLastComma(builder);
                builder.Append("]");

                builder.Append("}");
                break;
            }

            default:
                return("");
            }

            return(builder.ToString());
        }