Skip to content
Browse files

added multi detail for printing/emailing more than

one resource.
  • Loading branch information...
1 parent fd286c3 commit a6aa460b45ee705f43beed069d066278aa2864c8 @d0ugal d0ugal committed Apr 17, 2012
Showing with 100 additions and 23 deletions.
  1. +5 −0 css/style.css
  2. +33 −9 index.html
  3. +62 −14 js/gapp.js
View
5 css/style.css
@@ -87,4 +87,9 @@ h1{
.select_all{
text-align: left;
+}
+
+hr {
+ background:#ccc;
+ color:#ccc;
}
View
42 index.html
@@ -255,18 +255,42 @@ <h3 class="span-5 last">Saved searches</h3>
<script type="text/template" id="resource-template">
- <a href="#" class="back">Back to results</a>
+ <p class="pagination span-18 last">
+ <a href="#" class="back">Back to results</a>
+ </p>
- <hr/>
+ <% if (resources.length > 1){ %>
- <% var desc = description; %>
- <h3><%= title %></h3>
- <p><%= desc %></p>
- <hr/>
+ <% _.each(resources, function(resource) { %>
- <a href="http://aliss.org/depot/resource/<%= id %>/edit/">Edit resource</a> |
- <a href="http://aliss.org/depot/resource/<%= id %>/report/">Report Resource</a> |
- <a href="#" class="email">Email Resource</a>
+ <h3><%= resource.title %></h3>
+ <p><%= resource.description %></p>
+ <a href="http://aliss.org/depot/resource/<%= resource.id %>/edit/">Edit resource</a> |
+ <a href="http://aliss.org/depot/resource/<%= resource.id %>/report/">Report Resource</a>
+ <br/><br/>
+ <hr/>
+
+ <% }); %>
+
+ <p class="pagination span-18 last">
+ <a href="#" class="email">Email Resources</a> |
+ <a href="#" class="print">Print Resources</a>
+ </p>
+
+ <% } else if(resources.length === 1) { %>
+
+ <% var resource = resources[0]; %>
+ <h3><%= resource.title %></h3>
+ <p><%= resource.description %></p>
+ <hr/>
+ <a href="http://aliss.org/depot/resource/<%= resource.id %>/edit/">Edit resource</a> |
+ <a href="http://aliss.org/depot/resource/<%= resource.id %>/report/">Report Resource</a> |
+ <a href="#" class="email">Email Resource</a> |
+ <a href="#" class="print">Print Resource</a>
+
+ <% } else { %>
+ None?
+ <% } %>
</script>
View
76 js/gapp.js
@@ -2,6 +2,7 @@
$(function(){
+ "use strict";
locache.cleanup();
@@ -325,7 +326,8 @@ $(function(){
events: {
'click .back': 'hide',
- 'click .email': 'email'
+ 'click .email': 'email',
+ 'click .print': 'print'
},
results: new ResourceCollection(),
@@ -337,13 +339,15 @@ $(function(){
},
showResource: function(resource){
- this.resource = resource
var jsonResource = resource.toJSON()
- $('#resourceView').html(this.template(jsonResource))
- this.map.addResourceMarkers([jsonResource])
- this.map.setZoom(14);
- this.show()
- this.delegateEvents()
+ this.resources = [jsonResource]
+ this.render([jsonResource], [jsonResource])
+ },
+
+ showResources: function(resources){
+ this.resources = resources
+ var jsonResources = resources
+ this.render(jsonResources, jsonResources)
},
hide: function(){
@@ -357,10 +361,27 @@ $(function(){
},
email: function(){
- var title = this.resource.get('title'),
- description = this.emailTemplate(this.resource.toJSON())
+ var title = '', description = ''
+ $.each(this.resources, function(r){
+ title += r.title
+ description += this.emailTemplate(r)
+ })
description = description.replace(/\n/g, '%0D%0A')
window.location = "mailto:?Subject=" + title + "&body=" + description
+ },
+
+ print: function(){
+ window.print()
+ },
+
+ render: function(resources, markers){
+ $('#resourceView').html(this.template({
+ resources:resources
+ }))
+ this.map.addResourceMarkers(markers)
+ this.map.setZoom(14);
+ this.show()
+ this.delegateEvents()
}
})
@@ -584,15 +605,42 @@ $(function(){
resource: function(id){
- r = new Resource({"id": id});
+ var ids = id.split('-')
+
+ if (ids.length == 1){
+
+ resource = new Resource({
+ id: id
+ })
+ resource.on("change", function(){
+ app.resourceView.showResource(resource)
+ })
+ resource.fetch()
- r.on("change", function(){
+ } else if (ids.length > 1){
- app.resourceView.showResource(r)
+ resources = []
+
+ _.each(ids, function(i){
+ resource = new Resource({
+ id: i
+ })
+ resource.on("change", function(){
+ resources.push(resource.toJSON())
+ })
+ resource.fetch()
+ })
+ var fn = function(){
+ if (resources.length == ids.length){
+ app.resourceView.showResources(resources)
+ } else {
+ setTimeout(fn, 100)
+ }
+ }
+ fn()
- });
- r.fetch()
+ }
},

0 comments on commit a6aa460

Please sign in to comment.
Something went wrong with that request. Please try again.