diff --git a/app/controllers/TranscriptionController.coffee b/app/controllers/TranscriptionController.coffee index 20c0bb7..e475fed 100644 --- a/app/controllers/TranscriptionController.coffee +++ b/app/controllers/TranscriptionController.coffee @@ -5,6 +5,7 @@ Subject = require 'zooniverse/models/subject' Birds = require './interfaces/birds' BugsTranscriptionController = require './interfaces/bugs' +BugExpeditionsTranscriptionController = require './interfaces/bugExpeditions' SernacTranscriptionController = require './interfaces/plants' Fungi = require './interfaces/fungi' @@ -16,8 +17,8 @@ class TranscriptionController extends Site activate: (params) => super - - if Institute.count() is 0 + + if Institute.count() is 0 Institute.bind 'refresh', => @active params return @@ -38,6 +39,7 @@ class TranscriptionController extends Site # Set the appropriate transcription controller and start it up. switch @archive.slug() when 'calbug' then @transcriptionController = new BugsTranscriptionController() + when 'calbug-expeditions' then @transcriptionController = new BugExpeditionsTranscriptionController() when 'herbarium' then @transcriptionController = new SernacTranscriptionController() when 'ornithological' then @transcriptionController = new Birds() when 'macrofungi' then @transcriptionController = new Fungi() @@ -50,13 +52,13 @@ class TranscriptionController extends Site if e.which is 8 and not (e.target.tagName is 'INPUT') e.preventDefault() else if e.which is 77 and e.ctrlKey and $(".ui-autocomplete:visible").length == 0 - # ditto functionality - $(".ui-autocomplete-input").first().autocomplete("search","") + # ditto functionality + $(".ui-autocomplete-input").first().autocomplete("search","") $(".ui-autocomplete > li").parent().css("width", $(".ui-autocomplete-input").first().css("width")); $(".ui-autocomplete > li").parent().css("padding", "0px"); e.stopImmediatePropagation() - e.preventDefault() - else if $(".ui-autocomplete:visible").length > 0 + e.preventDefault() + else if $(".ui-autocomplete:visible").length > 0 # if menu is open and we press any key that has no meaning for jquery autocomplete menus (arrows, enter, escape, etc), close the menu $(".ui-autocomplete-input").autocomplete("close") if jQuery.inArray(e.which, [17,27,38,40,13,9,33,34]) == -1 e.preventDefault() diff --git a/app/controllers/interfaces/bugExpeditions.coffee b/app/controllers/interfaces/bugExpeditions.coffee new file mode 100644 index 0000000..bec9a3e --- /dev/null +++ b/app/controllers/interfaces/bugExpeditions.coffee @@ -0,0 +1,82 @@ +Archive = require '../../models/archive' + +Interfaces = require '../interfaces' + +Classification = require 'zooniverse/models/classification' +Subject = require 'zooniverse/models/subject' + +window.Snap = require 'snapsvg' +require 'snap.svg.zpd' + +ZOOM_FACTOR = 0.15 + +class BugExpeditions extends Interfaces + className: 'BugExpeditionsTranscriptionController' + template: require '../../views/transcription/bugs' + widgetName: 'Bugs' + + constructor: -> + super + + rawSvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + rawSvg.setAttribute 'id', 'image-container' + @surface = Snap rawSvg + + setupInterfaceWorkflow: => + @transcriber.$el.append @surface.node + + zoomInDiv = document.createElement 'div' + zoomInDiv.innerHTML = '+' + + zoomOutDiv = document.createElement 'div' + zoomOutDiv.innerHTML = '-' + + zoomInDiv.classList.add 'zoom-control', 'zoom-in' + zoomOutDiv.classList.add 'zoom-control', 'zoom-out' + + zoomInDiv.addEventListener 'click', => + g = @surface.select "##{@image.node.parentNode.id}" + + {width, height, cx, cy} = g.getBBox() + deltaX = ((width * (1 + ZOOM_FACTOR)) - width) / 2 + deltaY = ((height * (1 + ZOOM_FACTOR)) - height) / 2 + + matrix = new Snap.Matrix @image.node.parentNode.getCTM() + g.transform matrix.scale(1 + ZOOM_FACTOR).translate -(deltaX), -(deltaY) + + zoomOutDiv.addEventListener 'click', => + g = @surface.select "##{@image.node.parentNode.id}" + + {width, height} = g.getBBox() + deltaX = Math.abs ((width * (1 - ZOOM_FACTOR)) - width) / 2 + deltaY = Math.abs ((height * (1 - ZOOM_FACTOR)) - height) / 2 + + matrix = new Snap.Matrix @image.node.parentNode.getCTM() + g.transform matrix.scale(1 - ZOOM_FACTOR).translate deltaX, deltaY + + @transcriber.$el.append zoomInDiv + @transcriber.$el.append zoomOutDiv + + nextSubject: => + @surface.zpd 'destroy' + @surface.clear() + @classification = new Classification subject: Subject.current + + Subject.current.location.small ?= Subject.current.location.standard + subjectImage = Subject.current.location.standard + + img = new Image + img.onload = => + maxHeight = window.innerHeight - 150 + scaleFactor = Math.min 1, (maxHeight / img.naturalHeight) + + @image = @surface.image subjectImage, 0, 0, img.naturalWidth * scaleFactor, img.naturalHeight * scaleFactor + @image.transform("t#{(window.innerWidth / 2) - (@image.getBBox().width / 2)},20") + + @surface.zpd() + + @transcriber.startTranscribing Subject.current + + img.src = subjectImage + +module.exports = BugExpeditions diff --git a/app/controllers/interfaces/bugs.coffee b/app/controllers/interfaces/bugs.coffee index bc21f9f..8175501 100644 --- a/app/controllers/interfaces/bugs.coffee +++ b/app/controllers/interfaces/bugs.coffee @@ -8,7 +8,7 @@ Subject = require 'zooniverse/models/subject' window.Snap = require 'snapsvg' require 'snap.svg.zpd' -ZOOM_FACTOR = 0.25 +ZOOM_FACTOR = 0.15 class Bugs extends Interfaces className: 'BugsTranscriptionController' diff --git a/app/lib/badge-definitions.coffee b/app/lib/badge-definitions.coffee index 7c0a0f8..c203c9f 100644 --- a/app/lib/badge-definitions.coffee +++ b/app/lib/badge-definitions.coffee @@ -132,6 +132,54 @@ module.exports = [ else return false collection: 'calbug' + , + name: 'Egg' + url: 'badges/calbug/egg.png' + description: 'You earn this badge for transcribing a Calbug record' + awardText: 'You earned this badge for transcribing a Calbug record' + condition: + func: (details) -> + if details.user.project.groups?[details.archive.id]? + return details.user.project.groups[details.archive.id].classification_count > 0 + else + return false + collection: 'calbug-expeditions' + , + name: 'Caterpillar' + url: 'badges/calbug/caterpillar.png' + description: 'You earn this badge for transcribing 25 Calbug records' + awardText: 'You earned this badge for transcribing 25 Calbug records' + condition: + func: (details) -> + if details.user.project.groups?[details.archive.id]? + return details.user.project.groups[details.archive.id].classification_count > 25 + else + return false + collection: 'calbug-expeditions' + , + name: 'Butterfly' + url: 'badges/calbug/butterfly.png' + description: 'You earn this badge for transcribing 100 Calbug records' + awardText: 'You earned this badge for transcribing 100 Calbug records' + condition: + func: (details) -> + if details.user.project.groups?[details.archive.id]? + return details.user.project.groups[details.archive.id].classification_count > 100 + else + return false + collection: 'calbug-expeditions' + , + name: 'Butterflies' + url: 'badges/calbug/butterflies.png' + description: 'You earn this badge for transcribing 500 Calbug records' + awardText: 'You earned this badge for transcribing 500 Calbug records' + condition: + func: (details) -> + if details.user.project.groups?[details.archive.id]? + return details.user.project.groups[details.archive.id].classification_count > 500 + else + return false + collection: 'calbug-expeditions' , name: 'Spore' url: 'badges/macrofungi/spore.png' diff --git a/app/lib/groups.coffee b/app/lib/groups.coffee index 3aab4bc..8a59206 100644 --- a/app/lib/groups.coffee +++ b/app/lib/groups.coffee @@ -49,6 +49,22 @@ module.exports = "image":"images/img-collections5.jpg" "thumbnail":"images/calbug.png" "headerImage": "images/archives/calbugBg2.jpg" + "calbug-expeditions": + "name":"calbug-expeditions" + "categories":["Insects", "Spiders"] + "metadata": + "institute": "Essig Museum Collections" + "description":"Calbug is an effort to digitize terrestrial arthropod-specimen records with a focus on California, with specimen imges drawn from among eight entomological collections. The Calbug Science Team will then use the collection data to assess how arthropods have responded to climate change and habitat modification. CalBug Expeditions provide you with a focused taxonomic group to tackle. Our first expedition is on a group known as Jewel Beetles. They are both beautiful and destructive, and we need your help to learn more about them!" + "snippet": "Calbug digitizes collections of pinned insect specimens drawn from eight of California's major institutions, showcasing the stunning diversity of insect life in our world." + "extra_template": require "../views/archives/calbug" + "difficulty":"Easy" + "regions":["California and surrounding region"] + "start_date":"1880" + "end_date":"Present" + "location": + "image":"images/img-collections6.jpg" + "thumbnail":"images/calbug.png" + "headerImage": "images/archives/calbugBg3.jpg" "Natural History Museum": "name": "Natural History Museum" "Ornithological": @@ -93,4 +109,4 @@ module.exports = "location": "image":"images/archives/macrofungi/collection-list-bg.jpg" "headerImage": "images/archives/macrofungi/archive-bg.jpg" - + diff --git a/lib/nfn/ui/bugs/transcriber.js b/lib/nfn/ui/bugs/transcriber.js index 2788d9e..90ba0d7 100644 --- a/lib/nfn/ui/bugs/transcriber.js +++ b/lib/nfn/ui/bugs/transcriber.js @@ -169,7 +169,7 @@ nfn.ui.view.Bugs = nfn.ui.view.Transcriber.extend({ // Loads the Status Bar this.statusBar = new nfn.ui.view.StatusBar({ model: new nfn.ui.model.StatusBar({ - title: "Calbug", + title: "Calbug Expeditions", description: "from Essig Museum Collections" }), template: $("#statusbar-template").html(), diff --git a/public/images/archives/calbugBg3.jpg b/public/images/archives/calbugBg3.jpg new file mode 100644 index 0000000..940482b Binary files /dev/null and b/public/images/archives/calbugBg3.jpg differ diff --git a/public/images/img-collections6.jpg b/public/images/img-collections6.jpg new file mode 100644 index 0000000..ec5e7c0 Binary files /dev/null and b/public/images/img-collections6.jpg differ