protected override string RenderInput(Kooboo.CMS.Form.IColumn column) { var sb = new StringBuilder(); var input = string.Format("<input id=\"{0}\" name=\"{0}\"{3} type=\"{1}\" value=\"@(Model.{0} ==null ? \"\" : Model.{0}.ToLocalTime().ToString())\" {2}/>", column.Name, this.Type, ValidationExtensions.GetUnobtrusiveValidationAttributeString(column), column.AllowNull ? "" : " readonly=\"readonly\""); sb.Append(@"@if ((bool?)ViewContext.Controller.ViewData[""WebResourceUrl.Rendered""] != true) { ViewContext.Controller.ViewData[""WebResourceUrl.Rendered""] = true;"); const string script = @" <script src=""@Kooboo.CMS.Toolkit.Controls.ControlsScript.GetWebResourceUrl()"" type=""text/javascript"" ></script>"; const string css = @" <link href=""@Kooboo.CMS.Toolkit.Controls.ControlsScript.GetDatetimeResourceUrl()"" type=""text/css"" rel=""stylesheet"" />"; sb.Append(css); sb.Append(script); sb.Append("\t\t\t}"); var func = String.Format(@" <script type='text/javascript'> $(function() {{ $('input[name=""{0}""]').datetimepicker({{ showSecond: true, timeFormat: 'HH:mm:ss' }}); }}); </script>", column.Name); sb.Append(func); sb.Append(input); return(sb.ToString()); }
protected override string RenderInput(Kooboo.CMS.Form.IColumn column) { var sb = new StringBuilder(); sb.AppendFormat("<div id='{0}_Container' class='mediafile'>", column.Name); var input = @"<input id=""{0}"" name=""{0}"" type=""{1}"" value=""@(Model.{0} ?? """")"" data-bind=""value: fieldValue""/>"; const string script = "<script src=\"@Kooboo.CMS.Toolkit.Controls.ControlsScript.GetWebResourceUrl()\" type=\"text/javascript\" ></script>"; string options = @"{ allowMultipleFiles: " + AllowMultipleFiles.ToString().ToLower() + @", validation: " + Validation + @", validationErrorMessage: '" + ValidationErrorMessage + @"', value: '@(Model." + column.Name + @")' }"; var ul = @" <ul class=""clearfix"" data-bind=""foreach: data""> <!-- ko if: isImage --> <li class=""img""> <span class=""preview""></span> <a class=""action"" data-bind=""click: $parent.removeItem"">@Html.IconImage(""minus small"")</a> <img data-bind=""attr:{src:Url}"" height=""100"" width=""100""> </li> <!-- /ko --> <!-- ko ifnot: isImage --> <li> <span class=""left"" data-bind=""{text:FileName}""></span> <a class=""action right"" data-bind=""click: $parent.removeItem"">@Html.IconImage(""minus small"")</a> </li> <!-- /ko --> </ul>"; var mediaLibraryUrl = String.Format(@"@Url.Action(""Selection"", ViewContext.RequestContext.AllRouteValues().Merge(""Area"", ""Contents"").Merge(""Controller"", ""MediaContent"").Merge(""FolderName"", null){0})""", AllowMultipleFiles ? "" : @".Merge(""SingleChoice"", ""true"")"); var func = String.Format(@" {0} <a id='addMedia_{1}' columnName='{1}' href='{2}' class='action add'>@Html.IconImage(""plus small"")</a> <script type='text/javascript'> $('#{1}_Container').mediaControl({3}); </script> ", script, column.Name, mediaLibraryUrl, options); sb.AppendFormat(input, column.Name, Type, ValidationExtensions.GetUnobtrusiveValidationAttributeString(column)); sb.Append(ul); sb.Append(func); sb.Append("</div>"); return(sb.ToString()); }