Skip to content

Commit

Permalink
Full Journal View. Store last view.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Laské committed Dec 16, 2013
1 parent 3deb83d commit 7888d5c
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 18 deletions.
4 changes: 2 additions & 2 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "org.olpc-france.sugarweb"
version = "1.0.0">
<name>Sugar Web</name>
<name>Sugarizer</name>

<description>
A taste of the Sugar Learning platform in a small app.
A taste of the Sugar on any device.
</description>

<author href="http://olpc-france.org" email="[email protected]">
Expand Down
38 changes: 38 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,48 @@ input {

#main-toolbar #view-radial-button {
background-image: url(../icons/view-radial.svg);
position: absolute;
top: 0px;
right: 90px;
}

#main-toolbar #view-list-button {
background-image: url(../icons/view-list.svg);
position: absolute;
top: 0px;
right: 30px;
}

#main-toolbar #favorite-button {
background-image: url(../icons/emblem-favorite.svg);
position: absolute;
top: 0px;
left: 530px;
}

#main-toolbar #view-desktop-button {
background-image: url(../icons/view-radial.svg);
position: absolute;
top: 0px;
right: 30px;
}

#homeSearch {
width: 300px;
}

#journalSearch {
width: 450px;
}

#journalType {
margin-left: 70px;
width: 170px;
}

#journalTime {
margin-left: 10px;
width: 130px;
}

.web-activity {
Expand Down
26 changes: 19 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="utf-8" />
<title>Sugar WebUI</title>
<title>Sugarizer</title>

<!-- Sugar Framework -->
<link rel="stylesheet" href="lib/sugar-web/graphics/css/sugar.css">
Expand All @@ -27,15 +27,27 @@
</head>

<body>
<!-- Desktop toolbar -->
<!-- Toolbars -->
<div id="main-toolbar" class="toolbar">
<div class="row">
<input type="text" id="title">
<button class="toolbutton pull-right" id="view-list-button" title="List"></button>
<button class="toolbutton pull-right" id="view-radial-button" title="Home"></button>
<table width="100%">
<!-- Desktop toolbar -->
<tr id="desktopToolbar"><td>
<input type="text" id="homeSearch">
<button class="toolbutton" id="view-list-button" title="List"></button>
<button class="toolbutton" id="view-radial-button" title="Home"></button>
</td></tr>
<!-- Journal toolbar -->
<tr id="journalToolbar" style="display: none;"><td>
<input type="text" id="journalSearch">
<button class="toolbutton" id="favorite-button" title="Filter favorite"></button>
<button class="toolbutton" id="view-desktop-button" title="Home"></button>
<input type="text" id="journalType">
<input type="text" id="journalTime">

</td></tr>
</table>
</div>


</div>

<!-- The content of the desktop goes inside the canvas -->
Expand Down
1 change: 1 addition & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ define(function (require) {
);
document.getElementById("view-radial-button").onclick = function() { app.showView(constant.radialView); };
document.getElementById("view-list-button").onclick = function() { app.showView(constant.listView); };
document.getElementById("view-desktop-button").onclick = function() { app.showView(constant.radialView); };
app.renderInto(document.getElementById("canvas"));
});

Expand Down
25 changes: 17 additions & 8 deletions js/homeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,24 @@ enyo.kind({
create: function() {
// Init screen
this.inherited(arguments);
this.currentView = constant.radialView;
this.timer = null;
var that = this;
document.onmousemove = function(e) {
that.position = {x: e.pageX, y: e.pageY};
}

// Get activities from local storage or from init web service
if (preferences.getActivities() == null) {
this.$.activities.send();
} else {
this.init();
}

// Load and sort journal
this.journal = datastore.find();
this.journal = this.journal.sort(function(e0, e1) {
return parseInt(e1.metadata.timestamp) - parseInt(e0.metadata.timestamp);
});

// Get activities from local storage or from init web service
if (preferences.getActivities() == null) {
this.$.activities.send();
} else {
this.init();
}
},

// Init web service response, redraw screen
Expand All @@ -62,6 +61,9 @@ enyo.kind({

// Init desktop
init: function() {
this.currentView = constant.radialView;
if (preferences.getView())
this.showView(preferences.getView());
this.draw();
},

Expand Down Expand Up @@ -117,6 +119,7 @@ enyo.kind({

// Show desktop
if (newView == constant.radialView) {
util.setToolbarVisibility({desktopToolbar: true, journalToolbar: false});
this.$.otherview.hide();
this.$.desktop.show();
this.$.owner.show();
Expand All @@ -133,6 +136,7 @@ enyo.kind({

// Show list
if (newView == constant.listView) {
util.setToolbarVisibility({desktopToolbar: true, journalToolbar: false});
this.$.otherview.createComponent({kind: "Sugar.Desktop.ListView", count: preferences.getActivities().length});
}

Expand All @@ -142,13 +146,18 @@ enyo.kind({
this.$.activityPopup.hidePopup();
window.clearInterval(this.timer);
}
util.setToolbarVisibility({desktopToolbar: false, journalToolbar: true});
this.$.otherview.createComponent({kind: "Sugar.Journal", journal: this.journal});
}

this.$.otherview.show();
this.$.otherview.render();
},

getView: function() {
return this.currentView;
},

clearView: function() {
var controls = this.$.otherview.getControls();
for (var i = 0, c; c = controls[i]; i++) c.destroy();
Expand Down
1 change: 1 addition & 0 deletions js/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enyo.kind({
this.journal[inEvent.index].metadata.keep = (keep + 1) % 2;
var ds = new datastore.DatastoreObject(objectId);
ds.setMetadata(this.journal[inEvent.index].metadata);
ds.setDataAsText(this.journal[inEvent.index].text);
ds.save();
inSender.setColorized(this.journal[inEvent.index].metadata.keep == 1);
this.render();
Expand Down
13 changes: 12 additions & 1 deletion lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define(["sugar-web/datastore"], function (datastore) {
settings.color = 22;
settings.colorvalue = null;
settings.activities = null;
settings.view = 0;

// Load settings from local storage
settings.load = function() {
Expand All @@ -19,6 +20,7 @@ define(["sugar-web/datastore"], function (datastore) {
this.name = preferences.name;
this.color = preferences.color;
this.colorvalue = preferences.colorvalue;
this.view = preferences.view;

// Load activities
this.activities = preferences.activities;
Expand All @@ -38,7 +40,13 @@ define(["sugar-web/datastore"], function (datastore) {

// Save settings to local storage
settings.save = function() {
datastore.localStorage.setValue('sugar_settings', {name: this.name, color: this.color, colorvalue: xoPalette.colors[this.color], activities: this.activities});
datastore.localStorage.setValue('sugar_settings', {
name: this.name,
color: this.color,
colorvalue: xoPalette.colors[this.color],
activities: this.activities,
view: app.getView()
});
};

// Get properties
Expand All @@ -48,6 +56,9 @@ define(["sugar-web/datastore"], function (datastore) {
settings.getColor = function() {
return xoPalette.colors[this.color];
};
settings.getView = function() {
return this.view;
};
settings.getActivities = function() {
return this.activities;
};
Expand Down
11 changes: 11 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,16 @@ define(function () {
return { x: canvas_centerx, y: canvas_centery };
}

// Show/Hide toolbar
util.setToolbarVisibility = function(values) {
for(var key in values) {
var elem = document.getElementById(key);
if (values[key])
elem.style.display = "inline";
else
elem.style.display = "none";
}
}

return util;
});

0 comments on commit 7888d5c

Please sign in to comment.