Example #1
0
 internal static void SetupWebView <TApi>(this WebView webView, out IBindableJSContextProvider jsCtx, Func <IBindableJSContextProvider, TApi> newJsApi, out TApi jsApi, out CommonAPI jsCommonApi)
 {
     webView.IsHistoryDisabled          = true;
     webView.AllowDeveloperTools        = true;
     webView.DisableBuiltinContextMenus = true;
     //webView.BeforeResourceLoad += WebViewExtensions.OnWebViewBeforeResourceLoad;
     webView.AddBeforeResourceLoadEvent(WebViewExtensions.OnWebViewBeforeResourceLoad);
     webView.DefaultScriptsExecutionTimeout = (HybridConfiguration.DisableWebViewExecutionTimeouts ? null : new TimeSpan?(WebViewExtensions.DefaultScriptExecutionTimeout));
     //webView.FindLogicalParent<IDisposable>().MustBeSet("The webview must belong to a IDisposable view and be disposed");
     if (HybridConfiguration.ShowDeveloperTools)
     {
         webView.ShowDeveloperTools();
     }
     jsCtx       = new DocumentReadyJSApi(webView);
     jsApi       = newJsApi(jsCtx);
     jsCommonApi = new CommonAPI(jsCtx);
 }
Example #2
0
        public static NotifyCollectionChangedEventHandler CreateOnCollectionChangedHandler(IBindableJSContextProvider jsCtx, ITrackableJSObject jsObj, string collectionPropName)
        {
            return(delegate(object sender, NotifyCollectionChangedEventArgs e)
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    jsCtx.NotifyElementAdded(jsObj, collectionPropName, e.NewStartingIndex, e.NewItems[0]);
                    return;

                case NotifyCollectionChangedAction.Remove:
                    jsCtx.NotifyElementRemoved(jsObj, collectionPropName, e.OldStartingIndex);
                    return;

                case NotifyCollectionChangedAction.Replace:
                    jsCtx.NotifyElementReplaced(jsObj, collectionPropName, e.OldStartingIndex, e.NewItems[0]);
                    return;

                case NotifyCollectionChangedAction.Move:
                    jsCtx.NotifyElementMoved(jsObj, collectionPropName, e.OldStartingIndex, e.NewStartingIndex);
                    return;

                case NotifyCollectionChangedAction.Reset:
                    jsCtx.NotifyPropertyChanged(jsObj, collectionPropName, new IJSObject[0]);
                    return;

                default:
                    throw new InvalidOperationException("Unexpected type of collection update");
                }
            });
        }
Example #3
0
 internal static void SetupWebView <TApi>(this WebView webView, string editorName, bool readOnly, bool oldApi, out IBindableJSContextProvider jsCtx, Func <IBindableJSContextProvider, TApi> newJsApi, out TApi jsApi, out CommonAPI jsCommonApi)
 {
     webView.SetupWebView(out jsCtx, newJsApi, out jsApi, out jsCommonApi);
     webView.LoadResource(new ResourceUrl(typeof(WebViewExtensions).Assembly, new string[]
     {
         "WebViews",
         "Common",
         string.Concat(new string[]
         {
             "FormIoWebView",
             oldApi ? "-old" : "",
             ".html?render=",
             editorName,
             "&readOnly=",
             readOnly ? "true" : "false"
         })
     }));
 }
Example #4
0
 internal static void SetupWebView <TApi>(this WebView webView, string editorName, bool readOnly, out IBindableJSContextProvider jsCtx, Func <IBindableJSContextProvider, TApi> newJsApi, out TApi jsApi, out CommonAPI jsCommonApi) where TApi : class
 {
     webView.SetupWebView(editorName, readOnly, false, out jsCtx, newJsApi, out jsApi, out jsCommonApi);
 }