Exemple #1
0
        static void OnReady()
        {
            var win  = new jQuery("#window");
            var undo = new jQuery("#undo");

            undo.bind("click", e =>
            {
                win.data("kendoWindow").As <Window>().open();
                undo.hide();
            });

            if (win.data("kendoWindow") == null)
            {
                win.kendoWindow(new WindowConfiguration
                {
                    width   = "500px",
                    actions = new JsArray {
                        "Custom", "Minimize", "Maximize", "Close"
                    },
                    title = "About Josef Hoffmann",
                    close = () => undo.show().As <Window>()
                });
            }
            win.data("kendoWindow").As <Window>().wrapper.find(".k-i-custom").click(e =>
            {
                HtmlContext.alert("Custom action button clicked");
                e.preventDefault();
            });
        }
        public TypeDefinition resolveClassName(JsString qualifiedClassName)
        {
            dynamic type = findDefinition(qualifiedClassName);

            if (type == null)
            {
                JsString classDefinition = loader.loadClass(qualifiedClassName);

                //Before we load it into memory, check on the super class and see if we need to load *that*
                //into memory. We may *NOT* have an inherit if we dont inherit from anything, that is just fine
                resolveParentClassFromDefinition(qualifiedClassName, classDefinition);

                //Load the newly found class memory
                addDefinition(classDefinition);

                //Get a reference to the newly added type
                type = findDefinition(qualifiedClassName);

                if (type == null)
                {
                    //This alert shouldnt be here, we should figure out a way to get it to the UI level
                    HtmlContext.alert(qualifiedClassName + " does not contain required injection information ");
                    throw new JsError(qualifiedClassName + " does not contain required injection information ");
                }

                var td = new TypeDefinition(type);
                if (!td.builtIn)
                {
                    //Finally, resolve any classes it references in its own code execution
                    resolveClassDependencies(td);
                }
            }

            return(new TypeDefinition(type));
        }
        private void makeAsynchronousRequest(JsString url, TranslationsFileLoaded fileLoaded)
        {
            XMLHttpRequest request = new XMLHttpRequest();

            if (forceReload)
            {
                //just bust the cache for now
                url = url + "?rnd=" + JsMath.random();
            }

            request.open("GET", url, true);
            request.onreadystatechange = delegate(DOMEvent evt) {
                if (request.readyState == 4 && request.status == 200)
                {
                    parseResult(request.responseText);
                    fileLoaded();
                }
                else if (request.readyState >= 3 && request.status == 404)
                {
                    HtmlContext.alert("Required Content " + url + " cannot be loaded.");
                    throw new JsError("Cannot continue, missing required property file " + url);
                }
            };

            request.send("");
        }
        public static void RunSample()
        {
            HtmlDocument doc = HtmlContext.document;

            doc.write("Hello World!");
            HtmlContext.alert("Welcome!");
        }
Exemple #5
0
 static void OnReady()
 {
     new jQuery("#rerun").button().click(e => HtmlContext.alert("Running the last action"))
     .next().button(new ButtonOptions {
         text = false, icons = new IconOptions {
             primary = "ui-icon-triangle-1-s"
         }
     })
     .click(e => HtmlContext.alert("Could display a menu to select an action")).parent().buttonset();
 }
Exemple #6
0
        public static void Main()
        {
            var list = new List <Contact>();

            list.Add(new Contact {
                Name = "Asdas"
            });
            foreach (var item in list)
            {
                HtmlContext.alert(item.Name);
            }
            list.First().CallMe();
            list.First().CallMe("Hello");
        }
Exemple #7
0
 public static void OnLoad()
 {
     jQuery.ajax(new AjaxSettings
     {
         url      = "Handler.ashx",
         dataType = "text",
         success  = (js, b, cc) =>
         {
             var func = new JsFunction(js.As <JsString>());
             var x    = func.call();
             var c    = x.As <Contact>();
             HtmlContext.alert(c.GetType().FullName + "," + c.Name);
         }
     });
 }
Exemple #8
0
        public void verifyAndRegister()
        {
            foreach (var id in viableInjectionPoints)
            {
                if (viableInjectionPoints[id].As <JsString>() == "req")
                {
                    dynamic instance       = this;
                    var     typeDefinition = new TypeDefinition(instance.constructor);

                    HtmlContext.alert(typeDefinition.getClassName() + " requires a [View] element with the id of " + id + " but it could not be found");
                    return;
                }
                JsContext.delete(viableInjectionPoints[id]);
            }

            this.viableInjectionPoints = null;
            onRegister();
        }
        public string loadClass(JsString qualifiedClassName)
        {
            JsRegExp classNameRegex = new JsRegExp("\\.", "g");
            var      potentialURL   = qualifiedClassName.replace(classNameRegex, "/");

            potentialURL  = dynamicClassBaseUrl + potentialURL;
            potentialURL += ".js";

            xmlHttpRequest.open("GET", potentialURL, false);
            xmlHttpRequest.send("");

            //Todo Need to handle other status than just 404
            if (xmlHttpRequest.status == 404)
            {
                //Todo This alert shouldnt be here, we should figure out a way to get it to the UI level
                HtmlContext.alert("Required Class " + qualifiedClassName + " cannot be loaded.");
                throw new JsError("Cannot continue, missing required class " + qualifiedClassName);
            }

            return(xmlHttpRequest.responseText + "\n//@ sourceURL=" + potentialURL);
        }
        private void makeSynchronousRequest(JsString url)
        {
            XMLHttpRequest request = new XMLHttpRequest();

            if (forceReload)
            {
                //just bust the cache for now
                url = url + "?rnd=" + JsMath.random();
            }

            request.open("GET", url, false);
            request.send("");

            if (request.status == 404)
            {
                HtmlContext.alert("Required Content " + url + " cannot be loaded.");
                throw new JsError("Cannot continue, missing required property file " + url);
            }

            parseResult(request.responseText);
        }
Exemple #11
0
 public void CallMe(string s)
 {
     HtmlContext.alert("CallMe2 " + s);
 }
Exemple #12
0
 public void CallMe()
 {
     HtmlContext.alert("CallMe1");
 }
Exemple #13
0
        static void Main()
        {
            var geo = HtmlContext.navigator.geolocation;

            geo.getCurrentPosition(pos => HtmlContext.alert(pos));
        }