Browse files

Fixing up cloudfilepicker

  • Loading branch information...
1 parent e0cc12d commit e140a400a93f5efcf069c434f9096f2ab955fb0c Paul Kinlan committed Aug 10, 2012
Showing with 72 additions and 16 deletions.
  1. +72 −16 server/demos/cloudfilepicker/pages/index.html
View
88 server/demos/cloudfilepicker/pages/index.html
@@ -2,7 +2,8 @@
{% block title %}Cloud File Picker{% endblock %}
{% block headline %}Cloud File Picker{% endblock %}
{% block scripts %}
- <script src="//webintents.org/webintents.js"></script>
+ <script src="//webintents.org/webintents.min.js"></script>
+ <script src="//webintents.org/webintents-prefix.js"></script>
<script src="/javascripts/events.js"></script>
<script src="/scripts/proxy.js"></script>
<script src="/scripts/save.js"></script>
@@ -56,6 +57,9 @@
pickerBuilder.setAppId(clientId);
pickerBuilder.setCallback(pickerCallback);
pickerBuilder.build().setVisible(true);
+
+ var shareLinkElement = document.getElementById("shareLink");
+ shareLinkElement.addEventListener("click", shareLink, false);
}
function returnImage (e) {
@@ -68,28 +72,80 @@
}
}
- function pickerCallback(data) {
- if (data.action == google.picker.Action.PICKED) {
- returnImage(data.docs[0].thumbnails[data.docs[0].thumbnails.length - 1].url);
+ var saveFile = function() {
+ if(selectedData) {
+ var intent = new Intent({"action": "http://webintents.org/save", "type": "text/uri-list", "data": selectedData.url });
+ window.navigator.startActivity(intent, function() {}, function(){});
+ }
+ };
+
+ var shareFile = function() {
+ if(selectedData) {
+ var intent = new Intent({"action": "http://webintents.org/share", "type": selectedData.mimeType, "data": selectedData.url });
+ window.navigator.startActivity(intent, function() {}, function(){});
}
- else if(data.action == google.picker.Action.CANCEL) {
- // Tell the calling app the user cancelled.
- window.intent.postFailure({});
+ };
+
+ var shareLink = function() {
+ if(selectedData) {
+ var intent = new Intent({"action": "http://webintents.org/share", "type": "text/uri-list", "data": selectedData.url});
+ window.navigator.startActivity(intent, function() {}, function(){});
+ }
+ };
+
+ var selectedData;
+
+ function pickerCallback(data) {
+ var fileData = data.docs[0].thumbnails[data.docs[0].thumbnails.length - 1];
+ selectedData = fileData;
+ if(window.webkitIntent) {
+ if (data.action == google.picker.Action.PICKED) {
+ returnImage(fileData.url);
+ }
+ else if(data.action == google.picker.Action.CANCEL) {
+ // Tell the calling app the user cancelled.
+ window.intent.postFailure({});
+ }
}
}
</script>
{% endblock %}
{% block content %}
+ <style>
+ button {
+ background-color: #D14836;
+ background-image: -webkit-linear-gradient(top,#DD4B39,#D14836);
+ color: white;
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+ cursor: default;
+ font-size: 11px;
+ font-weight: bold;
+ text-align: center;
+ margin-right: 16px;
+ height: 27px;
+ line-height: 27px;
+ min-width: 54px;
+ outline: 0;
+ padding: 0 8px;
+ cursor: pointer;
+ font-family: arial,sans-serif;
+ border: 1px solid transparent;
+ }
+
+ button:hover {
+ border: 1px solid #B0281A;
+ }
+ </style>
<div id="contents">
- <h2>Welcome</h2>
- <p>
- This Cloud File Picker app gives you access to your files held in your Google account for
- use in your favourite applications.
- </p>
- <p>
- Apps won't be able to access your information without your consent, so you are in
- control of how applications can access your data.
- </p>
+ <h2>Now do something with your file</h2>
+
+ <div id="actions">
+ <button id="shareLink">Share Link to file</button>
+ <!--<button id="shareFile">Share File</button>
+ <button id="saveFile">Save File</button> -->
+ </div>
</div>
<a href="http://www.colourlovers.com/lover/sugar%21/loveNote" id="credits">Background by sugar!</a>

0 comments on commit e140a40

Please sign in to comment.