mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 06:46:03 +00:00
support completing items
This commit is contained in:
parent
fa52cea8c3
commit
44ab6d33ed
@ -49,10 +49,30 @@ body {
|
|||||||
height:100%; /* text area height */
|
height:100%; /* text area height */
|
||||||
width:100%; /* text area width */
|
width:100%; /* text area width */
|
||||||
padding:34px 10px 10px 10px;
|
padding:34px 10px 10px 10px;
|
||||||
text-align:center;
|
text-align:left;
|
||||||
margin:0px;
|
margin:0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.todoContainer {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todoContainer:after {
|
||||||
|
content: "";
|
||||||
|
display: table;
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todoItem {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deleteButton {
|
||||||
|
float:right;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Landscape layout (with min-width) */
|
/* Landscape layout (with min-width) */
|
||||||
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
|
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
|
||||||
.app {
|
.app {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
|
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
|
||||||
* Enable inline JS: add 'unsafe-inline' to default-src
|
* Enable inline JS: add 'unsafe-inline' to default-src
|
||||||
-->
|
-->
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
|
||||||
<meta name="format-detection" content="telephone=no">
|
<meta name="format-detection" content="telephone=no">
|
||||||
<meta name="msapplication-tap-highlight" content="no">
|
<meta name="msapplication-tap-highlight" content="no">
|
||||||
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
||||||
|
10
examples/cordova/platforms/ios/www/js/index.js
vendored
10
examples/cordova/platforms/ios/www/js/index.js
vendored
@ -29,11 +29,19 @@ function realm() {
|
|||||||
return new Realm({schema: [Todo]});
|
return new Realm({schema: [Todo]});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteTodo(index) {
|
||||||
|
realm().write(function() {
|
||||||
|
realm().delete(realm().objects("Todo")[index]);
|
||||||
|
});
|
||||||
|
updateItems();
|
||||||
|
}
|
||||||
|
|
||||||
function updateItems() {
|
function updateItems() {
|
||||||
var itemsHTML = "";
|
var itemsHTML = "";
|
||||||
var todos = realm().objects("Todo");
|
var todos = realm().objects("Todo");
|
||||||
for (var todo in todos) {
|
for (var todo in todos) {
|
||||||
itemsHTML += "<div>" + todos[todo].text + "</div>";
|
itemsHTML += "<div class='todoContainer'><div class='todoItem'>" + todos[todo].text +
|
||||||
|
"</div><button class='deleteButton' onclick='deleteTodo(" + todo + ");'>complete</button></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
var items = document.getElementById('items');
|
var items = document.getElementById('items');
|
||||||
|
@ -49,10 +49,30 @@ body {
|
|||||||
height:100%; /* text area height */
|
height:100%; /* text area height */
|
||||||
width:100%; /* text area width */
|
width:100%; /* text area width */
|
||||||
padding:34px 10px 10px 10px;
|
padding:34px 10px 10px 10px;
|
||||||
text-align:center;
|
text-align:left;
|
||||||
margin:0px;
|
margin:0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.todoContainer {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todoContainer:after {
|
||||||
|
content: "";
|
||||||
|
display: table;
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.todoItem {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deleteButton {
|
||||||
|
float:right;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Landscape layout (with min-width) */
|
/* Landscape layout (with min-width) */
|
||||||
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
|
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
|
||||||
.app {
|
.app {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
|
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
|
||||||
* Enable inline JS: add 'unsafe-inline' to default-src
|
* Enable inline JS: add 'unsafe-inline' to default-src
|
||||||
-->
|
-->
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
|
||||||
<meta name="format-detection" content="telephone=no">
|
<meta name="format-detection" content="telephone=no">
|
||||||
<meta name="msapplication-tap-highlight" content="no">
|
<meta name="msapplication-tap-highlight" content="no">
|
||||||
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
||||||
|
10
examples/cordova/www/js/index.js
vendored
10
examples/cordova/www/js/index.js
vendored
@ -29,11 +29,19 @@ function realm() {
|
|||||||
return new Realm({schema: [Todo]});
|
return new Realm({schema: [Todo]});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteTodo(index) {
|
||||||
|
realm().write(function() {
|
||||||
|
realm().delete(realm().objects("Todo")[index]);
|
||||||
|
});
|
||||||
|
updateItems();
|
||||||
|
}
|
||||||
|
|
||||||
function updateItems() {
|
function updateItems() {
|
||||||
var itemsHTML = "";
|
var itemsHTML = "";
|
||||||
var todos = realm().objects("Todo");
|
var todos = realm().objects("Todo");
|
||||||
for (var todo in todos) {
|
for (var todo in todos) {
|
||||||
itemsHTML += "<div>" + todos[todo].text + "</div>";
|
itemsHTML += "<div class='todoContainer'><div class='todoItem'>" + todos[todo].text +
|
||||||
|
"</div><button class='deleteButton' onclick='deleteTodo(" + todo + ");'>complete</button></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
var items = document.getElementById('items');
|
var items = document.getElementById('items');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user