Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[feature] stdlib, plugins: Meteor Spark binding

  • Loading branch information...
commit 525caf464fed3b4f965bfcf1c9bb2c7d2726174a 1 parent 12e2167
Cédric Soulas cedricss authored
13 doc/copyright/copyright
View
@@ -80,5 +80,18 @@ This package also includes pieces of the following software:
- Font Awesome, http://fortawesome.github.com/Font-Awesome
+- Meteor Spark, MIT License
+ Copyright (C) 2011-2012 Meteor Development Group
+ https://github.com/meteor/meteor/wiki/Spark
+
+- Alea, MIT License
+ Copyright (C) 2010 Johannes Baagøe <baagoe@baagoe.org>
+ http://baagoe.org/en/wiki/Better_random_numbers_for_javascrip
+
+- Underscore.js 1.3.3, MIT License
+ Copyright (C) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
+ Portions of Underscore are inspired or borrowed from Prototype, Oliver Steele's Functional, and John Resig's Micro-Templating.
+ For all details and documentation: http://documentcloud.github.com/underscor
+
Detailed copyright information of all these included packages lie in
file <other_licenses>.
1  lib/plugins/_tags
View
@@ -12,3 +12,4 @@
<unix>: traverse
<bootstrap-*>: traverse
+<meteor-*>: traverse
34 lib/plugins/meteor-spark/context.js
View
@@ -0,0 +1,34 @@
+/** @externType Context.t */
+
+/**
+ * @register { -> Context.t }
+ */
+function get() {
+ return Meteor.deps.Context.current;
+}
+
+/**
+ * @register { Context.t -> int }
+ */
+function getId(context) {
+ return context.id
+}
+
+/**
+ * @register { Context.t, (-> void) -> void }
+ */
+function onInvalidate(context, callback) {
+ context.onInvalidate(callback);
+}
+
+/**
+ * @register { Context.t -> void }
+ */
+function invalidate(context) {
+ context.invalidate();
+}
+
+/**
+ * @register { Context.t }
+ */
+ var empty = null
4,765 lib/plugins/meteor-spark/meteor-spark.js
View
4,765 additions, 0 deletions not shown
3  lib/plugins/meteor-spark/meteor-spark.opa_plugin
View
@@ -0,0 +1,3 @@
+meteor-spark.js
+spark.js
+context.js
38 lib/plugins/meteor-spark/spark.js
View
@@ -0,0 +1,38 @@
+/** @externType dom_element */
+/** @externType xhtml */
+/** @opaType Cursor.t('a) */
+
+/**
+ * @register { ( -> string ) -> dom_element }
+ */
+function render(htmlFunc) {
+ return Spark.render(htmlFunc);
+}
+
+/**
+ * @register { ( -> string ) -> string }
+ */
+function isolate(htmlFunc) {
+ return Spark.isolate(htmlFunc);
+}
+
+/**
+ * @register { string, ( -> string) -> string }
+ */
+function labelBranch(id, htmlFunc) {
+ return Spark.labelBranch(id, htmlFunc);
+}
+
+/**
+ * @register { Cursor.t('a), ('a -> string), ( -> string) -> string }
+ */
+function list(cursor, itemFunc, elseFunc) {
+ return Spark.list(cursor, itemFunc, elseFunc);
+}
+
+/**
+ * @register {dom_element, (->dom_element) -> dom_element}
+ */
+function replace_f(to, f) {
+ return to.replaceWith(f);
+}
29 lib/stdlib/meteor/spark/spark.opa
View
@@ -0,0 +1,29 @@
+import-plugin meteor-spark
+
+type Context.t = external
+
+client module Spark {
+
+ render = %% Spark.render %%
+ function render_f(htmlFunc) {
+ function f() { render(htmlFunc) }
+ f
+ }
+ isolate = %% Spark.isolate %%
+ labelBranch = %% Spark.labelBranch %%
+ list = %% Spark.list %%
+ function replace_f(position, item_f){
+ Dom.to_selection(
+ %% Spark.replace_f %%(Dom.of_selection(position), { function() item_f() } )
+ )
+ }
+}
+
+client module Context {
+
+ getId = %% Context.getId %%
+ get = %% Context.get %%
+ onInvalidate = %% Context.onInvalidate %%
+ invalidate = %% Context.invalidate %%
+ empty = %% Context.empty %%
+}
Please sign in to comment.
Something went wrong with that request. Please try again.