From 01a1780abc65db235dbef39f8dd0cd44d400aebe Mon Sep 17 00:00:00 2001 From: Chelsea Voss Date: Sat, 5 Nov 2016 16:57:12 -0400 Subject: Create browser history FFI module; make x button in new actions go back --- Makefile | 4 ++++ history/history.ur | 16 +++++++++++++++ history/history.urs | 14 +++++++++++++ history/historyFfi.js | 27 +++++++++++++++++++++++++ history/historyFfi.urs | 14 +++++++++++++ history/lib.urp | 6 ++++++ main.ur | 53 +++++++++++++++++++++++++++++--------------------- main.urs | 3 +++ mdl/mdlFfi.js | 15 ++++++++++---- ugtd.urp | 2 ++ 10 files changed, 128 insertions(+), 26 deletions(-) create mode 100644 history/history.ur create mode 100644 history/history.urs create mode 100644 history/historyFfi.js create mode 100644 history/historyFfi.urs create mode 100644 history/lib.urp diff --git a/Makefile b/Makefile index 1546b36..4f76d2b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ # Copyright 2016 Benjamin Barenblat +# Copyright 2016 Chelsea Voss # # Licensed under the Apache License, Version 2.0 (the “License”); you may not # use this file except in compliance with the License. You may obtain a copy of @@ -20,6 +21,9 @@ all: ugtd ugtd.db ugtd initialize.sql: \ ugtd.urp \ ugtd.css \ + history/lib.urp \ + history/historyFfi.urs history/historyFfi.js \ + history/history.urs history/history.ur \ mdl/lib.urp \ mdl/mdlFfi.urs mdl/mdlFfi.js \ mdl/mdlClasses.urp \ diff --git a/history/history.ur b/history/history.ur new file mode 100644 index 0000000..227049a --- /dev/null +++ b/history/history.ur @@ -0,0 +1,16 @@ +(* Copyright 2016 Chelsea Voss + +Licensed under the Apache License, Version 2.0 (the “License”); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. *) + +structure Ffi = HistoryFfi + +val browserBack = Ffi.browserBack () diff --git a/history/history.urs b/history/history.urs new file mode 100644 index 0000000..2dae3cc --- /dev/null +++ b/history/history.urs @@ -0,0 +1,14 @@ +(* Copyright 2016 Chelsea Voss + +Licensed under the Apache License, Version 2.0 (the “License”); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. *) + +val browserBack : transaction unit diff --git a/history/historyFfi.js b/history/historyFfi.js new file mode 100644 index 0000000..aaef87a --- /dev/null +++ b/history/historyFfi.js @@ -0,0 +1,27 @@ +// Copyright 2016 Chelsea Voss +// +// Licensed under the Apache License, Version 2.0 (the “License”); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +"use strict"; + +(function() { + var history = { + browserBack: function() { window.history.back(); } + }; + + try { + UrWeb.History = history; + } catch (ReferenceError) { + window.UrWeb = {History: history}; + } +})(); diff --git a/history/historyFfi.urs b/history/historyFfi.urs new file mode 100644 index 0000000..d62353c --- /dev/null +++ b/history/historyFfi.urs @@ -0,0 +1,14 @@ +(* Copyright 2016 Chelsea Voss + +Licensed under the Apache License, Version 2.0 (the “License”); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. *) + +val browserBack : unit -> transaction unit diff --git a/history/lib.urp b/history/lib.urp new file mode 100644 index 0000000..cbc4e5e --- /dev/null +++ b/history/lib.urp @@ -0,0 +1,6 @@ +ffi historyFfi +jsFunc HistoryFfi.browserBack=UrWeb.History.browserBack +file /xAjDQlqm.js historyFfi.js +script /xAjDQlqm.js + +history diff --git a/main.ur b/main.ur index b9b5699..0620419 100644 --- a/main.ur +++ b/main.ur @@ -1,5 +1,6 @@ (* Copyright 2015 Google Inc. Copyright 2016 Benjamin Barenblat +Copyright 2016 Chelsea Voss Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the @@ -63,10 +64,38 @@ style visible datatype mode = NextActions | NewNextAction +val newActionsDiv actionItems = + newNextActionDescription <- Mdl.Textbox.make "Description"; + return +
+
+ +
+ New action +
+
+
+
+ {newNextActionDescription.Xml} +
+
+
+ +val new = return Hello, world! + val main = actionItems <- bind renderNextActions source; mode <- source NextActions; - newNextActionDescription <- Mdl.Textbox.make "Description"; + newActionsDivValue <- newActionsDiv actionItems; return (* TODO(bbaren): Write a meta-description tag. *) @@ -96,27 +125,7 @@ val main = NewNextAction => visible | _ => hidden) }> -
-
- -
- New action -
-
-
-
- {newNextActionDescription.Xml} -
-
+ {newActionsDivValue}