| | 8 | if(!this.isInMidChange) { |
|---|
| | 9 | // Chances are this is a Media Annotation, so let's limit the flicker between items and |
|---|
| | 10 | // just show a Media Annotation panel right away (it flickers if you jump between Media |
|---|
| | 11 | // Annotations because the selection of the item initiates a load). If we're wrong, we |
|---|
| | 12 | // store the old panel and put it back. If jumping between Media Annotations and things |
|---|
| | 13 | // that aren't we'll get more flicker, but initial usability showing says people looking |
|---|
| | 14 | // at Media Annotations are more likely to click on subsequent Media Annotations, and |
|---|
| | 15 | // if they're not looking at Media Annotations, they're more likely to click on non- |
|---|
| | 16 | // Media Annotaions. The flicker essentially only happens when clicking from a non- |
|---|
| | 17 | // Media Annotation item to a Media Annotation item, and so far we'll just have to live |
|---|
| | 18 | // with it. |
|---|
| | 19 | var oldPanel = document.getElementById('zotero-item-pane-content').selectedPanel; |
|---|
| | 20 | // This being the test of whether the last item shown was a MediaAnnotation Item. |
|---|
| | 21 | if(this.isMediaAnnotation)this.showMAPanel(); |
|---|
| 75 | 91 | document.getElementById('ma-description').value = this.xmlDoc.evaluate("//description", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; |
|---|
| 76 | 92 | document.getElementById('ma-start-time').value = this.xmlDoc.evaluate("//start", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; |
|---|
| 77 | 93 | document.getElementById('ma-end-time').value = this.xmlDoc.evaluate("//end", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; |
|---|
| 78 | 94 | document.getElementById('ma-itemRef').value = item.getID(); |
|---|
| 92 | | if(this.isSaveable) { |
|---|
| 93 | | var item = Zotero.Items.get(document.getElementById('ma-itemRef').value); |
|---|
| 94 | | var newNote = "<mediannotate><description>" + document.getElementById('ma-description').value + "</description>\n" + |
|---|
| 95 | | "<start>" + document.getElementById('ma-start-time').value + "</start>\n" + |
|---|
| 96 | | "<end>" + document.getElementById('ma-end-time').value + "</end></mediannotate>"; |
|---|
| 97 | | item.updateNote(newNote); |
|---|
| 98 | | var title = document.getElementById('ma-start-time').value + " - " + document.getElementById('ma-end-time').value + " " + Zotero.Notes.noteToTitle(document.getElementById('ma-description').value); |
|---|
| 99 | | item.setField(110, title, false); |
|---|
| 100 | | item.save(); |
|---|
| | 108 | if(document.getElementById('ma-itemRef').value && !this.isInMidChange) { |
|---|
| | 109 | this.isInMidChange = true; |
|---|
| | 110 | var item = Zotero.Items.get(document.getElementById('ma-itemRef').value); |
|---|
| | 111 | var newNote = "<mediannotate><description>" + document.getElementById('ma-description').value + "</description>\n" + |
|---|
| | 112 | "<start>" + document.getElementById('ma-start-time').value + "</start>\n" + |
|---|
| | 113 | "<end>" + document.getElementById('ma-end-time').value + "</end></mediannotate>"; |
|---|
| | 114 | item.updateNote(newNote); |
|---|
| | 115 | //Sometimes were applying a change because we've switched to another item and the change in item takes effect before |
|---|
| | 116 | //the onchange takes effect. If that item is a Media Annotation, we'll want to switch back to the MAPanel because |
|---|
| | 117 | //updating the note will have reset it to its normal view, annoyingly enough. |
|---|
| | 118 | if(this.isMediaAnnotation) this.showMAPanel(); |
|---|
| | 119 | var title = document.getElementById('ma-start-time').value + " - " + document.getElementById('ma-end-time').value + " " + Zotero.Notes.noteToTitle(document.getElementById('ma-description').value); |
|---|
| | 120 | item.setField(110, title, false); |
|---|
| | 121 | item.save(); |
|---|
| | 122 | if(this.isMediaAnnotation) this.showMAPanel(); |
|---|
| | 123 | this.isInMidChange = false; |
|---|
| | 124 | this.hasChangedAnnotation = false; |
|---|