From 97957b7bc3c4ec7df8080b90b58a0e38067a71a9 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 13 Nov 2017 18:05:14 -0500 Subject: [PATCH] fix #807: merging was supported after all --- src/cloud-ui.html | 2 +- src/css/cloud-ui.css | 46 ++++++++++++++++++++++++++++---------------- src/js/cloud-ui.js | 10 ++++++++++ src/js/user-rules.js | 4 +--- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/cloud-ui.html b/src/cloud-ui.html index 9f2de2b..3053d7a 100644 --- a/src/cloud-ui.html +++ b/src/cloud-ui.html @@ -8,7 +8,7 @@ - +

diff --git a/src/css/cloud-ui.css b/src/css/cloud-ui.css index b96ad88..609b3cd 100644 --- a/src/css/cloud-ui.css +++ b/src/css/cloud-ui.css @@ -2,39 +2,45 @@ background: url("../img/cloud.png") hsl(216, 100%, 93%); border-radius: 3px; margin: 0.5em 0; - padding: 1em; + padding: 1em 1em 0 1em; position: relative; } #cloudWidget.hide { display: none; } #cloudWidget > button { - font-size: 160%; - padding: 0.1em 0.2em; - } -#cloudPull[disabled] { - visibility: hidden; - } -#cloudPush:after , -#cloudPull:before { + display: inline-block; font-family: FontAwesome; + font-size: 160%; font-style: normal; font-weight: normal; line-height: 1; + padding: 0.2em 0.25em 0.1em 0.25em; + position: relative; vertical-align: baseline; - display: inline-block; } -body[dir="ltr"] #cloudPush:after { - content: '\f0ee'; +#cloudWidget > button[disabled] { + visibility: hidden; } -body[dir="rtl"] #cloudPush:after { +#cloudWidget > button.error { + color: red; + } +#cloudPush:after { content: '\f0ee'; } -body[dir="ltr"] #cloudPull:before { +#cloudPull:before, +#cloudPullAndMerge:before { content: '\f0ed'; +} +#cloudPullAndMerge { + margin: 0 0.25em; } -body[dir="rtl"] #cloudPull:before { - content: '\f0ed'; +#cloudPullAndMerge:after { + content: '\f067'; + font-size: 50%; + position: absolute; + right: 0; + top: 10%; } #cloudWidget > span { color: gray; @@ -45,7 +51,13 @@ body[dir="rtl"] #cloudPull:before { vertical-align: bottom; white-space: pre; } -#cloudWidget > .nodata { +#cloudError { + color: red; + margin: 0; + padding: 0.5em 0; + } +#cloudError > span { + font-size: x-small; } #cloudWidget > #cloudCog { cursor: pointer; diff --git a/src/js/cloud-ui.js b/src/js/cloud-ui.js index c4cc118..07030af 100644 --- a/src/js/cloud-ui.js +++ b/src/js/cloud-ui.js @@ -62,6 +62,7 @@ var onCloudDataReceived = function(entry) { self.cloud.data = entry.data; uDom.nodeFromId('cloudPull').removeAttribute('disabled'); + uDom.nodeFromId('cloudPullAndMerge').removeAttribute('disabled'); var timeOptions = { weekday: 'short', @@ -118,6 +119,14 @@ var pullData = function(ev) { /******************************************************************************/ +var pullAndMergeData = function() { + if ( typeof self.cloud.onPull === 'function' ) { + self.cloud.onPull(self.cloud.data, true); + } +}; + +/******************************************************************************/ + var openOptions = function() { var input = uDom.nodeFromId('cloudDeviceName'); input.value = self.cloud.options.deviceName; @@ -188,6 +197,7 @@ var onInitialize = function(options) { uDom('#cloudPush').on('click', pushData); uDom('#cloudPull').on('click', pullData); + uDom('#cloudPullAndMerge').on('click', pullAndMergeData); uDom('#cloudCog').on('click', openOptions); uDom('#cloudOptions').on('click', closeOptions); uDom('#cloudOptionsSubmit').on('click', submitOptions); diff --git a/src/js/user-rules.js b/src/js/user-rules.js index 8963e7b..73dfb56 100644 --- a/src/js/user-rules.js +++ b/src/js/user-rules.js @@ -307,9 +307,7 @@ self.cloud.onPush = function() { }; self.cloud.onPull = function(data, append) { - if ( typeof data !== 'string' ) { - return; - } + if ( typeof data !== 'string' ) { return; } if ( append ) { data = rulesFromHTML('#diff .right li') + '\n' + data; }