yui3/commit

Developments within amalgame * extend yui3 write support * setting for local use

authorMichiel Hildebrand
Fri Mar 25 13:14:19 2011 +0100
committerMichiel Hildebrand
Fri Mar 25 13:14:19 2011 +0100
commit5442df4579c97ab88b5c9f0f6e7071e875bb81a4
tree7f5cc5a3415cc3b790444027dcf0d78084681031
parentab5aab0950e43e09bfe68c8de97fe5a879e8e938
Diff style: patch stat
diff --git a/config-available/yui3.pl b/config-available/yui3.pl
index 4ae3e419d0..c5f38b4001 100644
--- a/config-available/yui3.pl
+++ b/config-available/yui3.pl
@@ -3,8 +3,12 @@
 /** <module> YAHOO User Interface library version 3
 */
 
+:- use_module(library(settings)).
 :- use_module(library(http/http_path)).
 
+:- setting(local, boolean, false,
+	   'When set to true the local version of YUI is used').
+
 :- multifile http:location/3.
 
 user:file_search_path(yui3js, web('yui/3.3.0')).
@@ -12,10 +16,15 @@ user:file_search_path(yui3js, web('yui/3.3.0')).
 http:location(yui3,	    yui3_base(build),	       [js(true)]).
 http:location(yui3_examples, yui3_base(examples),	       [js(true)]).
 
-:- if(absolute_file_name(yui3js(.), _, [ access(read),
+local_yui3 :-
+	setting(local, true),
+	absolute_file_name(yui3js(.), _, [ access(read),
 					 file_type(directory),
 					 file_errors(fail)
-				       ])).
+				       ]).
+
+:- if(local_yui3).
+
 http:location(yui3_base,    www('yui/3.3.0'),	       []).
 
 :- use_module(library(http/http_dispatch)).
@@ -28,6 +37,6 @@ serve_file(Request) :-
 
 :- else.
 
-http:location(yui3_base, 'http://yui.yahooapis.com/3.3.0/', []).
+http:location(yui3_base, 'http://yui.yahooapis.com/3.3.0PR3/', []).
 
 :- endif.
diff --git a/lib/yui3.pl b/lib/yui3.pl
index 8920412480..a1e04464a2 100644
--- a/lib/yui3.pl
+++ b/lib/yui3.pl
@@ -3,6 +3,9 @@
 	    js_yui3_event//5,
 	    js_yui3_on//3,
 	    js_yui3_delegate//5,
+	    js_yui3_plug//3,
+	    js_yui3_render//1,
+	    js_yui3_render//2,
 	    js_function//2,
 	    js_function_decl//3,
 	    js_yui3_decl//2
@@ -20,7 +23,28 @@
         js_function(+, :, -, +),
 	js_function_decl(+, +, :, -, +).
 
-/* additional javascript support */
+/* javascript support for YUI3 */
+
+%%	js_yui3(+Head, +Include, +Body)
+%
+%	Emit javascript YUI3 object.
+
+js_yui3(Head, Include, Body) -->
+	html_requires(yui3('yui/yui-min.js')),
+ 	html('YUI(\n'),
+	js_args(Head),
+	html(')\n.use('),
+	js_yui3_include(Include),
+	html('\n'),
+	js_function(['Y'], Body),
+	html(')').
+
+js_yui3_include([]) -->
+	!.
+js_yui3_include(List) -->
+	js_args(List),
+	html(', ').
+
 
 %%	js_yui3_event(+Id, +When, +EventType, +JSFunction, +Scope)
 %
@@ -46,25 +70,6 @@ js_yui3_delegate(Select, Context, Event, Fn, Args) -->
 	html(['Y.delegate', '("', Event, '",', Fn, ',', \js_args([Select]),', "',Context,'",', Args, ');\n']).
 
 
-%%	js_yui3(+Head, +Include, +Body)
-%
-%	Emit javascript YUI3 object.
-
-js_yui3(Head, Include, Body) -->
-	html_requires(yui3('yui/yui-min.js')),
- 	html(['YUI(',
-	      \js_args(Head),
-	      ').use(',
-	      \js_yui3_include(Include),
-	      \js_function(['Y'], Body),
-	      ');\n'
-	     ]).
-
-js_yui3_include([]) -->
-	!.
-js_yui3_include(List) -->
-	js_args(List),
-	html(', ').
 
 %%	js_function(+Args, +Body)
 %
@@ -72,7 +77,7 @@ js_yui3_include(List) -->
 
 js_function(Args, Body) -->
  	html(['function(', \js_vars(Args), ') {\n']),
-	html(Body),
+	html([Body,'\n']),
 	html('}').
 
 %%	js_function_decl(+Id, +Args, +Body)
@@ -102,5 +107,20 @@ js_yui3_decl(Name, Value) -->
 	js_args([Value]),
 	html(';\n').
 
+%%	js_yui3_plug(+Id, +Plugin, +Conf)
+%
+%	Emit javascript plugin.
+
+js_yui3_plug(Id, Plugin, Conf) -->
+	html([Id, '.plug(', Plugin, ',']),
+	js_args([Conf]),
+	html(');\n').
 
+%%	js_yui3_render(+Id, +El)
+%
+%	Emit javascript YUI3 render call.
 
+js_yui3_render(Id) -->
+	html([Id, '.render();\n']).
+js_yui3_render(Id, El) -->
+	html([Id, '.render(', \js_args([El]), ');\n']).