diff options
author | Chelsea Voss <csvoss@mit.edu> | 2016-11-05 16:57:12 -0400 |
---|---|---|
committer | Chelsea Voss <csvoss@mit.edu> | 2016-11-05 17:00:25 -0400 |
commit | 01a1780abc65db235dbef39f8dd0cd44d400aebe (patch) | |
tree | 8b03e02b7fa1d75114ccffd1455bddd356f314a7 | |
parent | 9e4a75fe23afd82dd4556c73be654366f47bad00 (diff) |
Create browser history FFI module; make x button in new actions go back
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | history/history.ur | 16 | ||||
-rw-r--r-- | history/history.urs | 14 | ||||
-rw-r--r-- | history/historyFfi.js | 27 | ||||
-rw-r--r-- | history/historyFfi.urs | 14 | ||||
-rw-r--r-- | history/lib.urp | 6 | ||||
-rw-r--r-- | main.ur | 53 | ||||
-rw-r--r-- | main.urs | 3 | ||||
-rw-r--r-- | mdl/mdlFfi.js | 15 | ||||
-rw-r--r-- | ugtd.urp | 2 |
10 files changed, 128 insertions, 26 deletions
@@ -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 @@ -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 <xml> + <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header"> + <header class="mdl-layout__header"> + <button class="mdl-layout__drawer-button" onclick={fn _ => History.browserBack}> + <i class="material-icons">close</i> + </button> + <div class="mdl-layout__header-row"> + <span class="mdl-layout-title">New action</span> + <div class="mdl-layout-spacer" /> + <button class="mdl-button mdl-js-button" value="Save" onclick={fn _ => + name <- get newNextActionDescription.Source; + bind (rpc (newNextAction name)) (set actionItems); + sleep 0; + (* TODO(csvoss): Put the right back action here. *) + set newNextActionDescription.Source "" + } /> + </div> + </header> + <div class="mdl-layout__content"> + {newNextActionDescription.Xml} + </div> + </div> + </xml> + +val new = return <xml><head></head><body>Hello, world!</body></xml> + val main = actionItems <- bind renderNextActions source; mode <- source NextActions; - newNextActionDescription <- Mdl.Textbox.make "Description"; + newActionsDivValue <- newActionsDiv actionItems; return <xml> <head> (* TODO(bbaren): Write a meta-description tag. *) @@ -96,27 +125,7 @@ val main = NewNextAction => visible | _ => hidden) }> - <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header"> - <header class="mdl-layout__header"> - <button class="mdl-layout__drawer-button" onclick={fn _ => set mode NextActions}> - <i class="material-icons">close</i> - </button> - <div class="mdl-layout__header-row"> - <span class="mdl-layout-title">New action</span> - <div class="mdl-layout-spacer" /> - <button class="mdl-button mdl-js-button" value="Save" onclick={fn _ => - name <- get newNextActionDescription.Source; - bind (rpc (newNextAction name)) (set actionItems); - sleep 0; - set mode NextActions; - set newNextActionDescription.Source "" - } /> - </div> - </header> - <div class="mdl-layout__content"> - {newNextActionDescription.Xml} - </div> - </div> + {newActionsDivValue} </div> <div dynClass={ currentMode <- signal mode; @@ -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 the @@ -12,3 +13,5 @@ CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) val main : transaction page + +val new : transaction page diff --git a/mdl/mdlFfi.js b/mdl/mdlFfi.js index f961cab..97c4166 100644 --- a/mdl/mdlFfi.js +++ b/mdl/mdlFfi.js @@ -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 @@ -15,14 +16,20 @@ "use strict"; -var UrWeb = { - MdlFfi: { - +(function() { + var mdlFfi = { showSnackbar: function(id, text) { document.querySelector('#' + id) .MaterialSnackbar.showSnackbar({message: text}); }, + }; + try { + UrWeb.MdlFfi = mdlFfi; + } catch (ReferenceError) { + console.log("asdf"); + window.UrWeb = {MdlFfi: mdlFfi}; + console.log("hjkl"); } -}; // UrWeb.MdlFfi +})(); // UrWeb.MdlFfi @@ -7,9 +7,11 @@ allow url https://code.getmdl.io/* database dbname=ugtd.db dbms sqlite file /ugtd.css ugtd.css +library history library mdl script https://storage.googleapis.com/code.getmdl.io/1.1.3/material.min.js sql initialize.sql rewrite url Main/main +rewrite url Main/new new main |