Changeset 24821
- Timestamp:
- 2011-11-28T14:57:17+13:00 (12 years ago)
- Location:
- main/trunk/model-cols-dev/peijones
- Files:
-
- 314 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-cols-dev/peijones/etc/collectionConfig.bak
r24784 r24821 73 73 <option name="-buttonname" value="Source"/> 74 74 </classifier> 75 <format><gsf:template match="documentNode"> <td valign="top"><gsf:link type="document"><gsf:icon type="document"/></gsf:link></td><td valign="top"><gsf:link type="source"><gsf:choose-metadata><gsf:metadata name="thumbicon"/><gsf:metadata name="srcicon"/></gsf:choose-metadata></gsf:link></td><td valign="top"><gsf:choose-metadata><gsf:metadata name="dc.Title"/><gsf:metadata name="exp.Title"/><gsf:metadata name="Title"/><gsf:default>Untitled</gsf:default></gsf:choose-metadata><gsf:switch><gsf:metadata name="Source"/><gsf:when test="exists"><br/><i>(<gsf:metadata name="Source"/>)</i></gsf:when></gsf:switch></td></gsf:template><gsf:template match="classifierNode"><td valign="top"><gsf:link type="classifier"><gsf:icon type="classifier"/></gsf:link></td><td valign="top"><gsf:metadata name="srclink"/><gsf:choose-metadata><gsf:metadata name="thumbicon"/><gsf:metadata name="srcicon"/></gsf:choose-metadata><gsf:metadata name="/srclink"/></td><td valign="top"><gsf:choose-metadata><gsf:metadata name="dc.Title"/><gsf:metadata name="exp.Title"/><gsf:metadata name="Title"/><gsf:default>Untitled</gsf:default></gsf:choose-metadata><gsf:switch><gsf:metadata name="Source"/><gsf:when test="exists"><br/><i>(<gsf:metadata name="Source"/>)</i></gsf:when></gsf:switch></td></gsf:template><gsf:template match="classifierNode" mode="horizontal"><gsf:link type="horizontal"><gsf:metadata name="Title"/></gsf:link></gsf:template></format>75 <format><gsf:template match="documentNode"> <td valign="top"> <gsf:link type="document"> <gsf:icon type="document"/> </gsf:link> </td> <td valign="top"> <gsf:link type="source"> <gsf:choose-metadata> <gsf:metadata name="thumbicon"/> <gsf:metadata name="srcicon"/> </gsf:choose-metadata> </gsf:link> </td> <td valign="top"> <gsf:choose-metadata> <gsf:metadata name="dc.Title"/> <gsf:metadata name="exp.Title"/> <gsf:metadata name="Title"/> <gsf:default>Untitled</gsf:default> </gsf:choose-metadata> <gsf:switch> <gsf:metadata name="Source"/> <gsf:when test="exists"> <br/><i>(<gsf:metadata name="Source"/>)</i> </gsf:when> </gsf:switch> </td> </gsf:template> <gsf:template match="classifierNode"> <td valign="top"> <gsf:link type="classifier"> <gsf:icon type="classifier"/> </gsf:link> </td> <td valign="top"> <gsf:metadata name="srclink"/> <gsf:choose-metadata> <gsf:metadata name="thumbicon"/> <gsf:metadata name="srcicon"/> </gsf:choose-metadata> <gsf:metadata name="/srclink"/> </td> <td valign="top"> <gsf:choose-metadata> <gsf:metadata name="dc.Title"/> <gsf:metadata name="exp.Title"/> <gsf:metadata name="Title"/> <gsf:default>Untitled</gsf:default> </gsf:choose-metadata> <gsf:switch> <gsf:metadata name="Source"/> <gsf:when test="exists"> <br/><i>(<gsf:metadata name="Source"/>)</i> </gsf:when> </gsf:switch> </td> </gsf:template> <gsf:template match="classifierNode" mode="horizontal"> <gsf:link type="horizontal"> <gsf:metadata name="Title"/> </gsf:link> </gsf:template> </format> 76 76 </browse> 77 77 <display> 78 <format> 79 <gsf:option name="TOC" value="false"/> 80 <xsl:template name="additionalHeaderContent"> 81 <!-- jQuery must be included before Annotator --> 82 <script src="sites/localsite/collect/peijones/js/annotator/lib/vendor/jquery.js"><xsl:text> </xsl:text></script> 83 84 <!-- If you're sure your users will only be using browsers modern 85 enough to have their own JSON.parse and JSON.stringify 86 implementations you can skip this --> 87 <script src="sites/localsite/collect/peijones/js/annotator/lib/vendor/json2.js"><xsl:text> </xsl:text></script> 88 89 <!-- The main Annotator script --> 90 <script src="sites/localsite/collect/peijones/js/annotator/pkg/annotator.min.js"><xsl:text> </xsl:text></script> 91 92 <!-- Annotator's styling and images --> 93 <link rel="stylesheet" type="text/css" href="sites/localsite/collect/peijones/js/annotator/pkg/annotator.min.css"/> 94 95 <!-- The following plugins are entirely optional --> 96 97 <!-- The Store plugin. Saves annotations to a remote backend --> 98 <script src="sites/localsite/collect/peijones/js/annotator/pkg/annotator.store.min.js"><xsl:text> </xsl:text></script> 99 100 <!-- The Auth plugin. Allows users of Annotator to authenticate themselves 101 to the remote backend --> 102 <script src="sites/localsite/collect/peijones/js/annotator/pkg/annotator.auth.min.js"><xsl:text> </xsl:text></script> 103 104 <!-- The Permissions plugin. See who created which annotation and create 105 annotations as a specified user --> 106 <script src="sites/localsite/collect/peijones/js/annotator/pkg/annotator.permissions.min.js"><xsl:text> </xsl:text></script> 107 108 <!-- The Tags plugin. Edit and display tag keywords on annotations --> 109 <script src="sites/localsite/collect/peijones/js/annotator/pkg/annotator.tags.min.js"><xsl:text> </xsl:text></script> 110 111 <!-- The Markdown plugin. Treat annotation text as Markdown --> 112 <script src="sites/localsite/collect/peijones/js/annotator/lib/vendor/showdown.js"><xsl:text> </xsl:text></script> 113 <script src="sites/localsite/collect/peijones/js/annotator/pkg/annotator.markdown.min.js"><xsl:text> </xsl:text></script> 114 115 <!-- Photo note scripts --> 116 <script type="text/javascript" src="sites/localsite/collect/peijones/js/documentmaker/BrowserDetect.js"><xsl:text> </xsl:text></script> 117 <script type="text/javascript" src="sites/localsite/collect/peijones/js/documentmaker/PhotoNotes-1.5.js"><xsl:text> </xsl:text></script> 118 <link rel="stylesheet" type="text/css" href="sites/localsite/collect/peijones/style/PhotoNotes-1.5.css"/> 119 120 <!-- Zoom scripts --> 121 <!--<script src="interfaces/{$interface_name}/js/jquery-1.4.2.js" type="text/javascript"><xsl:text> </xsl:text></script>--> 122 <script src="sites/localsite/collect/peijones/js/documentmaker/zoomer.jquery.js" type="text/javascript"><xsl:text> </xsl:text></script> <link href="sites/localsite/collect/peijones/style/style.css" rel="stylesheet" type="text/css"/> 123 <script type="text/javascript"> 124 <xsl:text disable-output-escaping="yes"> 125 _zoomEnabled = true; 126 function readyImagesForZoom() 127 { 128 var noZoom = document.getElementById("noZoom"); 129 var wrap = document.getElementById("wrap"); 130 if(!noZoom || !wrap) 131 { 132 return; 133 } 134 var smallImageDiv = document.getElementById("small"); 135 var smallImage = smallImageDiv.getElementsByTagName("img")[0]; 136 smallImageDiv.style.width = smallImageWidth + "px"; 137 smallImageDiv.style.height = smallImageHeight + "px"; 138 var multiplier = largeImageHeight / smallImageHeight; 139 $("#wrap").anythingZoomer({ 140 expansionSize:50, 141 speedMultiplier:multiplier 142 }); 143 144 noZoom.onclick = function(){addZoom();} 145 document.getElementById("overlay").onclick = function(){removeZoom();} 146 147 removeZoom(); 148 } 149 function addZoom() 150 { 151 if(!_zoomEnabled) 152 { 153 return; 154 } 155 156 var wrapper = document.getElementById("wrap"); 157 var noZoom = document.getElementById("noZoom"); 158 159 if(!noZoom || !wrapper) 160 { 161 return; 162 } 163 164 noZoom.style.display = "none"; 165 wrapper.style.display = "block"; 166 var option = document.getElementById("zoomOption"); 167 if(option) 168 { 169 option.setAttribute("onclick", "removeZoom();"); 170 } 171 } 172 function removeZoom() 173 { 174 if(!_zoomEnabled) 175 { 176 return; 177 } 178 179 var wrapper = document.getElementById("wrap"); 180 var noZoom = document.getElementById("noZoom"); 181 182 if(!noZoom || !wrapper) 183 { 184 return; 185 } 186 187 wrapper.style.display = "none"; 188 noZoom.style.display = "block"; 189 var option = document.getElementById("zoomOption"); 190 if(option) 191 { 192 option.setAttribute("onclick", "addZoom();"); 193 } 194 } 195 </xsl:text> 196 </script> 197 <script text="text/javascript"> 198 <xsl:text disable-output-escaping="yes"> 199 200 var _posCount = 0; 201 var _notes; 202 function initNotes() 203 { 204 /* create the Photo Note Container */ 205 _notes = new PhotoNoteContainer(document.getElementById("noZoom")); 206 getNotes(); 207 } 208 209 function deleteFunction(note) 210 { 211 var callback = 212 { 213 success: function(response) 214 { 215 var updateURL = gs.siteMetadata.siteURL.replace("8080","9090") + gs.xsltParams.library_name + "?a=s&sa=c"; 216 217 var updateCallback = 218 { 219 success: function(response){}, 220 failed: function(){alert("Failed in deleteFunction() to update Greenstone server with: " + updateURL);} 221 }; 222 223 224 YAHOO.util.Connect.asyncRequest("GET", updateURL, updateCallback); 225 }, 226 failed: function(){ alert("Failed in deleteFunction() with note id: " + note.id)}, 227 }; 228 229 var status = true; 230 231 if (note && note.id && note.id > 0) { 232 var metaposStr = note.id - 1; 233 234 var url = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=remove-metadata&site=localsite&c=" + gs.cgiParams.c + "&d=" + gs.cgiParams.d + "&metaname=gsimg.photoNote&metapos=" + metaposStr; 235 YAHOO.util.Connect.asyncRequest("GET", url, callback); 236 } 237 else { 238 alert("Failed to find valid note data to delete"); 239 status = false; 240 } 241 242 return status; 243 } 244 245 function saveFunction(note) 246 { 247 var callback = 248 { 249 success: function(response) 250 { 251 var updateURL = gs.siteMetadata.siteURL.replace("8080","9090") + gs.xsltParams.library_name + "?a=s&sa=c"; 252 253 var updateCallback = 254 { 255 success: function(response){}, 256 failed: function(reponse){ alert("Failed in saveFunction() to update Greenstone server with: " + updateURL);} 257 }; 258 259 260 YAHOO.util.Connect.asyncRequest("GET", updateURL, updateCallback); 261 }, 262 failed: function(reponse){ alert("Failed in saveFunction() with note id: " + note.id)}, 263 }; 264 265 var jsonVal = '{"caption":"' + note.text + '", "area":{"x":' + note.rect.left + ', "y":' + note.rect.top + ', "width":' + note.rect.width + ', "height":' + note.rect.height + '}}'; 266 var metaposStr = (note && note.id && note.id > 0) ? note.id - 1 : _posCount; 267 268 var saveURL = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=set-metadata&site=localsite&c=" + gs.cgiParams.c + "&d=" + gs.cgiParams.d + "&metaname=gsimg.photoNote&metavalue=" + jsonVal + "&metapos=" + metaposStr; 269 YAHOO.util.Connect.asyncRequest("GET", saveURL, callback); 270 271 return 1; 272 } 273 274 function getNotes() 275 { 276 if(gs.variables.photoNotes == null || gs.variables.photoNotes == undefined) 277 { 278 console.log("No photo notes"); 279 return; 280 } 281 282 for(var i = 0; i < gs.variables.photoNotes.length; i++) 283 { 284 var note = gs.variables.photoNotes[i]; 285 if(!note) 286 { 287 continue; 288 } 289 var newNote = new PhotoNote(note.caption, i+1, new PhotoNoteRect(note.area.x,note.area.y,note.area.width,note.area.height)); 290 newNote.onsave = saveFunction; 291 newNote.ondelete = deleteFunction; 292 _notes.AddNote(newNote); 293 _posCount++; 294 } 295 296 addNoteOverAndOutHandlers(); 297 } 298 299 function AddNote() 300 { 301 var newNote = new PhotoNote('Add note text here...',_posCount+1,new PhotoNoteRect(10,10,50,50)); 302 newNote.onsave = saveFunction; 303 newNote.ondelete = deleteFunction; 304 _notes.AddNote(newNote); 305 _posCount++; 306 307 addNoteOverAndOutHandlers(); 308 newNote.Select(); 309 } 310 311 function addNoteOverAndOutHandlers() 312 { 313 var divs = document.getElementsByTagName("DIV"); 314 for(var i = 0; i < divs.length; i++) 315 { 316 if(divs[i].getAttribute("class") && divs[i].getAttribute("class").search("fn-area") != -1) 317 { 318 divs[i].onmouseover = function(){_zoomEnabled = false;} 319 divs[i].onmouseout = function(){_zoomEnabled = true;} 320 } 321 } 322 } 323 324 window.onload = function(){initNotes(); readyImagesForZoom(); initAnnotator();}; 325 </xsl:text> 326 </script> 327 <script text="text/javascript"> 328 <xsl:text disable-output-escaping="yes"> 329 function initAnnotator() 330 { 331 jQuery(function ($) { 332 //alert(typeof $.fn.annotator); 333 if (typeof $.fn.annotator !== 'function') { 334 alert("Ooops! it looks like you haven't built the Annotator concatenation file. " + 335 "Either download a tagged release from GitHub, or modify the Cakefile to point " + 336 "at your copy of the YUI compressor and run `cake package`."); 337 } else { 338 // This is the important bit: how to create the annotator and add 339 // plugins 340 $('#gs-document-text').annotator() 341 .annotator('addPlugin', 'Permissions') 342 .annotator('addPlugin', 'Markdown') 343 //.annotator('addPlugin', 'Auth') 344 .annotator('addPlugin', 'Tags'); 345 346 $('#gs-document-text').data('annotator').plugins['Permissions'].setUser(""); 347 } 348 }); 349 } 350 </xsl:text> 351 </script> 352 </xsl:template> 353 354 <!--<xsl:template match="documentNode" mode="document">--> 355 <!-- Get the photo notes for this document node --> 356 <!--<gsf:variable-struct name="photoNotes"> 357 <gsf:metadata multiple="true" name="gsimg.photoNote" separator=", "/> 358 </gsf:variable-struct>--> 359 360 <!-- Get details about the image for zooming --> 361 <!--<h3> 362 <gsf:choose-metadata> 363 <gsf:metadata name="dc.Title"/> 364 <gsf:metadata name="ex.Title"/> 365 </gsf:choose-metadata> 366 </h3> 367 <xsl:variable name="imageWidth"> 368 <gsf:choose-metadata> 369 <gsf:metadata name="ImageWidth"/> 370 <gsf:default>-1</gsf:default> 371 </gsf:choose-metadata> 372 </xsl:variable> 373 <xsl:variable name="imageHeight"> 374 <gsf:choose-metadata> 375 <gsf:metadata name="ImageHeight"/> 376 <gsf:default>-1</gsf:default> 377 </gsf:choose-metadata> 378 </xsl:variable> 379 <xsl:variable name="screenImageWidth"> 380 <gsf:choose-metadata> 381 <gsf:metadata name="ScreenWidth"/> 382 <gsf:default>-1</gsf:default> 383 </gsf:choose-metadata> 384 </xsl:variable> 385 <xsl:variable name="screenImageHeight"> 386 <gsf:choose-metadata> 387 <gsf:metadata name="ScreenHeight"/> 388 <gsf:default>-1</gsf:default> 389 </gsf:choose-metadata> 390 </xsl:variable> 391 <script type="text/javascript"> 392 <xsl:text>largeImageHeight =</xsl:text><xsl:value-of select="$imageHeight"/><xsl:text>;</xsl:text> 393 <xsl:text>largeImageWidth =</xsl:text><xsl:value-of select="$imageWidth"/><xsl:text>;</xsl:text> 394 <xsl:text>smallImageHeight =</xsl:text><xsl:value-of select="$screenImageHeight"/><xsl:text>;</xsl:text> 395 <xsl:text>smallImageWidth =</xsl:text><xsl:value-of select="$screenImageWidth"/><xsl:text>;</xsl:text> 396 </script> 397 <div id="noZoom" style="display:block;"> 398 <gsf:metadata name="screenicon"/> 399 </div> 400 <xsl:if test="$imageHeight != -1"> 401 <div id="wrap" style="display:none"> 402 <div id="small" style="width: {$screenImageWidth}; height: {$screenImageHeight};"><gsf:metadata name="screenicon"/></div> 403 <div id="mover"> 404 <div id="overlay"><xsl:text> </xsl:text></div> 405 <div id="large"> 406 <img style="width: {$imageWidth}; height: {$imageHeight};"> 407 <xsl:attribute name="src"> 408 <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<gsf:metadata name="assocfilepath"/>/<gsf:metadata name="srclinkFile"/> 409 </xsl:attribute> 410 </img> 411 </div> 412 </div> 413 </div> 414 <input type="button" value="Tag Photo!" style="margin-left:30px;" onclick="AddNote();" /> 415 </xsl:if> 416 </xsl:template>--> 417 418 </format> 78 <format><gsf:option name="sideBar" value="false"/> <xsl:template name="additionalHeaderContent"> <#comment/> <script src="sites/localsite/collect/peijones/js/annotator/lib/vendor/jquery.js"><xsl:text> </xsl:text></script> <#comment/> <script src="sites/localsite/collect/peijones/js/annotator/lib/vendor/json2.js"><xsl:text> </xsl:text></script> <script src="sites/localsite/collect/peijones/js/annotator/pkg/annotator-full.min.js"><xsl:text> </xsl:text></script> <#comment/> <#comment/> <#comment/> <link href="sites/localsite/collect/peijones/js/annotator/pkg/annotator.min.css" rel="stylesheet" type="text/css"/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <#comment/> <script src="sites/localsite/collect/peijones/js/documentmaker/BrowserDetect.js" type="text/javascript"><xsl:text> </xsl:text></script> <script src="sites/localsite/collect/peijones/js/documentmaker/PhotoNotes-1.5.js" type="text/javascript"><xsl:text> </xsl:text></script> <link href="sites/localsite/collect/peijones/style/PhotoNotes-1.5.css" rel="stylesheet" type="text/css"/> <#comment/> <#comment/> <script src="sites/localsite/collect/peijones/js/documentmaker/zoomer.jquery.js" type="text/javascript"><xsl:text> </xsl:text></script> <link href="sites/localsite/collect/peijones/style/style.css" rel="stylesheet" type="text/css"/> <script type="text/javascript"> <xsl:text disable-output-escaping="yes"> _zoomEnabled = true; function readyImagesForZoom() { var noZoom = document.getElementById("noZoom"); var wrap = document.getElementById("wrap"); if(!noZoom || !wrap) { return; } var smallImageDiv = document.getElementById("small"); var smallImage = smallImageDiv.getElementsByTagName("img")[0]; smallImageDiv.style.width = smallImageWidth + "px"; smallImageDiv.style.height = smallImageHeight + "px"; var multiplier = largeImageHeight / smallImageHeight; $("#wrap").anythingZoomer({ expansionSize:50, speedMultiplier:multiplier }); noZoom.onclick = function(){addZoom();} document.getElementById("overlay").onclick = function(){removeZoom();} removeZoom(); } function addZoom() { if(!_zoomEnabled) { return; } var wrapper = document.getElementById("wrap"); var noZoom = document.getElementById("noZoom"); if(!noZoom || !wrapper) { return; } noZoom.style.display = "none"; wrapper.style.display = "block"; var option = document.getElementById("zoomOption"); if(option) { option.setAttribute("onclick", "removeZoom();"); } } function removeZoom() { if(!_zoomEnabled) { return; } var wrapper = document.getElementById("wrap"); var noZoom = document.getElementById("noZoom"); if(!noZoom || !wrapper) { return; } wrapper.style.display = "none"; noZoom.style.display = "block"; var option = document.getElementById("zoomOption"); if(option) { option.setAttribute("onclick", "addZoom();"); } } </xsl:text> </script> <script text="text/javascript"> <xsl:text disable-output-escaping="yes"> var _posCount = 0; var _notes; function initNotes() { /* create the Photo Note Container */ _notes = new PhotoNoteContainer(document.getElementById("noZoom")); getNotes(); } function deleteFunction(note) { var callback = { success: function(response) { var updateURL = gs.siteMetadata.siteURL.replace("8080","9090") + gs.xsltParams.library_name + "?a=s&sa=c"; var updateCallback = { success: function(response){}, failed: function(){alert("Failed in deleteFunction() to update Greenstone server with: " + updateURL);} }; YAHOO.util.Connect.asyncRequest("GET", updateURL, updateCallback); }, failed: function(){ alert("Failed in deleteFunction() with note id: " + note.id)}, }; var status = true; if (note && note.id && note.id > 0) { var metaposStr = note.id - 1; var url = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=remove-metadata&site=localsite&c=" + gs.cgiParams.c + "&d=" + gs.cgiParams.d + "&metaname=gsimg.photoNote&metapos=" + metaposStr; YAHOO.util.Connect.asyncRequest("GET", url, callback); } else { alert("Failed to find valid note data to delete"); status = false; } return status; } function saveFunction(note) { var callback = { success: function(response) { var updateURL = gs.siteMetadata.siteURL.replace("8080","9090") + gs.xsltParams.library_name + "?a=s&sa=c"; var updateCallback = { success: function(response){}, failed: function(reponse){ alert("Failed in saveFunction() to update Greenstone server with: " + updateURL);} }; YAHOO.util.Connect.asyncRequest("GET", updateURL, updateCallback); }, failed: function(reponse){ alert("Failed in saveFunction() with note id: " + note.id)}, }; var jsonVal = '{"caption":"' + note.text + '", "area":{"x":' + note.rect.left + ', "y":' + note.rect.top + ', "width":' + note.rect.width + ', "height":' + note.rect.height + '}}'; var metaposStr = (note && note.id && note.id > 0) ? note.id - 1 : _posCount; var saveURL = gs.siteMetadata.siteURL.replace("8080","9090") + "cgi-bin/metadata-server.pl?a=set-metadata&site=localsite&c=" + gs.cgiParams.c + "&d=" + gs.cgiParams.d + "&metaname=gsimg.photoNote&metavalue=" + jsonVal + "&metapos=" + metaposStr; YAHOO.util.Connect.asyncRequest("GET", saveURL, callback); return 1; } function getNotes() { if(gs.variables.photoNotes == null || gs.variables.photoNotes == undefined) { console.log("No photo notes"); return; } for(var i = 0; i < gs.variables.photoNotes.length; i++) { var note = gs.variables.photoNotes[i]; if(!note) { continue; } var newNote = new PhotoNote(note.caption, i+1, new PhotoNoteRect(note.area.x,note.area.y,note.area.width,note.area.height)); newNote.onsave = saveFunction; newNote.ondelete = deleteFunction; _notes.AddNote(newNote); _posCount++; } addNoteOverAndOutHandlers(); } function AddNote() { var newNote = new PhotoNote('Add note text here...',_posCount+1,new PhotoNoteRect(10,10,50,50)); newNote.onsave = saveFunction; newNote.ondelete = deleteFunction; _notes.AddNote(newNote); _posCount++; addNoteOverAndOutHandlers(); newNote.Select(); } function addNoteOverAndOutHandlers() { var divs = document.getElementsByTagName("DIV"); for(var i = 0; i < divs.length; i++) { if(divs[i].getAttribute("class") && divs[i].getAttribute("class").search("fn-area") != -1) { divs[i].onmouseover = function(){_zoomEnabled = false;} divs[i].onmouseout = function(){_zoomEnabled = true;} } } } window.onload = function(){initNotes(); readyImagesForZoom(); initAnnotator();}; </xsl:text> </script> <script text="text/javascript"> <xsl:text disable-output-escaping="yes"> function initAnnotator() { jQuery(function ($) { if (typeof $.fn.annotator !== 'function') { alert("Ooops! it looks like you haven't built the Annotator concatenation file. " + "Either download a tagged release from GitHub, or modify the Cakefile to point " + "at your copy of the YUI compressor and run `cake package`."); } else { /* jQuery('#gs-document-text').annotator() .annotator('addPlugin', 'Store', { prefix: 'http://annotateit.org/api', annotationData: {'uri':document.URL} }) .annotator('addPlugin', 'Auth', { userId: 'papitha', // Your AnnotateIt username consumerKey: '39fc339cf058bd22176771b3e33c5dac', // Your Account Key authToken: '852b7fc25396d2aedf9aeb44dd58518faa679dbf027892164bfb81900bd09741' // Your Auth Token }); */ jQuery(function ($) { // Include AnnotateIt credentials to load the store plugin. $('#gs-document-text').annotator().annotator('setupPlugins', { userId: 'papitha', userName: 'Papitha', accountId: '39fc339cf058bd22176771b3e33c5dac', authToken: '852b7fc25396d2aedf9aeb44dd58518faa679dbf027892164bfb81900bd09741', }, { //Store: {annotationData: {'uri':document.URL}} }); }); } }); } </xsl:text> </script> </xsl:template> <xsl:template name="documentImage"> <#comment/> <gsf:variable-struct name="photoNotes"> <gsf:metadata multiple="true" name="gsimg.photoNote" separator=", "/> </gsf:variable-struct> <#comment/> <h3> <gsf:choose-metadata> <gsf:metadata name="dc.Title"/> <gsf:metadata name="ex.Title"/> </gsf:choose-metadata> </h3> <xsl:variable name="imageWidth"> <gsf:choose-metadata> <gsf:metadata name="ImageWidth"/> <gsf:default>-1</gsf:default> </gsf:choose-metadata> </xsl:variable> <xsl:variable name="imageHeight"> <gsf:choose-metadata> <gsf:metadata name="ImageHeight"/> <gsf:default>-1</gsf:default> </gsf:choose-metadata> </xsl:variable> <xsl:variable name="screenImageWidth"> <gsf:choose-metadata> <gsf:metadata name="ScreenWidth"/> <gsf:default>-1</gsf:default> </gsf:choose-metadata> </xsl:variable> <xsl:variable name="screenImageHeight"> <gsf:choose-metadata> <gsf:metadata name="ScreenHeight"/> <gsf:default>-1</gsf:default> </gsf:choose-metadata> </xsl:variable> <script type="text/javascript"> <xsl:text>largeImageHeight =</xsl:text><xsl:value-of select="$imageHeight"/><xsl:text>;</xsl:text> <xsl:text>largeImageWidth =</xsl:text><xsl:value-of select="$imageWidth"/><xsl:text>;</xsl:text> <xsl:text>smallImageHeight =</xsl:text><xsl:value-of select="$screenImageHeight"/><xsl:text>;</xsl:text> <xsl:text>smallImageWidth =</xsl:text><xsl:value-of select="$screenImageWidth"/><xsl:text>;</xsl:text> </script> <div id="noZoom" style="display:block;"> <gsf:metadata name="screenicon"/> </div> <#comment/> <div id="wrap" style="display:none; width: {$screenImageWidth}; height: {$screenImageHeight};"> <div id="small" style="width: {$screenImageWidth}; height: {$screenImageHeight};"><gsf:metadata name="screenicon"/></div> <div id="mover"> <div id="overlay"><xsl:text> </xsl:text></div> <div id="large"> <img style="width: {$imageWidth}; height: {$imageHeight};"> <xsl:attribute name="src"> <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<gsf:metadata name="assocfilepath"/>/<gsf:metadata name="srclinkFile"/> </xsl:attribute> </img> </div> </div> </div> <input onclick="AddNote();" style="margin-left:30px;" type="button" value="Tag Photo!"/> <#comment/> </xsl:template> </format> 419 79 </display> 420 80 <replaceListRef id="gs2-standard"/> -
main/trunk/model-cols-dev/peijones/js/annotator/pkg/annotator-full.min.js
r24771 r24821 1 (function(){var h,o,b,p,n,i,l,a,e,d,c,r,s,j;var m=Array.prototype.slice,g=function(t,u){return function(){return t.apply(u,arguments)}},k=Object.prototype.hasOwnProperty,q=function(w,u){for(var t in u){if(k.call(u,t)){w[t]=u[t]}}function v(){this.constructor=w}v.prototype=u.prototype;w.prototype=new v;w.__super__=u.prototype;return w},f=Array.prototype.indexOf||function(v){for(var u=0,t=this.length;u<t;u++){if(this[u]===v){return u}}return -1};if(!(typeof jQuery!=="undefined"&&jQuery!==null?(j=jQuery.fn)!=null?j.jquery:void 0:void 0)){console.error("Annotator requires jQuery: have you included lib/vendor/jquery.js?")}if(!(JSON&&JSON.parse&&JSON.stringify)){console.error("Annotator requires a JSON implementation: have you included lib/vendor/json2.js?")}h=jQuery.sub();h.flatten=function(u){var t;t=function(w){var x,z,y,v;z=[];for(y=0,v=w.length;y<v;y++){x=w[y];z=z.concat(x&&h.isArray(x)?t(x):x)}return z};return t(u)};h.plugin=function(u,t){return jQuery.fn[u]=function(w){var v;v=Array.prototype.slice.call(arguments,1);return this.each(function(){var x;x=h.data(this,u);if(x){return w&&x[w].apply(x,v)}else{x=new t(this,w);return h.data(this,u,x)}})}};h.fn.textNodes=function(){var t;t=function(v){var u;if(v&&v.nodeType!==3){u=[];if(v.nodeType!==8){v=v.lastChild;while(v){u.push(t(v));v=v.previousSibling}}return u.reverse()}else{return v}};return this.map(function(){return h.flatten(t(this))})};h.fn.xpath=function(t){var u;u=this.map(function(){var w,v,x;x="";w=this;while(w&&w.nodeType===1&&w!==t){v=h(w.parentNode).children(w.tagName).index(w)+1;v=v>1?"["+v+"]":"";x="/"+w.tagName.toLowerCase()+v+x;w=w.parentNode}return x});return u.get()};h.escape=function(t){return t.replace(/&(?!\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")};h.fn.escape=function(t){if(arguments.length){return this.html(h.escape(t))}return this.html()};l=["log","debug","info","warn","exception","assert","dir","dirxml","trace","group","groupEnd","groupCollapsed","time","timeEnd","profile","profileEnd","count","clear","table","error","notifyFirebug","firebug","userObjects"];if(typeof console!=="undefined"&&console!==null){if(!(console.group!=null)){console.group=function(t){return console.log("GROUP: ",t)}}if(!(console.groupCollapsed!=null)){console.groupCollapsed=console.group}for(d=0,r=l.length;d<r;d++){i=l[d];if(!(console[i]!=null)){console[i]=function(){return console.log("Not implemented: console."+name)}}}}else{this.console={};for(c=0,s=l.length;c<s;c++){i=l[c];this.console[i]=function(){}}this.console.error=function(){var t;t=1<=arguments.length?m.call(arguments,0):[];return alert("ERROR: "+(t.join(", ")))};this.console.warn=function(){var t;t=1<=arguments.length?m.call(arguments,0):[];return alert("WARNING: "+(t.join(", ")))}}b=(function(){t.prototype.events={};t.prototype.options={};t.prototype.element=null;function t(v,u){this.options=h.extend(true,{},this.options,u);this.element=h(v);this.on=this.subscribe;this.addEvents()}t.prototype.addEvents=function(){var x,z,y,u,w,B,A,v;B=this.events;v=[];for(y in B){z=B[y];A=y.split(" "),u=2<=A.length?m.call(A,0,w=A.length-1):(w=0,[]),x=A[w++];v.push(this.addEvent(u.join(" "),x,z))}return v};t.prototype.addEvent=function(u,w,x){var y,v;y=g(function(){return this[x].apply(this,arguments)},this);v=typeof u==="string"&&u.replace(/\s+/g,"")==="";if(v){u=this.element}if(typeof u==="string"){this.element.delegate(u,w,y)}else{if(this.isCustomEvent(w)){this.subscribe(w,y)}else{h(u).bind(w,y)}}return this};t.prototype.isCustomEvent=function(v){var u;u="blur focus focusin focusout load resize scroll unload click dblclick\nmousedown mouseup mousemove mouseover mouseout mouseenter mouseleave\nchange select submit keydown keypress keyup error".split(/[^a-z]+/);v=v.split(".")[0];return h.inArray(v,u)===-1};t.prototype.publish=function(){this.element.triggerHandler.apply(this.element,arguments);return this};t.prototype.subscribe=function(u,w){var v;v=function(){return w.apply(this,[].slice.call(arguments,1))};v.guid=w.guid=(h.guid+=1);this.element.bind(u,v);return this};t.prototype.unsubscribe=function(){this.element.unbind.apply(this.element,arguments);return this};return t})();p={};p.sniff=function(t){if(t.commonAncestorContainer!=null){return new p.BrowserRange(t)}else{if(typeof t.start==="string"){return new p.SerializedRange(t)}else{if(t.start&&typeof t.start==="object"){return new p.NormalizedRange(t)}else{console.error("Couldn't not sniff range type");return false}}}};p.BrowserRange=(function(){function t(u){this.commonAncestorContainer=u.commonAncestorContainer;this.startContainer=u.startContainer;this.startOffset=u.startOffset;this.endContainer=u.endContainer;this.endOffset=u.endOffset}t.prototype.normalize=function(C){var B,x,D,A,w,v,z,u,y;if(this.tainted){console.error("You may only call normalize() once on a BrowserRange!");return false}else{this.tainted=true}v={};D={};y=["start","end"];for(z=0,u=y.length;z<u;z++){w=y[z];x=this[w+"Container"];A=this[w+"Offset"];if(x.nodeType===1){B=x.childNodes[A];x=B||x.childNodes[A-1];while(x.nodeType!==3){x=x.firstChild}A=B?0:x.nodeValue.length}v[w]=x;v[w+"Offset"]=A}D.start=v.startOffset>0?v.start.splitText(v.startOffset):v.start;if(v.start===v.end){if((v.endOffset-v.startOffset)<D.start.nodeValue.length){D.start.splitText(v.endOffset-v.startOffset)}D.end=D.start}else{if(v.endOffset<v.end.nodeValue.length){v.end.splitText(v.endOffset)}D.end=v.end}D.commonAncestor=this.commonAncestorContainer;while(D.commonAncestor.nodeType!==1){D.commonAncestor=D.commonAncestor.parentNode}return new p.NormalizedRange(D)};t.prototype.serialize=function(u,v){return this.normalize(u).serialize(u,v)};return t})();p.NormalizedRange=(function(){function t(u){this.commonAncestor=u.commonAncestor;this.start=u.start;this.end=u.end}t.prototype.normalize=function(u){return this};t.prototype.limit=function(y){var u,x,v,w,A,z;u=h.grep(this.textNodes(),function(B){return B.parentNode===y||h.contains(y,B.parentNode)});if(!u.length){return null}this.start=u[0];this.end=u[u.length-1];v=h(this.start).parents();z=h(this.end).parents();for(w=0,A=z.length;w<A;w++){x=z[w];if(v.index(x)!==-1){this.commonAncestor=x;break}}return this};t.prototype.serialize=function(w,x){var v,u,y;u=function(D,C){var B,A,F,I,H,G,E,z;if(x){I=h(D).parents(":not("+x+")").eq(0)}else{I=h(D).parent()}G=I.xpath(w)[0];H=I.textNodes();A=H.slice(0,H.index(D));F=0;for(E=0,z=A.length;E<z;E++){B=A[E];F+=B.nodeValue.length}if(C){return[G,F+D.nodeValue.length]}else{return[G,F]}};y=u(this.start);v=u(this.end,true);return new p.SerializedRange({start:y[0],end:v[0],startOffset:y[1],endOffset:v[1]})};t.prototype.text=function(){var u;return((function(){var w,y,x,v;x=this.textNodes();v=[];for(w=0,y=x.length;w<y;w++){u=x[w];v.push(u.nodeValue)}return v}).call(this)).join("")};t.prototype.textNodes=function(){var u,x,v,w;v=h(this.commonAncestor).textNodes();w=[v.index(this.start),v.index(this.end)],x=w[0],u=w[1];return h.makeArray(v.slice(x,(u+1)||9000000000))};return t})();p.SerializedRange=(function(){function t(u){this.start=u.start;this.startOffset=u.startOffset;this.end=u.end;this.endOffset=u.endOffset}t.prototype._nodeFromXPath=function(u){var z,y,v,x,w;y=function(B,A){if(A==null){A=null}return document.evaluate(B,document,A,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue};if(!h.isXMLDoc(document.documentElement)){return y(u)}else{z=document.createNSResolver(document.ownerDocument===null?document.documentElement:document.ownerDocument.documentElement);x=y(u,z);if(!x){u=((function(){var B,D,C,A;C=u.split("/");A=[];for(B=0,D=C.length;B<D;B++){w=C[B];A.push(w&&w.indexOf(":")===-1?w.replace(/^([a-z]+)/,"xhtml:$1"):w)}return A})()).join("/");v=document.lookupNamespaceURI(null);z=function(A){if(A==="xhtml"){return v}else{return document.documentElement.getAttribute("xmlns:"+A)}};x=y(u,z)}return x}};t.prototype.normalize=function(G){var K,D,C,I,A,F,H,E,B,z,v,u,L,J,y,x,w;H=h(G).xpath()[0];B=this.start.split("/");C=this.end.split("/");D=[];E={};for(I=0,y=B.length;0<=y?I<y:I>y;0<=y?I++:I--){if(B[I]===C[I]){D.push(B[I])}else{break}}K=H+D.join("/");E.commonAncestorContainer=this._nodeFromXPath(K);if(!E.commonAncestorContainer){console.error("Error deserializing range: can't find XPath '"+K+"'. Is this the right document?");return null}x=["start","end"];for(v=0,L=x.length;v<L;v++){F=x[v];A=0;w=h(this._nodeFromXPath(H+this[F])).textNodes();for(u=0,J=w.length;u<J;u++){z=w[u];if(A+z.nodeValue.length>=this[F+"Offset"]){E[F+"Container"]=z;E[F+"Offset"]=this[F+"Offset"]-A;break}else{A+=z.nodeValue.length}}}return new p.BrowserRange(E).normalize(G)};t.prototype.serialize=function(u,v){return this.normalize(u).serialize(u,v)};t.prototype.toObject=function(){return{start:this.start,startOffset:this.startOffset,end:this.end,endOffset:this.endOffset}};return t})();a={getGlobal:function(){return(function(){return this})()},mousePosition:function(t,v){var u;u=h(v).offset();return{top:t.pageY-u.top,left:t.pageX-u.left}}};e=this.Annotator;o=(function(){q(t,b);t.prototype.events={".annotator-adder button click":"onAdderClick",".annotator-adder button mousedown":"onAdderMousedown",".annotator-hl mouseover":"onHighlightMouseover",".annotator-hl mouseout":"startViewerHideTimer"};t.prototype.html={hl:'<span class="annotator-hl"></span>',adder:'<div class="annotator-adder"><button>Annotate</button></div>',wrapper:'<div class="annotator-wrapper"></div>'};t.prototype.options={};t.prototype.plugins={};t.prototype.editor=null;t.prototype.viewer=null;t.prototype.selectedRanges=null;t.prototype.mouseIsDown=false;t.prototype.ignoreMouseup=false;t.prototype.viewerHideTimer=null;function t(w,v){this.onDeleteAnnotation=g(this.onDeleteAnnotation,this);this.onEditAnnotation=g(this.onEditAnnotation,this);this.onAdderClick=g(this.onAdderClick,this);this.onAdderMousedown=g(this.onAdderMousedown,this);this.onHighlightMouseover=g(this.onHighlightMouseover,this);this.checkForEndSelection=g(this.checkForEndSelection,this);this.checkForStartSelection=g(this.checkForStartSelection,this);this.clearViewerHideTimer=g(this.clearViewerHideTimer,this);this.startViewerHideTimer=g(this.startViewerHideTimer,this);this.showViewer=g(this.showViewer,this);this.onEditorSubmit=g(this.onEditorSubmit,this);this.onEditorHide=g(this.onEditorHide,this);this.showEditor=g(this.showEditor,this);var u,x,y;t.__super__.constructor.apply(this,arguments);this.plugins={};if(!t.supported()){return this}this._setupDocumentEvents()._setupWrapper()._setupViewer()._setupEditor();y=this.html;for(u in y){x=y[u];if(u!=="wrapper"){this[u]=h(x).appendTo(this.wrapper).hide()}}}t.prototype._setupWrapper=function(){this.wrapper=h(this.html.wrapper);this.element.find("script").remove();this.element.wrapInner(this.wrapper);this.wrapper=this.element.find(".annotator-wrapper");return this};t.prototype._setupViewer=function(){this.viewer=new t.Viewer();this.viewer.hide().on("edit",this.onEditAnnotation).on("delete",this.onDeleteAnnotation).addField({load:g(function(v,u){h(v).escape(u.text||"");return this.publish("annotationViewerTextField",[v,u])},this)}).element.appendTo(this.wrapper).bind({mouseover:this.clearViewerHideTimer,mouseout:this.startViewerHideTimer});return this};t.prototype._setupEditor=function(){this.editor=new t.Editor();this.editor.hide().on("hide",this.onEditorHide).on("save",this.onEditorSubmit).addField({type:"textarea",label:"Comments\u2026",load:function(v,u){return h(v).find("textarea").val(u.text||"")},submit:function(v,u){return u.text=h(v).find("textarea").val()}});this.editor.element.appendTo(this.wrapper);return this};t.prototype._setupDocumentEvents=function(){h(document).bind({mouseup:this.checkForEndSelection,mousedown:this.checkForStartSelection});return this};t.prototype.getSelectedRanges=function(){var x,v,u,w;w=a.getGlobal().getSelection();u=[];if(!w.isCollapsed){u=(function(){var z,y;y=[];for(v=0,z=w.rangeCount;0<=z?v<z:v>z;0<=z?v++:v--){x=new p.BrowserRange(w.getRangeAt(v));y.push(x.normalize().limit(this.wrapper[0]))}return y}).call(this)}return h.grep(u,function(y){return y})};t.prototype.createAnnotation=function(){var u;u={};this.publish("beforeAnnotationCreated",[u]);return u};t.prototype.setupAnnotation=function(u,w){var v,A,z,x,y,B;if(w==null){w=true}u.ranges||(u.ranges=this.selectedRanges);A=(function(){var D,F,E,C;E=u.ranges;C=[];for(D=0,F=E.length;D<F;D++){z=E[D];x=p.sniff(z);C.push(x.normalize(this.wrapper[0]))}return C}).call(this);A=h.grep(A,function(C){return C!==null});u.quote=[];u.ranges=[];u.highlights=[];for(y=0,B=A.length;y<B;y++){v=A[y];u.quote.push(h.trim(v.text()));u.ranges.push(v.serialize(this.wrapper[0],".annotator-hl"));h.merge(u.highlights,this.highlightRange(v))}u.quote=u.quote.join(" / ");h(u.highlights).data("annotation",u);if(w){this.publish("annotationCreated",[u])}return u};t.prototype.updateAnnotation=function(u){this.publish("beforeAnnotationUpdated",[u]);this.publish("annotationUpdated",[u]);return u};t.prototype.deleteAnnotation=function(u){var w,v,y,x;x=u.highlights;for(v=0,y=x.length;v<y;v++){w=x[v];h(w).replaceWith(w.childNodes)}this.publish("annotationDeleted",[u]);return u};t.prototype.loadAnnotations=function(v){var w,u;if(v==null){v=[]}u=g(function(z){var B,x,y,A;if(z==null){z=[]}x=z.splice(0,10);for(y=0,A=x.length;y<A;y++){B=x[y];this.setupAnnotation(B,false)}if(z.length>0){return setTimeout((function(){return u(z)}),100)}else{return this.publish("annotationsLoaded",[w])}},this);w=v.slice();if(v.length){u(v)}return this};t.prototype.dumpAnnotations=function(){if(this.plugins.Store){return this.plugins.Store.dumpAnnotations()}else{return console.warn("Can't dump annotations without Store plugin.")}};t.prototype.highlightRange=function(v){var u,w,x;return u=(function(){var z,B,A,y;A=v.textNodes();y=[];for(z=0,B=A.length;z<B;z++){w=A[z];x=this.hl.clone().show();y.push(h(w).wrap(x).parent().get(0))}return y}).call(this)};t.prototype.addPlugin=function(w,v){var u,x;if(this.plugins[w]){console.error("You cannot have more than one instance of any plugin.")}else{u=t.Plugin[w];if(typeof u==="function"){this.plugins[w]=new u(this.element[0],v);this.plugins[w].annotator=this;if(typeof(x=this.plugins[w]).pluginInit==="function"){x.pluginInit()}}else{console.error("Could not load "+w+" plugin. Have you included the appropriate <script> tag?")}}return this};t.prototype.showEditor=function(u,v){this.editor.element.css(v);this.editor.load(u);return this};t.prototype.onEditorHide=function(){this.publish("annotationEditorHidden",[this.editor]);return this.ignoreMouseup=false};t.prototype.onEditorSubmit=function(u){this.publish("annotationEditorSubmit",[this.editor,u]);if(u.ranges===void 0){return this.setupAnnotation(u)}else{return this.updateAnnotation(u)}};t.prototype.showViewer=function(v,u){this.viewer.element.css(u);this.viewer.load(v);return this.publish("annotationViewerShown",[this.viewer,v])};t.prototype.startViewerHideTimer=function(){if(!this.viewerHideTimer){return this.viewerHideTimer=setTimeout(h.proxy(this.viewer.hide,this.viewer),250)}};t.prototype.clearViewerHideTimer=function(){clearTimeout(this.viewerHideTimer);return this.viewerHideTimer=false};t.prototype.checkForStartSelection=function(u){if(!(u&&this.isAnnotator(u.target))){this.startViewerHideTimer();return this.mouseIsDown=true}};t.prototype.checkForEndSelection=function(x){var u,v,w,z,y;this.mouseIsDown=false;if(this.ignoreMouseup){return}this.selectedRanges=this.getSelectedRanges();y=this.selectedRanges;for(w=0,z=y.length;w<z;w++){v=y[w];u=v.commonAncestor;if(this.isAnnotator(u)){return}}if(x&&this.selectedRanges.length){return this.adder.css(a.mousePosition(x,this.wrapper[0])).show()}else{return this.adder.hide()}};t.prototype.isAnnotator=function(u){return !!h(u).parents().andSelf().filter("[class^=annotator-]").not(this.wrapper).length};t.prototype.onHighlightMouseover=function(u){var v;this.clearViewerHideTimer();if(this.mouseIsDown||this.viewer.isShown()){return false}v=h(u.target).parents(".annotator-hl").andSelf().map(function(){return h(this).data("annotation")});return this.showViewer(h.makeArray(v),a.mousePosition(u,this.wrapper[0]))};t.prototype.onAdderMousedown=function(u){if(u!=null){u.preventDefault()}return this.ignoreMouseup=true};t.prototype.onAdderClick=function(v){var u;if(v!=null){v.preventDefault()}u=this.adder.position();this.adder.hide();return this.showEditor(this.createAnnotation(),u)};t.prototype.onEditAnnotation=function(u){var v;v=this.viewer.element.position();this.viewer.hide();return this.showEditor(u,v)};t.prototype.onDeleteAnnotation=function(u){this.viewer.hide();return this.deleteAnnotation(u)};return t})();o.Plugin=(function(){q(t,b);function t(v,u){t.__super__.constructor.apply(this,arguments)}t.prototype.pluginInit=function(){};return t})();o.$=h;o.supported=function(){return(function(){return !!this.getSelection})()};o.noConflict=function(){a.getGlobal().Annotator=e;return this};h.plugin("annotator",o);this.Annotator=o;o.Widget=(function(){q(t,b);t.prototype.classes={hide:"annotator-hide",invert:{x:"annotator-invert-x",y:"annotator-invert-y"}};function t(v,u){t.__super__.constructor.apply(this,arguments);this.classes=h.extend({},o.Widget.prototype.classes,this.classes)}t.prototype.checkOrientation=function(){var x,y,u,w,v;this.resetOrientation();v=h(a.getGlobal());w=this.element.children(":first");y=w.offset();u={top:v.scrollTop(),right:v.width()+v.scrollLeft()};x={top:y.top,right:y.left+w.width()};if((x.top-u.top)<0){this.invertY()}if((x.right-u.right)>0){this.invertX()}return this};t.prototype.resetOrientation=function(){this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y);return this};t.prototype.invertX=function(){this.element.addClass(this.classes.invert.x);return this};t.prototype.invertY=function(){this.element.addClass(this.classes.invert.y);return this};return t})();o.Editor=(function(){q(t,o.Widget);t.prototype.events={"form submit":"submit",".annotator-save click":"submit",".annotator-cancel click":"hide",".annotator-cancel mouseover":"onCancelButtonMouseover","textarea keydown":"processKeypress"};t.prototype.classes={hide:"annotator-hide",focus:"annotator-focus"};t.prototype.html='<div class="annotator-outer annotator-editor">\n <form class="annotator-widget">\n <ul class="annotator-listing"></ul>\n <div class="annotator-controls">\n <a href="#cancel" class="annotator-cancel">Cancel</a>\n <a href="#save" class="annotator-save annotator-focus">Save</a>\n </div>\n <span class="annotator-resize"></span>\n </form>\n</div>';t.prototype.options={};function t(u){this.onCancelButtonMouseover=g(this.onCancelButtonMouseover,this);this.processKeypress=g(this.processKeypress,this);this.submit=g(this.submit,this);this.load=g(this.load,this);this.hide=g(this.hide,this);this.show=g(this.show,this);t.__super__.constructor.call(this,h(this.html)[0],u);this.fields=[];this.annotation={};this.setupDragabbles()}t.prototype.show=function(u){if(u!=null){u.preventDefault()}this.element.removeClass(this.classes.hide);this.element.find(".annotator-save").addClass(this.classes.focus);this.element.find(":input:first").focus();return this.checkOrientation().publish("show")};t.prototype.hide=function(u){if(u!=null){u.preventDefault()}this.element.addClass(this.classes.hide);return this.publish("hide")};t.prototype.load=function(u){var w,v,y,x;this.annotation=u;this.publish("load",[this.annotation]);x=this.fields;for(v=0,y=x.length;v<y;v++){w=x[v];w.load(w.element,this.annotation)}return this.show()};t.prototype.submit=function(v){var w,u,y,x;if(v!=null){v.preventDefault()}x=this.fields;for(u=0,y=x.length;u<y;u++){w=x[u];w.submit(w.element,this.annotation)}this.publish("save",[this.annotation]);return this.hide()};t.prototype.addField=function(v){var w,x,u;x=h.extend({id:"annotator-field-"+(new Date()).getTime(),type:"input",label:"",load:function(){},submit:function(){}},v);u=null;w=h('<li class="annotator-item" />');x.element=w[0];switch(x.type){case"textarea":u=h("<textarea />");break;case"input":case"checkbox":u=h("<input />")}w.append(u);u.attr({id:x.id,placeholder:x.label});if(x.type==="checkbox"){u[0].type="checkbox";w.addClass("annotator-checkbox");w.append(h("<label />",{"for":x.id,html:x.label}))}this.element.find("ul:first").append(w);this.fields.push(x);return x.element};t.prototype.checkOrientation=function(){var u,w,v;t.__super__.checkOrientation.apply(this,arguments);v=this.element.find("ul");u=this.element.find(".annotator-controls");w=function(){return v.children().each(function(){return h(this).parent().prepend(this)})};if(this.element.hasClass(this.classes.invert.y)&&v.is(":first-child")){u.insertBefore(v);w()}else{if(u.is(":first-child")){u.insertAfter(v);w()}}return this};t.prototype.processKeypress=function(u){if(u.keyCode===27){return this.hide()}else{if(u.keyCode===13&&!u.shiftKey){return this.submit()}}};t.prototype.onCancelButtonMouseover=function(){return this.element.find("."+this.classes.focus).removeClass(this.classes.focus)};t.prototype.setupDragabbles=function(){var w,D,z,u,y,B,x,v,A,C;u=null;w=this.classes;z=this.element;A=null;v=z.find(".annotator-resize");D=z.find(".annotator-controls");C=false;y=function(E){if(E.target===this){u={element:this,top:E.pageY,left:E.pageX};A=z.find("textarea:first");h(window).bind({"mouseup.annotator-editor-resize":x,"mousemove.annotator-editor-resize":B});return E.preventDefault()}};x=function(){u=null;return h(window).unbind(".annotator-editor-resize")};B=g(function(I){var J,G,F,E,H;if(u&&C===false){J={top:I.pageY-u.top,left:I.pageX-u.left};if(u.element===v[0]){E=A.outerHeight();H=A.outerWidth();G=z.hasClass(w.invert.x)?-1:1;F=z.hasClass(w.invert.y)?1:-1;A.height(E+(J.top*F));A.width(H+(J.left*G));if(A.outerHeight()!==E){u.top=I.pageY}if(A.outerWidth()!==H){u.left=I.pageX}}else{if(u.element===D[0]){z.css({top:parseInt(z.css("top"),10)+J.top,left:parseInt(z.css("left"),10)+J.left});u.top=I.pageY;u.left=I.pageX}}C=true;return setTimeout(function(){return C=false},1000/60)}},this);v.bind("mousedown",y);return D.bind("mousedown",y)};return t})();o.Viewer=(function(){q(t,o.Widget);t.prototype.events={".annotator-edit click":"onEditClick",".annotator-delete click":"onDeleteClick"};t.prototype.classes={hide:"annotator-hide",showControls:"annotator-visible"};t.prototype.html={element:'<div class="annotator-outer annotator-viewer">\n <ul class="annotator-widget annotator-listing"></ul>\n</div>',item:'<li class="annotator-annotation annotator-item">\n <span class="annotator-controls">\n <button class="annotator-edit">Edit</button>\n <button class="annotator-delete">Delete</button>\n </span>\n</li>'};function t(u){this.onDeleteClick=g(this.onDeleteClick,this);this.onEditClick=g(this.onEditClick,this);this.load=g(this.load,this);this.hide=g(this.hide,this);this.show=g(this.show,this);t.__super__.constructor.call(this,h(this.html.element)[0],u);this.item=h(this.html.item)[0];this.fields=[];this.annotations=[]}t.prototype.show=function(v){var u;if(v!=null){v.preventDefault()}u=this.element.find(".annotator-controls").addClass(this.classes.showControls);setTimeout((g(function(){return u.removeClass(this.classes.showControls)},this)),500);this.element.removeClass(this.classes.hide);return this.checkOrientation().publish("show")};t.prototype.isShown=function(){return !this.element.hasClass(this.classes.hide)};t.prototype.hide=function(u){if(u!=null){u.preventDefault()}this.element.addClass(this.classes.hide);return this.publish("hide")};t.prototype.load=function(C){var z,B,G,H,F,A,E,I,D,y,w,u,J,x,v;this.annotations=C||[];D=this.element.find("ul:first").empty();x=this.annotations;for(y=0,u=x.length;y<u;y++){z=x[y];I=h(this.item).clone().appendTo(D).data("annotation",z);G=I.find(".annotator-controls");F=G.find(".annotator-edit");H=G.find(".annotator-delete");B={showEdit:function(){return F.removeAttr("disabled")},hideEdit:function(){return F.attr("disabled","disabled")},showDelete:function(){return H.removeAttr("disabled")},hideDelete:function(){return H.attr("disabled","disabled")}};v=this.fields;for(w=0,J=v.length;w<J;w++){E=v[w];A=h(E.element).clone().appendTo(I)[0];E.load(A,z,B)}}this.publish("load",[this.annotations]);return this.show()};t.prototype.addField=function(u){var v;v=h.extend({load:function(){}},u);v.element=h("<div />")[0];this.fields.push(v);v.element;return this};t.prototype.onEditClick=function(u){return this.onButtonClick(u,"edit")};t.prototype.onDeleteClick=function(u){return this.onButtonClick(u,"delete")};t.prototype.onButtonClick=function(w,u){var v;v=h(w.target).parents(".annotator-annotation");return this.publish(u,[v.data("annotation")])};return t})();o=o||{};o.Notification=(function(){q(t,b);t.prototype.events={click:"hide"};t.prototype.options={html:"<div class='annotator-notice'></div>",classes:{show:"annotator-notice-show",info:"annotator-notice-info",success:"annotator-notice-success",error:"annotator-notice-error"}};function t(u){this.hide=g(this.hide,this);this.show=g(this.show,this);t.__super__.constructor.call(this,h(this.options.html).appendTo(document.body)[0],u)}t.prototype.show=function(v,u){if(u==null){u=o.Notification.INFO}h(this.element).addClass(this.options.classes.show).addClass(this.options.classes[u]).escape(v||"");setTimeout(this.hide,5000);return this};t.prototype.hide=function(){h(this.element).removeClass(this.options.classes.show);return this};return t})();o.Notification.INFO="show";o.Notification.SUCCESS="success";o.Notification.ERROR="error";h(function(){var t;t=new o.Notification;o.showNotification=t.show;return o.hideNotification=t.hide});o.Plugin.Tags=(function(){q(t,o.Plugin);function t(){this.setAnnotationTags=g(this.setAnnotationTags,this);this.updateField=g(this.updateField,this);t.__super__.constructor.apply(this,arguments)}t.prototype.field=null;t.prototype.input=null;t.prototype.pluginInit=function(){if(!o.supported()){return}this.field=this.annotator.editor.addField({label:"Add some tags here\u2026",load:this.updateField,submit:this.setAnnotationTags});this.annotator.viewer.addField({load:this.updateViewer});if(this.annotator.plugins.Filter){this.annotator.plugins.Filter.addFilter({label:"Tag",property:"tags",isFiltered:o.Plugin.Tags.filterCallback})}return this.input=h(this.field).find(":input")};t.prototype.parseTags=function(v){var u;v=h.trim(v);u=[];if(v){u=v.split(/\s+/)}return u};t.prototype.stringifyTags=function(u){return u.join(" ")};t.prototype.updateField=function(w,u){var v;v="";if(u.tags){v=this.stringifyTags(u.tags)}return this.input.val(v)};t.prototype.setAnnotationTags=function(v,u){return u.tags=this.parseTags(this.input.val())};t.prototype.updateViewer=function(v,u){v=h(v);if(u.tags&&h.isArray(u.tags)&&u.tags.length){return v.addClass("annotator-tags").html(function(){var w;return w=h.map(u.tags,function(x){return'<span class="annotator-tag">'+o.$.escape(x)+"</span>"}).join(" ")})}else{return v.remove()}};return t})();o.Plugin.Tags.filterCallback=function(z,B){var y,x,w,C,v,u,t,A;if(B==null){B=[]}w=0;x=[];if(z){x=z.split(/\s+/g);for(v=0,t=x.length;v<t;v++){y=x[v];if(B.length){for(u=0,A=B.length;u<A;u++){C=B[u];if(C.indexOf(y)!==-1){w+=1}}}}}return w===x.length};n=function(u){var y,t,x,v,w,z;v="([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";y=u.match(new RegExp(v));x=0;t=new Date(y[1],0,1);if(y[3]){t.setMonth(y[3]-1)}if(y[5]){t.setDate(y[5])}if(y[7]){t.setHours(y[7])}if(y[8]){t.setMinutes(y[8])}if(y[10]){t.setSeconds(y[10])}if(y[12]){t.setMilliseconds(Number("0."+y[12])*1000)}if(y[14]){x=(Number(y[16])*60)+Number(y[17]);x*=(z=y[15]==="-")!=null?z:{1:-1}}x-=t.getTimezoneOffset();w=Number(t)+(x*60*1000);t.setTime(Number(w));return t};o.Plugin.Auth=(function(){q(t,o.Plugin);t.prototype.options={token:null,tokenUrl:"/auth/token",autoFetch:true};function t(v,u){this.haveValidToken=g(this.haveValidToken,this);t.__super__.constructor.apply(this,arguments);this.element.data("annotator:auth",this);this.waitingForToken=[];if(this.options.token){this.setToken(this.options.token)}else{this.requestToken()}}t.prototype.requestToken=function(){this.requestInProgress=true;return h.getJSON(this.options.tokenUrl,g(function(v,u,w){if(u!=="success"){return console.error("Couldn't get auth token: "+u,w)}else{this.setToken(v);return this.requestInProgress=false}},this))};t.prototype.setToken=function(v){var u;this.token=v;if(this.haveValidToken()){if(this.options.autoFetch){this.refreshTimeout=setTimeout((g(function(){return this.requestToken()},this)),(this.timeToExpiry()-2)*1000)}this.updateHeaders();u=[];while(this.waitingForToken.length>0){u.push(this.waitingForToken.pop().apply())}return u}else{console.warn("Didn't get a valid token.");if(this.options.autoFetch){console.warn("Getting a new token in 10s.");return setTimeout((g(function(){return this.requestToken()},this)),10*1000)}}};t.prototype.haveValidToken=function(){var u;u=this.token&&this.token.authToken&&this.token.authTokenIssueTime&&this.token.authTokenTTL&&this.token.accountId&&this.token.userId;return u&&this.timeToExpiry()>0};t.prototype.timeToExpiry=function(){var w,u,v,x;v=new Date().getTime()/1000;u=n(this.token.authTokenIssueTime).getTime()/1000;w=u+this.token.authTokenTTL;x=w-v;if(x>0){return x}else{return 0}};t.prototype.updateHeaders=function(){var u;u=this.element.data("annotator:headers");return this.element.data("annotator:headers",h.extend(u,{"x-annotator-auth-token":this.token.authToken,"x-annotator-auth-token-issue-time":this.token.authTokenIssueTime,"x-annotator-auth-token-ttl":this.token.authTokenTTL,"x-annotator-account-id":this.token.accountId,"x-annotator-user-id":this.token.userId}))};t.prototype.withToken=function(u){if(!(u!=null)){return}if(this.haveValidToken()){return u()}else{this.waitingForToken.push(u);if(!this.requestInProgress){return this.requestToken()}}};return t})();o.Plugin.Store=(function(){q(t,o.Plugin);t.prototype.events={annotationCreated:"annotationCreated",annotationDeleted:"annotationDeleted",annotationUpdated:"annotationUpdated"};t.prototype.options={prefix:"/store",autoFetch:true,annotationData:{},loadFromSearch:false,urls:{create:"/annotations",read:"/annotations/:id",update:"/annotations/:id",destroy:"/annotations/:id",search:"/search"}};function t(v,u){this._onError=g(this._onError,this);this._onBeforeSend=g(this._onBeforeSend,this);this._onLoadAnnotationsFromSearch=g(this._onLoadAnnotationsFromSearch,this);this._onLoadAnnotations=g(this._onLoadAnnotations,this);this._getAnnotations=g(this._getAnnotations,this);t.__super__.constructor.apply(this,arguments);this.annotations=[]}t.prototype.pluginInit=function(){var u;if(!o.supported()){return}u=this.element.data("annotator:auth");if(u){return u.withToken(this._getAnnotations)}else{return this._getAnnotations()}};t.prototype._getAnnotations=function(){if(this.options.loadFromSearch){return this.loadAnnotationsFromSearch(this.options.loadFromSearch)}else{return this.loadAnnotations()}};t.prototype.annotationCreated=function(u){if(f.call(this.annotations,u)<0){this.registerAnnotation(u);return this._apiRequest("create",u,g(function(v){if(!(v.id!=null)){console.warn("Warning: No ID returned from server for annotation ",u)}return this.updateAnnotation(u,v)},this))}else{return this.updateAnnotation(u,{})}};t.prototype.annotationUpdated=function(u){if(f.call(this.annotations,u)>=0){return this._apiRequest("update",u,(g(function(v){return this.updateAnnotation(u,v)},this)))}};t.prototype.annotationDeleted=function(u){if(f.call(this.annotations,u)>=0){return this._apiRequest("destroy",u,(g(function(){return this.unregisterAnnotation(u)},this)))}};t.prototype.registerAnnotation=function(u){return this.annotations.push(u)};t.prototype.unregisterAnnotation=function(u){return this.annotations.splice(this.annotations.indexOf(u),1)};t.prototype.updateAnnotation=function(u,v){if(f.call(this.annotations,u)<0){console.error("Trying to update unregistered annotation!")}else{h.extend(u,v)}return h(u.highlights).data("annotation",u)};t.prototype.loadAnnotations=function(){return this._apiRequest("read",null,this._onLoadAnnotations)};t.prototype._onLoadAnnotations=function(u){if(u==null){u=[]}this.annotations=u;return this.annotator.loadAnnotations(u.slice())};t.prototype.loadAnnotationsFromSearch=function(u){return this._apiRequest("search",u,this._onLoadAnnotationsFromSearch)};t.prototype._onLoadAnnotationsFromSearch=function(u){if(u==null){u={}}return this._onLoadAnnotations(u.rows||[])};t.prototype.dumpAnnotations=function(){var w,v,y,x,u;x=this.annotations;u=[];for(v=0,y=x.length;v<y;v++){w=x[v];u.push(JSON.parse(this._dataFor(w)))}return u};t.prototype._apiRequest=function(x,y,z){var A,v,w,u;A=y&&y.id;u=this._urlFor(x,A);v=this._apiRequestOptions(x,y,z);w=h.ajax(u,v);w._id=A;w._action=x;return w};t.prototype._apiRequestOptions=function(v,w,x){var u;u={type:this._methodFor(v),beforeSend:this._onBeforeSend,dataType:"json",success:x||function(){},error:this._onError};if(v==="search"){u=h.extend(u,{data:w})}else{u=h.extend(u,{data:w&&this._dataFor(w),contentType:"application/json; charset=utf-8"})}return u};t.prototype._urlFor=function(w,x){var u,v;u=x!=null?"/"+x:"";v=this.options.prefix||"/";v+=this.options.urls[w];v=v.replace(/\/:id/,u);return v};t.prototype._methodFor=function(v){var u;u={create:"POST",read:"GET",update:"PUT",destroy:"DELETE",search:"GET"};return u[v]};t.prototype._dataFor=function(u){var v,w;w=u.highlights;delete u.highlights;h.extend(u,this.options.annotationData);v=JSON.stringify(u);if(w){u.highlights=w}return v};t.prototype._onBeforeSend=function(y){var x,v,w,u;x=this.element.data("annotator:headers");if(x){u=[];for(v in x){w=x[v];u.push(y.setRequestHeader(v,w))}return u}};t.prototype._onError=function(w){var v,u;v=w._action;u="Sorry we could not "+v+" this annotation";if(w._action==="search"){u="Sorry we could not search the store for annotations"}else{if(w._action==="read"&&!w._id){u="Sorry we could not "+v+" the annotations from the store"}}switch(w.status){case 401:u="Sorry you are not allowed to "+v+" this annotation";break;case 404:u="Sorry we could not connect to the annotations store";break;case 500:u="Sorry something went wrong with the annotation store"}o.showNotification(u,o.Notification.ERROR);return console.error("API request failed: '"+w.status+"'")};return t})();o.Plugin.Filter=(function(){q(t,o.Plugin);t.prototype.events={".annotator-filter-property input focus":"_onFilterFocus",".annotator-filter-property input blur":"_onFilterBlur",".annotator-filter-property input keyup":"_onFilterKeyup",".annotator-filter-previous click":"_onPreviousClick",".annotator-filter-next click":"_onNextClick",".annotator-filter-clear click":"_onClearClick"};t.prototype.classes={active:"annotator-filter-active",hl:{hide:"annotator-hl-filtered",active:"annotator-hl-active"}};t.prototype.html={element:'<div class="annotator-filter">\n <strong>Navigate:</strong>\n <span class="annotator-filter-navigation">\n <button class="annotator-filter-previous">Previous</button>\n <button class="annotator-filter-next">Next</button>\n </span>\n <strong>Filter by:</strong>\n</div>',filter:'<span class="annotator-filter-property">\n <label></label>\n <input/>\n <button class="annotator-filter-clear">Clear</button>\n</span>'};t.prototype.options={appendTo:"body",filters:[],addAnnotationFilter:true,isFiltered:function(v,x){var u,w,z,y;if(!(v&&x)){return false}y=v.split(/\s*/);for(w=0,z=y.length;w<z;w++){u=y[w];if(x.indexOf(u)===-1){return false}}return true}};function t(v,u){this._onPreviousClick=g(this._onPreviousClick,this);this._onNextClick=g(this._onNextClick,this);this._onFilterKeyup=g(this._onFilterKeyup,this);this._onFilterBlur=g(this._onFilterBlur,this);this._onFilterFocus=g(this._onFilterFocus,this);this.updateHighlights=g(this.updateHighlights,this);v=h(this.html.element).appendTo(this.options.appendTo);t.__super__.constructor.call(this,v,u);this.filter=h(this.html.filter);this.filters=[];this.current=0}t.prototype.pluginInit=function(){var v,u,x,w;w=this.options.filters;for(u=0,x=w.length;u<x;u++){v=w[u];this.addFilter(v)}this.updateHighlights();this._setupListeners()._insertSpacer();if(this.options.addAnnotationFilter===true){return this.addFilter({label:"Annotation",property:"text"})}};t.prototype._insertSpacer=function(){var v,u;u=h("html");v=parseInt(u.css("padding-top"),10)||0;u.css("padding-top",v+this.element.outerHeight());return this};t.prototype._setupListeners=function(){var w,u,v,x;u=["annotationsLoaded","annotationCreated","annotationUpdated","annotationDeleted"];for(v=0,x=u.length;v<x;v++){w=u[v];this.annotator.subscribe(w,this.updateHighlights)}return this};t.prototype.addFilter=function(u){var w,v;v=h.extend({label:"",property:"",isFiltered:this.options.isFiltered},u);if(!((function(){var y,A,z,x;z=this.filters;x=[];for(y=0,A=z.length;y<A;y++){w=z[y];if(w.property===v.property){x.push(w)}}return x}).call(this)).length){v.id="annotator-filter-"+v.property;v.annotations=[];v.element=this.filter.clone().appendTo(this.element);v.element.find("label").html(v.label).attr("for",v.id);v.element.find("input").attr({id:v.id,placeholder:"Filter by "+v.label+"\u2026"});v.element.find("button").hide();v.element.data("filter",v);this.filters.push(v)}return this};t.prototype.updateFilter=function(x){var u,z,v,y,w,B,A;x.annotations=[];this.updateHighlights();this.resetHighlights();v=h.trim(x.element.find("input").val());if(v){z=this.highlights.map(function(){return h(this).data("annotation")});A=h.makeArray(z);for(w=0,B=A.length;w<B;w++){u=A[w];y=u[x.property];if(x.isFiltered(v,y)){x.annotations.push(u)}}return this.filterHighlights()}};t.prototype.updateHighlights=function(){this.highlights=this.annotator.element.find(".annotator-hl:visible");return this.filtered=this.highlights.not(this.classes.hl.hide)};t.prototype.filterHighlights=function(){var v,x,y,B,z,A,C,u,w;v=h.grep(this.filters,function(D){return !!D.annotations.length});B=((w=v[0])!=null?w.annotations:void 0)||[];if(v.length>1){y=[];h.each(v,function(){return h.merge(y,this.annotations)});C=[];B=[];h.each(y,function(){if(h.inArray(this,C)===-1){return C.push(this)}else{return B.push(this)}})}z=this.highlights;for(A=0,u=B.length;A<u;A++){x=B[A];z=z.not(x.highlights)}z.addClass(this.classes.hl.hide);this.filtered=this.highlights.not(this.classes.hl.hide);return this};t.prototype.resetHighlights=function(){this.highlights.removeClass(this.classes.hl.hide);this.filtered=this.highlights;return this};t.prototype._onFilterFocus=function(v){var u;u=h(v.target);u.parent().addClass(this.classes.active);return u.next("button").show()};t.prototype._onFilterBlur=function(v){var u;if(!v.target.value){u=h(v.target);u.parent().removeClass(this.classes.active);return u.next("button").hide()}};t.prototype._onFilterKeyup=function(v){var u;u=h(v.target).parent().data("filter");if(u){return this.updateFilter(u)}};t.prototype._findNextHighlight=function(z){var v,w,B,A,y,x,u,C;if(!this.highlights.length){return this}x=z?0:-1;C=z?-1:0;u=z?"lt":"gt";v=this.highlights.not("."+this.classes.hl.hide);B=v.filter("."+this.classes.hl.active);if(!B.length){B=v.eq(x)}w=B.data("annotation");A=v.index(B[0]);y=v.filter(":"+u+"("+A+")").not(w.highlights).eq(C);if(!y.length){y=v.eq(C)}return this._scrollToHighlight(y.data("annotation").highlights)};t.prototype._onNextClick=function(u){return this._findNextHighlight()};t.prototype._onPreviousClick=function(u){return this._findNextHighlight(true)};t.prototype._scrollToHighlight=function(u){u=h(u);this.highlights.removeClass(this.classes.hl.active);u.addClass(this.classes.hl.active);return h("html, body").animate({scrollTop:u.offset().top-(this.element.height()+20)},150)};t.prototype._onClearClick=function(u){return h(u.target).prev("input").val("").keyup().blur()};return t})();o.Plugin.Markdown=(function(){q(t,o.Plugin);t.prototype.events={annotationViewerTextField:"updateTextField"};function t(v,u){this.updateTextField=g(this.updateTextField,this);if((typeof Showdown!=="undefined"&&Showdown!==null?Showdown.converter:void 0)!=null){t.__super__.constructor.apply(this,arguments);this.converter=new Showdown.converter()}else{console.error("To use the Markdown plugin, you must include Showdown into the page first.")}}t.prototype.updateTextField=function(v,u){var w;w=o.$.escape(u.text||"");return h(v).html(this.convert(w))};t.prototype.convert=function(u){return this.converter.makeHtml(u)};return t})();o.Plugin.Unsupported=(function(){q(t,o.Plugin);function t(){t.__super__.constructor.apply(this,arguments)}t.prototype.options={message:"Sorry your current browser does not support the Annotator"};t.prototype.pluginInit=function(){if(!o.supported()){return h(g(function(){o.showNotification(this.options.message);if((window.XMLHttpRequest===void 0)&&(ActiveXObject!==void 0)){return h("html").addClass("ie6")}},this))}};return t})();o.Plugin.Permissions=(function(){q(t,o.Plugin);t.prototype.events={beforeAnnotationCreated:"addFieldsToAnnotation"};t.prototype.options={showViewPermissionsCheckbox:true,showEditPermissionsCheckbox:true,userId:function(u){return u},userString:function(u){return u},userAuthorize:function(u,v){return this.userId(u)===v},user:"",permissions:{read:[],update:[],"delete":[],admin:[]}};function t(v,u){this.updateViewer=g(this.updateViewer,this);this.updateAnnotationPermissions=g(this.updateAnnotationPermissions,this);this.updatePermissionsField=g(this.updatePermissionsField,this);this.addFieldsToAnnotation=g(this.addFieldsToAnnotation,this);t.__super__.constructor.apply(this,arguments);if(this.options.user){this.setUser(this.options.user);delete this.options.user}}t.prototype.pluginInit=function(){var u,v;if(!o.supported()){return}v=this;u=function(x,w){return function(z,y){return v[x].call(v,w,z,y)}};if(this.options.showViewPermissionsCheckbox===true){this.annotator.editor.addField({type:"checkbox",label:"Allow anyone to <strong>view</strong> this annotation",load:u("updatePermissionsField","read"),submit:u("updateAnnotationPermissions","read")})}if(this.options.showEditPermissionsCheckbox===true){this.annotator.editor.addField({type:"checkbox",label:"Allow anyone to <strong>edit</strong> this annotation",load:u("updatePermissionsField","update"),submit:u("updateAnnotationPermissions","update")})}this.annotator.viewer.addField({load:this.updateViewer});if(this.annotator.plugins.Filter){return this.annotator.plugins.Filter.addFilter({label:"User",property:"user",isFiltered:g(function(y,x){var w,z,B,A;x=this.options.userString(x);if(!(y&&x)){return false}A=y.split(/\s*/);for(z=0,B=A.length;z<B;z++){w=A[z];if(x.indexOf(w)===-1){return false}}return true},this)})}};t.prototype.setUser=function(u){return this.user=u};t.prototype.addFieldsToAnnotation=function(u){if(u){u.permissions=this.options.permissions;if(this.user){return u.user=this.user}}};t.prototype.authorize=function(y,u,v){var w,z,x,A;if(v===void 0){v=this.user}if(u.permissions){z=u.permissions[y]||[];if(z.length===0){return true}for(x=0,A=z.length;x<A;x++){w=z[x];if(this.options.userAuthorize.call(this.options,v,w)){return true}}return false}else{if(u.user){return v&&this.options.userId(v)===u.user}}return true};t.prototype.updatePermissionsField=function(w,y,u){var x,v;y=h(y).show();v=y.find("input").removeAttr("disabled");if(!this.authorize("admin",u)){y.hide()}if(this.authorize(w,u||{},null)){v.attr("checked","checked");x={permissions:this.options.permissions};if(this.authorize(w,x,null)){return v.attr("disabled","disabled")}}else{return v.removeAttr("checked")}};t.prototype.updateAnnotationPermissions=function(w,x,u){var y,v;if(!u.permissions){u.permissions=this.options.permissions}y=w+"-permissions";if(h(x).find("input").is(":checked")){h.data(u,y,u.permissions[w]);return u.permissions[w]=[]}else{v=h.data(u,y);if(v){return u.permissions[w]=v}}};t.prototype.updateViewer=function(x,u,w){var v,y;x=h(x);y=this.options.userString(u.user);if(u.user&&y&&typeof y==="string"){v=o.$.escape(this.options.userString(u.user));x.html(v).addClass("annotator-user")}else{x.remove()}if(u.permissions){if(!this.authorize("update",u)){w.hideEdit()}if(!this.authorize("delete",u)){return w.hideDelete()}}else{if(u.user&&!this.authorize(null,u)){w.hideEdit();return w.hideDelete()}}};return t})();o.prototype.setupPlugins=function(w,E){var B,D,u,t,y,v,A,C,z,x;if(w==null){w={}}if(E==null){E={}}z=a.getGlobal();y={Tags:{},Filter:{filters:[{label:"User",property:"user"},{label:"Tags",property:"tags"}]},Unsupported:{}};if(z.Showdown){y.Markdown={}}A=w.userId,C=w.userName,B=w.accountId,D=w.authToken;if(A&&C&&B&&D){v=z.location.href.split(/#|\?/).shift()||"";h.extend(y,{Store:{prefix:w.storeUri||"http://annotateit.org/api",annotationData:{uri:v},loadFromSearch:{uri:v,all_fields:1}},Permissions:{user:{id:w.userId,name:w.userName},permissions:{read:[w.userId],update:[w.userId],"delete":[w.userId],admin:[w.userId]},userId:function(F){if(F!=null?F.id:void 0){return F.id}else{return""}},userString:function(F){if(F!=null?F.name:void 0){return F.name}else{return""}}}});this.element.data({"annotator:headers":{"X-Annotator-User-Id":w.userId,"X-Annotator-Account-Id":w.accountId,"X-Annotator-Auth-Token":w.authToken}})}h.extend(y,E);x=[];for(u in y){if(!k.call(y,u)){continue}t=y[u];if(t!==null&&t!==false){x.push(this.addPlugin(u,t))}}return x}}).call(this); 1 (function () { 2 var h, o, b, p, n, i, l, a, e, d, c, r, s, j; 3 var m = Array.prototype.slice, 4 g = function (t, u) { 5 return function () { 6 return t.apply(u, arguments) 7 } 8 }, 9 k = Object.prototype.hasOwnProperty, 10 q = function (w, u) { 11 for (var t in u) { 12 if (k.call(u, t)) { 13 w[t] = u[t] 14 } 15 } 16 function v() { 17 this.constructor = w 18 } 19 v.prototype = u.prototype; 20 w.prototype = new v; 21 w.__super__ = u.prototype; 22 return w 23 }, 24 f = Array.prototype.indexOf || 25 function (v) { 26 for (var u = 0, t = this.length; u < t; u++) { 27 if (this[u] === v) { 28 return u 29 } 30 } 31 return -1 32 }; 33 if (!(typeof jQuery !== "undefined" && jQuery !== null ? (j = jQuery.fn) != null ? j.jquery : void 0 : void 0)) { 34 console.error("Annotator requires jQuery: have you included lib/vendor/jquery.js?") 35 } 36 if (!(JSON && JSON.parse && JSON.stringify)) { 37 console.error("Annotator requires a JSON implementation: have you included lib/vendor/json2.js?") 38 } 39 h = jQuery.sub(); 40 h.flatten = function (u) { 41 var t; 42 t = function (w) { 43 var x, z, y, v; 44 z = []; 45 for (y = 0, v = w.length; y < v; y++) { 46 x = w[y]; 47 z = z.concat(x && h.isArray(x) ? t(x) : x) 48 } 49 return z 50 }; 51 return t(u) 52 }; 53 h.plugin = function (u, t) { 54 return jQuery.fn[u] = function (w) { 55 var v; 56 v = Array.prototype.slice.call(arguments, 1); 57 return this.each(function () { 58 var x; 59 x = h.data(this, u); 60 if (x) { 61 return w && x[w].apply(x, v) 62 } else { 63 x = new t(this, w); 64 return h.data(this, u, x) 65 } 66 }) 67 } 68 }; 69 h.fn.textNodes = function () { 70 var t; 71 t = function (v) { 72 var u; 73 if (v && v.nodeType !== 3) { 74 u = []; 75 if (v.nodeType !== 8) { 76 v = v.lastChild; 77 while (v) { 78 u.push(t(v)); 79 v = v.previousSibling 80 } 81 } 82 return u.reverse() 83 } else { 84 return v 85 } 86 }; 87 return this.map(function () { 88 return h.flatten(t(this)) 89 }) 90 }; 91 h.fn.xpath = function (t) { 92 var u; 93 u = this.map(function () { 94 var w, v, x; 95 x = ""; 96 w = this; 97 while (w && w.nodeType === 1 && w !== t) { 98 v = h(w.parentNode).children(w.tagName).index(w) + 1; 99 v = v > 1 ? "[" + v + "]" : ""; 100 x = "/" + w.tagName.toLowerCase() + v + x; 101 w = w.parentNode 102 } 103 return x 104 }); 105 return u.get() 106 }; 107 h.escape = function (t) { 108 return t.replace(/&(?!\w+;)/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """) 109 }; 110 h.fn.escape = function (t) { 111 if (arguments.length) { 112 return this.html(h.escape(t)) 113 } 114 return this.html() 115 }; 116 l = ["log", "debug", "info", "warn", "exception", "assert", "dir", "dirxml", "trace", "group", "groupEnd", "groupCollapsed", "time", "timeEnd", "profile", "profileEnd", "count", "clear", "table", "error", "notifyFirebug", "firebug", "userObjects"]; 117 if (typeof console !== "undefined" && console !== null) { 118 if (!(console.group != null)) { 119 console.group = function (t) { 120 return console.log("GROUP: ", t) 121 } 122 } 123 if (!(console.groupCollapsed != null)) { 124 console.groupCollapsed = console.group 125 } 126 for (d = 0, r = l.length; d < r; d++) { 127 i = l[d]; 128 if (!(console[i] != null)) { 129 console[i] = function () { 130 return console.log("Not implemented: console." + name) 131 } 132 } 133 } 134 } else { 135 this.console = {}; 136 for (c = 0, s = l.length; c < s; c++) { 137 i = l[c]; 138 this.console[i] = function () {} 139 } 140 this.console.error = function () { 141 var t; 142 t = 1 <= arguments.length ? m.call(arguments, 0) : []; 143 return alert("ERROR: " + (t.join(", "))) 144 }; 145 this.console.warn = function () { 146 var t; 147 t = 1 <= arguments.length ? m.call(arguments, 0) : []; 148 return alert("WARNING: " + (t.join(", "))) 149 } 150 } 151 b = (function () { 152 t.prototype.events = {}; 153 t.prototype.options = {}; 154 t.prototype.element = null; 155 156 function t(v, u) { 157 this.options = h.extend(true, {}, this.options, u); 158 this.element = h(v); 159 this.on = this.subscribe; 160 this.addEvents() 161 } 162 t.prototype.addEvents = function () { 163 var x, z, y, u, w, B, A, v; 164 B = this.events; 165 v = []; 166 for (y in B) { 167 z = B[y]; 168 A = y.split(" "), u = 2 <= A.length ? m.call(A, 0, w = A.length - 1) : (w = 0, []), x = A[w++]; 169 v.push(this.addEvent(u.join(" "), x, z)) 170 } 171 return v 172 }; 173 t.prototype.addEvent = function (u, w, x) { 174 var y, v; 175 y = g(function () { 176 return this[x].apply(this, arguments) 177 }, this); 178 v = typeof u === "string" && u.replace(/\s+/g, "") === ""; 179 if (v) { 180 u = this.element 181 } 182 if (typeof u === "string") { 183 this.element.delegate(u, w, y) 184 } else { 185 if (this.isCustomEvent(w)) { 186 this.subscribe(w, y) 187 } else { 188 h(u).bind(w, y) 189 } 190 } 191 return this 192 }; 193 t.prototype.isCustomEvent = function (v) { 194 var u; 195 u = "blur focus focusin focusout load resize scroll unload click dblclick\nmousedown mouseup mousemove mouseover mouseout mouseenter mouseleave\nchange select submit keydown keypress keyup error".split(/[^a-z]+/); 196 v = v.split(".")[0]; 197 return h.inArray(v, u) === -1 198 }; 199 t.prototype.publish = function () { 200 this.element.triggerHandler.apply(this.element, arguments); 201 return this 202 }; 203 t.prototype.subscribe = function (u, w) { 204 var v; 205 v = function () { 206 return w.apply(this, [].slice.call(arguments, 1)) 207 }; 208 v.guid = w.guid = (h.guid += 1); 209 this.element.bind(u, v); 210 return this 211 }; 212 t.prototype.unsubscribe = function () { 213 this.element.unbind.apply(this.element, arguments); 214 return this 215 }; 216 return t 217 })(); 218 p = {}; 219 p.sniff = function (t) { 220 if (t.commonAncestorContainer != null) { 221 return new p.BrowserRange(t) 222 } else { 223 if (typeof t.start === "string") { 224 return new p.SerializedRange(t) 225 } else { 226 if (t.start && typeof t.start === "object") { 227 return new p.NormalizedRange(t) 228 } else { 229 console.error("Couldn't not sniff range type"); 230 return false 231 } 232 } 233 } 234 }; 235 p.BrowserRange = (function () { 236 function t(u) { 237 this.commonAncestorContainer = u.commonAncestorContainer; 238 this.startContainer = u.startContainer; 239 this.startOffset = u.startOffset; 240 this.endContainer = u.endContainer; 241 this.endOffset = u.endOffset 242 } 243 t.prototype.normalize = function (C) { 244 var B, x, D, A, w, v, z, u, y; 245 if (this.tainted) { 246 console.error("You may only call normalize() once on a BrowserRange!"); 247 return false 248 } else { 249 this.tainted = true 250 } 251 v = {}; 252 D = {}; 253 y = ["start", "end"]; 254 for (z = 0, u = y.length; z < u; z++) { 255 w = y[z]; 256 x = this[w + "Container"]; 257 A = this[w + "Offset"]; 258 if (x.nodeType === 1) { 259 B = x.childNodes[A]; 260 x = B || x.childNodes[A - 1]; 261 while (x.nodeType !== 3) { 262 x = x.firstChild 263 } 264 A = B ? 0 : x.nodeValue.length 265 } 266 v[w] = x; 267 v[w + "Offset"] = A 268 } 269 D.start = v.startOffset > 0 ? v.start.splitText(v.startOffset) : v.start; 270 if (v.start === v.end) { 271 if ((v.endOffset - v.startOffset) < D.start.nodeValue.length) { 272 D.start.splitText(v.endOffset - v.startOffset) 273 } 274 D.end = D.start 275 } else { 276 if (v.endOffset < v.end.nodeValue.length) { 277 v.end.splitText(v.endOffset) 278 } 279 D.end = v.end 280 } 281 D.commonAncestor = this.commonAncestorContainer; 282 while (D.commonAncestor.nodeType !== 1) { 283 D.commonAncestor = D.commonAncestor.parentNode 284 } 285 return new p.NormalizedRange(D) 286 }; 287 t.prototype.serialize = function (u, v) { 288 return this.normalize(u).serialize(u, v) 289 }; 290 return t 291 })(); 292 p.NormalizedRange = (function () { 293 function t(u) { 294 this.commonAncestor = u.commonAncestor; 295 this.start = u.start; 296 this.end = u.end 297 } 298 t.prototype.normalize = function (u) { 299 return this 300 }; 301 t.prototype.limit = function (y) { 302 var u, x, v, w, A, z; 303 u = h.grep(this.textNodes(), function (B) { 304 return B.parentNode === y || h.contains(y, B.parentNode) 305 }); 306 if (!u.length) { 307 return null 308 } 309 this.start = u[0]; 310 this.end = u[u.length - 1]; 311 v = h(this.start).parents(); 312 z = h(this.end).parents(); 313 for (w = 0, A = z.length; w < A; w++) { 314 x = z[w]; 315 if (v.index(x) !== -1) { 316 this.commonAncestor = x; 317 break 318 } 319 } 320 return this 321 }; 322 t.prototype.serialize = function (w, x) { 323 var v, u, y; 324 u = function (D, C) { 325 var B, A, F, I, H, G, E, z; 326 if (x) { 327 I = h(D).parents(":not(" + x + ")").eq(0) 328 } else { 329 I = h(D).parent() 330 } 331 G = I.xpath(w)[0]; 332 H = I.textNodes(); 333 A = H.slice(0, H.index(D)); 334 F = 0; 335 for (E = 0, z = A.length; E < z; E++) { 336 B = A[E]; 337 F += B.nodeValue.length 338 } 339 if (C) { 340 return [G, F + D.nodeValue.length] 341 } else { 342 return [G, F] 343 } 344 }; 345 y = u(this.start); 346 v = u(this.end, true); 347 return new p.SerializedRange({ 348 start: y[0], 349 end: v[0], 350 startOffset: y[1], 351 endOffset: v[1] 352 }) 353 }; 354 t.prototype.text = function () { 355 var u; 356 return ((function () { 357 var w, y, x, v; 358 x = this.textNodes(); 359 v = []; 360 for (w = 0, y = x.length; w < y; w++) { 361 u = x[w]; 362 v.push(u.nodeValue) 363 } 364 return v 365 }).call(this)).join("") 366 }; 367 t.prototype.textNodes = function () { 368 var u, x, v, w; 369 v = h(this.commonAncestor).textNodes(); 370 w = [v.index(this.start), v.index(this.end)], x = w[0], u = w[1]; 371 return h.makeArray(v.slice(x, (u + 1) || 9000000000)) 372 }; 373 return t 374 })(); 375 p.SerializedRange = (function () { 376 function t(u) { 377 this.start = u.start; 378 this.startOffset = u.startOffset; 379 this.end = u.end; 380 this.endOffset = u.endOffset 381 } 382 t.prototype._nodeFromXPath = function (u) { 383 var z, y, v, x, w; 384 y = function (B, A) { 385 if (A == null) { 386 A = null 387 } 388 return document.evaluate(B, document, A, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue 389 }; 390 if (!h.isXMLDoc(document.documentElement)) { 391 return y(u) 392 } else { 393 z = document.createNSResolver(document.ownerDocument === null ? document.documentElement : document.ownerDocument.documentElement); 394 x = y(u, z); 395 if (!x) { 396 u = ((function () { 397 var B, D, C, A; 398 C = u.split("/"); 399 A = []; 400 for (B = 0, D = C.length; B < D; B++) { 401 w = C[B]; 402 A.push(w && w.indexOf(":") === -1 ? w.replace(/^([a-z]+)/, "xhtml:$1") : w) 403 } 404 return A 405 })()).join("/"); 406 v = document.lookupNamespaceURI(null); 407 z = function (A) { 408 if (A === "xhtml") { 409 return v 410 } else { 411 return document.documentElement.getAttribute("xmlns:" + A) 412 } 413 }; 414 x = y(u, z) 415 } 416 return x 417 } 418 }; 419 t.prototype.normalize = function (G) { 420 var K, D, C, I, A, F, H, E, B, z, v, u, L, J, y, x, w; 421 H = h(G).xpath()[0]; 422 B = this.start.split("/"); 423 C = this.end.split("/"); 424 D = []; 425 E = {}; 426 for (I = 0, y = B.length; 0 <= y ? I < y : I > y; 0 <= y ? I++ : I--) { 427 if (B[I] === C[I]) { 428 D.push(B[I]) 429 } else { 430 break 431 } 432 } 433 K = H + D.join("/"); 434 E.commonAncestorContainer = this._nodeFromXPath(K); 435 if (!E.commonAncestorContainer) { 436 console.error("Error deserializing range: can't find XPath '" + K + "'. Is this the right document?"); 437 return null 438 } 439 x = ["start", "end"]; 440 for (v = 0, L = x.length; v < L; v++) { 441 F = x[v]; 442 A = 0; 443 w = h(this._nodeFromXPath(H + this[F])).textNodes(); 444 for (u = 0, J = w.length; u < J; u++) { 445 z = w[u]; 446 if (A + z.nodeValue.length >= this[F + "Offset"]) { 447 E[F + "Container"] = z; 448 E[F + "Offset"] = this[F + "Offset"] - A; 449 break 450 } else { 451 A += z.nodeValue.length 452 } 453 } 454 } 455 return new p.BrowserRange(E).normalize(G) 456 }; 457 t.prototype.serialize = function (u, v) { 458 return this.normalize(u).serialize(u, v) 459 }; 460 t.prototype.toObject = function () { 461 return { 462 start: this.start, 463 startOffset: this.startOffset, 464 end: this.end, 465 endOffset: this.endOffset 466 } 467 }; 468 return t 469 })(); 470 a = { 471 getGlobal: function () { 472 return (function () { 473 return this 474 })() 475 }, 476 mousePosition: function (t, v) { 477 var u; 478 u = h(v).offset(); 479 return { 480 top: t.pageY - u.top, 481 left: t.pageX - u.left 482 } 483 } 484 }; 485 e = this.Annotator; 486 o = (function () { 487 q(t, b); 488 t.prototype.events = { 489 ".annotator-adder button click": "onAdderClick", 490 ".annotator-adder button mousedown": "onAdderMousedown", 491 ".annotator-hl mouseover": "onHighlightMouseover", 492 ".annotator-hl mouseout": "startViewerHideTimer" 493 }; 494 t.prototype.html = { 495 hl: '<span class="annotator-hl"></span>', 496 adder: '<div class="annotator-adder"><button>Annotate</button></div>', 497 wrapper: '<div class="annotator-wrapper"></div>' 498 }; 499 t.prototype.options = {}; 500 t.prototype.plugins = {}; 501 t.prototype.editor = null; 502 t.prototype.viewer = null; 503 t.prototype.selectedRanges = null; 504 t.prototype.mouseIsDown = false; 505 t.prototype.ignoreMouseup = false; 506 t.prototype.viewerHideTimer = null; 507 508 function t(w, v) { 509 this.onDeleteAnnotation = g(this.onDeleteAnnotation, this); 510 this.onEditAnnotation = g(this.onEditAnnotation, this); 511 this.onAdderClick = g(this.onAdderClick, this); 512 this.onAdderMousedown = g(this.onAdderMousedown, this); 513 this.onHighlightMouseover = g(this.onHighlightMouseover, this); 514 this.checkForEndSelection = g(this.checkForEndSelection, this); 515 this.checkForStartSelection = g(this.checkForStartSelection, this); 516 this.clearViewerHideTimer = g(this.clearViewerHideTimer, this); 517 this.startViewerHideTimer = g(this.startViewerHideTimer, this); 518 this.showViewer = g(this.showViewer, this); 519 this.onEditorSubmit = g(this.onEditorSubmit, this); 520 this.onEditorHide = g(this.onEditorHide, this); 521 this.showEditor = g(this.showEditor, this); 522 var u, x, y; 523 t.__super__.constructor.apply(this, arguments); 524 this.plugins = {}; 525 if (!t.supported()) { 526 return this 527 } 528 this._setupDocumentEvents()._setupWrapper()._setupViewer()._setupEditor(); 529 y = this.html; 530 for (u in y) { 531 x = y[u]; 532 if (u !== "wrapper") { 533 this[u] = h(x).appendTo(this.wrapper).hide() 534 } 535 } 536 } 537 t.prototype._setupWrapper = function () { 538 this.wrapper = h(this.html.wrapper); 539 this.element.find("script").remove(); 540 this.element.wrapInner(this.wrapper); 541 this.wrapper = this.element.find(".annotator-wrapper"); 542 return this 543 }; 544 t.prototype._setupViewer = function () { 545 this.viewer = new t.Viewer(); 546 this.viewer.hide().on("edit", this.onEditAnnotation).on("delete", this.onDeleteAnnotation).addField({ 547 load: g(function (v, u) { 548 h(v).escape(u.text || ""); 549 return this.publish("annotationViewerTextField", [v, u]) 550 }, this) 551 }).element.appendTo(this.wrapper).bind({ 552 mouseover: this.clearViewerHideTimer, 553 mouseout: this.startViewerHideTimer 554 }); 555 return this 556 }; 557 t.prototype._setupEditor = function () { 558 this.editor = new t.Editor(); 559 this.editor.hide().on("hide", this.onEditorHide).on("save", this.onEditorSubmit).addField({ 560 type: "textarea", 561 label: "Comments\u2026", 562 load: function (v, u) { 563 return h(v).find("textarea").val(u.text || "") 564 }, 565 submit: function (v, u) { 566 return u.text = h(v).find("textarea").val() 567 } 568 }); 569 this.editor.element.appendTo(this.wrapper); 570 return this 571 }; 572 t.prototype._setupDocumentEvents = function () { 573 h(document).bind({ 574 mouseup: this.checkForEndSelection, 575 mousedown: this.checkForStartSelection 576 }); 577 return this 578 }; 579 t.prototype.getSelectedRanges = function () { 580 var x, v, u, w; 581 w = a.getGlobal().getSelection(); 582 u = []; 583 if (!w.isCollapsed) { 584 u = (function () { 585 var z, y; 586 y = []; 587 for (v = 0, z = w.rangeCount; 0 <= z ? v < z : v > z; 0 <= z ? v++ : v--) { 588 x = new p.BrowserRange(w.getRangeAt(v)); 589 y.push(x.normalize().limit(this.wrapper[0])) 590 } 591 return y 592 }).call(this) 593 } 594 return h.grep(u, function (y) { 595 return y 596 }) 597 }; 598 t.prototype.createAnnotation = function () { 599 var u; 600 u = {}; 601 this.publish("beforeAnnotationCreated", [u]); 602 return u 603 }; 604 t.prototype.setupAnnotation = function (u, w) { 605 var v, A, z, x, y, B; 606 if (w == null) { 607 w = true 608 } 609 u.ranges || (u.ranges = this.selectedRanges); 610 A = (function () { 611 var D, F, E, C; 612 E = u.ranges; 613 C = []; 614 for (D = 0, F = E.length; D < F; D++) { 615 z = E[D]; 616 x = p.sniff(z); 617 C.push(x.normalize(this.wrapper[0])) 618 } 619 return C 620 }).call(this); 621 A = h.grep(A, function (C) { 622 return C !== null 623 }); 624 u.quote = []; 625 u.ranges = []; 626 u.highlights = []; 627 for (y = 0, B = A.length; y < B; y++) { 628 v = A[y]; 629 u.quote.push(h.trim(v.text())); 630 u.ranges.push(v.serialize(this.wrapper[0], ".annotator-hl")); 631 h.merge(u.highlights, this.highlightRange(v)) 632 } 633 u.quote = u.quote.join(" / "); 634 h(u.highlights).data("annotation", u); 635 if (w) { 636 this.publish("annotationCreated", [u]) 637 } 638 return u 639 }; 640 t.prototype.updateAnnotation = function (u) { 641 this.publish("beforeAnnotationUpdated", [u]); 642 this.publish("annotationUpdated", [u]); 643 return u 644 }; 645 t.prototype.deleteAnnotation = function (u) { 646 var w, v, y, x; 647 x = u.highlights; 648 for (v = 0, y = x.length; v < y; v++) { 649 w = x[v]; 650 h(w).replaceWith(w.childNodes) 651 } 652 this.publish("annotationDeleted", [u]); 653 return u 654 }; 655 t.prototype.loadAnnotations = function (v) { 656 var w, u; 657 if (v == null) { 658 v = [] 659 } 660 u = g(function (z) { 661 var B, x, y, A; 662 if (z == null) { 663 z = [] 664 } 665 x = z.splice(0, 10); 666 for (y = 0, A = x.length; y < A; y++) { 667 B = x[y]; 668 this.setupAnnotation(B, false) 669 } 670 if (z.length > 0) { 671 return setTimeout((function () { 672 return u(z) 673 }), 100) 674 } else { 675 return this.publish("annotationsLoaded", [w]) 676 } 677 }, this); 678 w = v.slice(); 679 if (v.length) { 680 u(v) 681 } 682 return this 683 }; 684 t.prototype.dumpAnnotations = function () { 685 if (this.plugins.Store) { 686 return this.plugins.Store.dumpAnnotations() 687 } else { 688 return console.warn("Can't dump annotations without Store plugin.") 689 } 690 }; 691 t.prototype.highlightRange = function (v) { 692 var u, w, x; 693 return u = (function () { 694 var z, B, A, y; 695 A = v.textNodes(); 696 y = []; 697 for (z = 0, B = A.length; z < B; z++) { 698 w = A[z]; 699 x = this.hl.clone().show(); 700 y.push(h(w).wrap(x).parent().get(0)) 701 } 702 return y 703 }).call(this) 704 }; 705 t.prototype.addPlugin = function (w, v) { 706 var u, x; 707 if (this.plugins[w]) { 708 console.error("You cannot have more than one instance of any plugin.") 709 } else { 710 u = t.Plugin[w]; 711 if (typeof u === "function") { 712 this.plugins[w] = new u(this.element[0], v); 713 this.plugins[w].annotator = this; 714 if (typeof (x = this.plugins[w]).pluginInit === "function") { 715 x.pluginInit() 716 } 717 } else { 718 console.error("Could not load " + w + " plugin. Have you included the appropriate <script> tag?") 719 } 720 } 721 return this 722 }; 723 t.prototype.showEditor = function (u, v) { 724 this.editor.element.css(v); 725 this.editor.load(u); 726 return this 727 }; 728 t.prototype.onEditorHide = function () { 729 this.publish("annotationEditorHidden", [this.editor]); 730 return this.ignoreMouseup = false 731 }; 732 t.prototype.onEditorSubmit = function (u) { 733 this.publish("annotationEditorSubmit", [this.editor, u]); 734 if (u.ranges === void 0) { 735 return this.setupAnnotation(u) 736 } else { 737 return this.updateAnnotation(u) 738 } 739 }; 740 t.prototype.showViewer = function (v, u) { 741 this.viewer.element.css(u); 742 this.viewer.load(v); 743 return this.publish("annotationViewerShown", [this.viewer, v]) 744 }; 745 t.prototype.startViewerHideTimer = function () { 746 if (!this.viewerHideTimer) { 747 return this.viewerHideTimer = setTimeout(h.proxy(this.viewer.hide, this.viewer), 250) 748 } 749 }; 750 t.prototype.clearViewerHideTimer = function () { 751 clearTimeout(this.viewerHideTimer); 752 return this.viewerHideTimer = false 753 }; 754 t.prototype.checkForStartSelection = function (u) { 755 if (!(u && this.isAnnotator(u.target))) { 756 this.startViewerHideTimer(); 757 return this.mouseIsDown = true 758 } 759 }; 760 t.prototype.checkForEndSelection = function (x) { 761 var u, v, w, z, y; 762 this.mouseIsDown = false; 763 if (this.ignoreMouseup) { 764 return 765 } 766 this.selectedRanges = this.getSelectedRanges(); 767 y = this.selectedRanges; 768 for (w = 0, z = y.length; w < z; w++) { 769 v = y[w]; 770 u = v.commonAncestor; 771 if (this.isAnnotator(u)) { 772 return 773 } 774 } 775 if (x && this.selectedRanges.length) { 776 return this.adder.css(a.mousePosition(x, this.wrapper[0])).show() 777 } else { 778 return this.adder.hide() 779 } 780 }; 781 t.prototype.isAnnotator = function (u) { 782 return !!h(u).parents().andSelf().filter("[class^=annotator-]").not(this.wrapper).length 783 }; 784 t.prototype.onHighlightMouseover = function (u) { 785 var v; 786 this.clearViewerHideTimer(); 787 if (this.mouseIsDown || this.viewer.isShown()) { 788 return false 789 } 790 v = h(u.target).parents(".annotator-hl").andSelf().map(function () { 791 return h(this).data("annotation") 792 }); 793 return this.showViewer(h.makeArray(v), a.mousePosition(u, this.wrapper[0])) 794 }; 795 t.prototype.onAdderMousedown = function (u) { 796 if (u != null) { 797 u.preventDefault() 798 } 799 return this.ignoreMouseup = true 800 }; 801 t.prototype.onAdderClick = function (v) { 802 var u; 803 if (v != null) { 804 v.preventDefault() 805 } 806 u = this.adder.position(); 807 this.adder.hide(); 808 return this.showEditor(this.createAnnotation(), u) 809 }; 810 t.prototype.onEditAnnotation = function (u) { 811 var v; 812 v = this.viewer.element.position(); 813 this.viewer.hide(); 814 return this.showEditor(u, v) 815 }; 816 t.prototype.onDeleteAnnotation = function (u) { 817 this.viewer.hide(); 818 return this.deleteAnnotation(u) 819 }; 820 return t 821 })(); 822 o.Plugin = (function () { 823 q(t, b); 824 825 function t(v, u) { 826 t.__super__.constructor.apply(this, arguments) 827 } 828 t.prototype.pluginInit = function () {}; 829 return t 830 })(); 831 o.$ = h; 832 o.supported = function () { 833 return (function () { 834 return !!this.getSelection 835 })() 836 }; 837 o.noConflict = function () { 838 a.getGlobal().Annotator = e; 839 return this 840 }; 841 h.plugin("annotator", o); 842 this.Annotator = o; 843 o.Widget = (function () { 844 q(t, b); 845 t.prototype.classes = { 846 hide: "annotator-hide", 847 invert: { 848 x: "annotator-invert-x", 849 y: "annotator-invert-y" 850 } 851 }; 852 853 function t(v, u) { 854 t.__super__.constructor.apply(this, arguments); 855 this.classes = h.extend({}, o.Widget.prototype.classes, this.classes) 856 } 857 t.prototype.checkOrientation = function () { 858 var x, y, u, w, v; 859 this.resetOrientation(); 860 v = h(a.getGlobal()); 861 w = this.element.children(":first"); 862 y = w.offset(); 863 u = { 864 top: v.scrollTop(), 865 right: v.width() + v.scrollLeft() 866 }; 867 x = { 868 top: y.top, 869 right: y.left + w.width() 870 }; 871 if ((x.top - u.top) < 0) { 872 this.invertY() 873 } 874 if ((x.right - u.right) > 0) { 875 this.invertX() 876 } 877 return this 878 }; 879 t.prototype.resetOrientation = function () { 880 this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y); 881 return this 882 }; 883 t.prototype.invertX = function () { 884 this.element.addClass(this.classes.invert.x); 885 return this 886 }; 887 t.prototype.invertY = function () { 888 this.element.addClass(this.classes.invert.y); 889 return this 890 }; 891 return t 892 })(); 893 o.Editor = (function () { 894 q(t, o.Widget); 895 t.prototype.events = { 896 "form submit": "submit", 897 ".annotator-save click": "submit", 898 ".annotator-cancel click": "hide", 899 ".annotator-cancel mouseover": "onCancelButtonMouseover", 900 "textarea keydown": "processKeypress" 901 }; 902 t.prototype.classes = { 903 hide: "annotator-hide", 904 focus: "annotator-focus" 905 }; 906 t.prototype.html = '<div class="annotator-outer annotator-editor">\n <form class="annotator-widget">\n <ul class="annotator-listing"></ul>\n <div class="annotator-controls">\n <a href="#cancel" class="annotator-cancel">Cancel</a>\n <a href="#save" class="annotator-save annotator-focus">Save</a>\n </div>\n <span class="annotator-resize"></span>\n </form>\n</div>'; 907 t.prototype.options = {}; 908 909 function t(u) { 910 this.onCancelButtonMouseover = g(this.onCancelButtonMouseover, this); 911 this.processKeypress = g(this.processKeypress, this); 912 this.submit = g(this.submit, this); 913 this.load = g(this.load, this); 914 this.hide = g(this.hide, this); 915 this.show = g(this.show, this); 916 t.__super__.constructor.call(this, h(this.html)[0], u); 917 this.fields = []; 918 this.annotation = {}; 919 this.setupDragabbles() 920 } 921 t.prototype.show = function (u) { 922 if (u != null) { 923 u.preventDefault() 924 } 925 this.element.removeClass(this.classes.hide); 926 this.element.find(".annotator-save").addClass(this.classes.focus); 927 this.element.find(":input:first").focus(); 928 return this.checkOrientation().publish("show") 929 }; 930 t.prototype.hide = function (u) { 931 if (u != null) { 932 u.preventDefault() 933 } 934 this.element.addClass(this.classes.hide); 935 return this.publish("hide") 936 }; 937 t.prototype.load = function (u) { 938 var w, v, y, x; 939 this.annotation = u; 940 this.publish("load", [this.annotation]); 941 x = this.fields; 942 for (v = 0, y = x.length; v < y; v++) { 943 w = x[v]; 944 w.load(w.element, this.annotation) 945 } 946 return this.show() 947 }; 948 t.prototype.submit = function (v) { 949 var w, u, y, x; 950 if (v != null) { 951 v.preventDefault() 952 } 953 x = this.fields; 954 for (u = 0, y = x.length; u < y; u++) { 955 w = x[u]; 956 w.submit(w.element, this.annotation) 957 } 958 this.publish("save", [this.annotation]); 959 return this.hide() 960 }; 961 t.prototype.addField = function (v) { 962 var w, x, u; 963 x = h.extend({ 964 id: "annotator-field-" + (new Date()).getTime(), 965 type: "input", 966 label: "", 967 load: function () {}, 968 submit: function () {} 969 }, v); 970 u = null; 971 w = h('<li class="annotator-item" />'); 972 x.element = w[0]; 973 switch (x.type) { 974 case "textarea": 975 u = h("<textarea />"); 976 break; 977 case "input": 978 case "checkbox": 979 u = h("<input />") 980 } 981 w.append(u); 982 u.attr({ 983 id: x.id, 984 placeholder: x.label 985 }); 986 if (x.type === "checkbox") { 987 u[0].type = "checkbox"; 988 w.addClass("annotator-checkbox"); 989 w.append(h("<label />", { 990 "for": x.id, 991 html: x.label 992 })) 993 } 994 this.element.find("ul:first").append(w); 995 this.fields.push(x); 996 return x.element 997 }; 998 t.prototype.checkOrientation = function () { 999 var u, w, v; 1000 t.__super__.checkOrientation.apply(this, arguments); 1001 v = this.element.find("ul"); 1002 u = this.element.find(".annotator-controls"); 1003 w = function () { 1004 return v.children().each(function () { 1005 return h(this).parent().prepend(this) 1006 }) 1007 }; 1008 if (this.element.hasClass(this.classes.invert.y) && v.is(":first-child")) { 1009 u.insertBefore(v); 1010 w() 1011 } else { 1012 if (u.is(":first-child")) { 1013 u.insertAfter(v); 1014 w() 1015 } 1016 } 1017 return this 1018 }; 1019 t.prototype.processKeypress = function (u) { 1020 if (u.keyCode === 27) { 1021 return this.hide() 1022 } else { 1023 if (u.keyCode === 13 && !u.shiftKey) { 1024 return this.submit() 1025 } 1026 } 1027 }; 1028 t.prototype.onCancelButtonMouseover = function () { 1029 return this.element.find("." + this.classes.focus).removeClass(this.classes.focus) 1030 }; 1031 t.prototype.setupDragabbles = function () { 1032 var w, D, z, u, y, B, x, v, A, C; 1033 u = null; 1034 w = this.classes; 1035 z = this.element; 1036 A = null; 1037 v = z.find(".annotator-resize"); 1038 D = z.find(".annotator-controls"); 1039 C = false; 1040 y = function (E) { 1041 if (E.target === this) { 1042 u = { 1043 element: this, 1044 top: E.pageY, 1045 left: E.pageX 1046 }; 1047 A = z.find("textarea:first"); 1048 h(window).bind({ 1049 "mouseup.annotator-editor-resize": x, 1050 "mousemove.annotator-editor-resize": B 1051 }); 1052 return E.preventDefault() 1053 } 1054 }; 1055 x = function () { 1056 u = null; 1057 return h(window).unbind(".annotator-editor-resize") 1058 }; 1059 B = g(function (I) { 1060 var J, G, F, E, H; 1061 if (u && C === false) { 1062 J = { 1063 top: I.pageY - u.top, 1064 left: I.pageX - u.left 1065 }; 1066 if (u.element === v[0]) { 1067 E = A.outerHeight(); 1068 H = A.outerWidth(); 1069 G = z.hasClass(w.invert.x) ? -1 : 1; 1070 F = z.hasClass(w.invert.y) ? 1 : -1; 1071 A.height(E + (J.top * F)); 1072 A.width(H + (J.left * G)); 1073 if (A.outerHeight() !== E) { 1074 u.top = I.pageY 1075 } 1076 if (A.outerWidth() !== H) { 1077 u.left = I.pageX 1078 } 1079 } else { 1080 if (u.element === D[0]) { 1081 z.css({ 1082 top: parseInt(z.css("top"), 10) + J.top, 1083 left: parseInt(z.css("left"), 10) + J.left 1084 }); 1085 u.top = I.pageY; 1086 u.left = I.pageX 1087 } 1088 } 1089 C = true; 1090 return setTimeout(function () { 1091 return C = false 1092 }, 1000 / 60) 1093 } 1094 }, this); 1095 v.bind("mousedown", y); 1096 return D.bind("mousedown", y) 1097 }; 1098 return t 1099 })(); 1100 o.Viewer = (function () { 1101 q(t, o.Widget); 1102 t.prototype.events = { 1103 ".annotator-edit click": "onEditClick", 1104 ".annotator-delete click": "onDeleteClick" 1105 }; 1106 t.prototype.classes = { 1107 hide: "annotator-hide", 1108 showControls: "annotator-visible" 1109 }; 1110 t.prototype.html = { 1111 element: '<div class="annotator-outer annotator-viewer">\n <ul class="annotator-widget annotator-listing"></ul>\n</div>', 1112 item: '<li class="annotator-annotation annotator-item">\n <span class="annotator-controls">\n <button class="annotator-edit">Edit</button>\n <button class="annotator-delete">Delete</button>\n </span>\n</li>' 1113 }; 1114 1115 function t(u) { 1116 this.onDeleteClick = g(this.onDeleteClick, this); 1117 this.onEditClick = g(this.onEditClick, this); 1118 this.load = g(this.load, this); 1119 this.hide = g(this.hide, this); 1120 this.show = g(this.show, this); 1121 t.__super__.constructor.call(this, h(this.html.element)[0], u); 1122 this.item = h(this.html.item)[0]; 1123 this.fields = []; 1124 this.annotations = [] 1125 } 1126 t.prototype.show = function (v) { 1127 var u; 1128 if (v != null) { 1129 v.preventDefault() 1130 } 1131 u = this.element.find(".annotator-controls").addClass(this.classes.showControls); 1132 setTimeout((g(function () { 1133 return u.removeClass(this.classes.showControls) 1134 }, this)), 500); 1135 this.element.removeClass(this.classes.hide); 1136 return this.checkOrientation().publish("show") 1137 }; 1138 t.prototype.isShown = function () { 1139 return !this.element.hasClass(this.classes.hide) 1140 }; 1141 t.prototype.hide = function (u) { 1142 if (u != null) { 1143 //u.preventDefault() 1144 } 1145 this.element.addClass(this.classes.hide); 1146 return this.publish("hide") 1147 }; 1148 t.prototype.load = function (C) { 1149 var z, B, G, H, F, A, E, I, D, y, w, u, J, x, v; 1150 this.annotations = C || []; 1151 D = this.element.find("ul:first").empty(); 1152 x = this.annotations; 1153 for (y = 0, u = x.length; y < u; y++) { 1154 z = x[y]; 1155 I = h(this.item).clone().appendTo(D).data("annotation", z); 1156 G = I.find(".annotator-controls"); 1157 F = G.find(".annotator-edit"); 1158 H = G.find(".annotator-delete"); 1159 B = { 1160 showEdit: function () { 1161 return F.removeAttr("disabled") 1162 }, 1163 hideEdit: function () { 1164 return F.attr("disabled", "disabled") 1165 }, 1166 showDelete: function () { 1167 return H.removeAttr("disabled") 1168 }, 1169 hideDelete: function () { 1170 return H.attr("disabled", "disabled") 1171 } 1172 }; 1173 v = this.fields; 1174 for (w = 0, J = v.length; w < J; w++) { 1175 E = v[w]; 1176 A = h(E.element).clone().appendTo(I)[0]; 1177 E.load(A, z, B) 1178 } 1179 } 1180 this.publish("load", [this.annotations]); 1181 return this.show() 1182 }; 1183 t.prototype.addField = function (u) { 1184 var v; 1185 v = h.extend({ 1186 load: function () {} 1187 }, u); 1188 v.element = h("<div />")[0]; 1189 this.fields.push(v); 1190 v.element; 1191 return this 1192 }; 1193 t.prototype.onEditClick = function (u) { 1194 return this.onButtonClick(u, "edit") 1195 }; 1196 t.prototype.onDeleteClick = function (u) { 1197 return this.onButtonClick(u, "delete") 1198 }; 1199 t.prototype.onButtonClick = function (w, u) { 1200 var v; 1201 v = h(w.target).parents(".annotator-annotation"); 1202 return this.publish(u, [v.data("annotation")]) 1203 }; 1204 return t 1205 })(); 1206 o = o || {}; 1207 o.Notification = (function () { 1208 q(t, b); 1209 t.prototype.events = { 1210 click: "hide" 1211 }; 1212 t.prototype.options = { 1213 html: "<div class='annotator-notice'></div>", 1214 classes: { 1215 show: "annotator-notice-show", 1216 info: "annotator-notice-info", 1217 success: "annotator-notice-success", 1218 error: "annotator-notice-error" 1219 } 1220 }; 1221 1222 function t(u) { 1223 this.hide = g(this.hide, this); 1224 this.show = g(this.show, this); 1225 t.__super__.constructor.call(this, h(this.options.html).appendTo(document.body)[0], u) 1226 } 1227 t.prototype.show = function (v, u) { 1228 if (u == null) { 1229 u = o.Notification.INFO 1230 } 1231 h(this.element).addClass(this.options.classes.show).addClass(this.options.classes[u]).escape(v || ""); 1232 setTimeout(this.hide, 5000); 1233 return this 1234 }; 1235 t.prototype.hide = function () { 1236 h(this.element).removeClass(this.options.classes.show); 1237 return this 1238 }; 1239 return t 1240 })(); 1241 o.Notification.INFO = "show"; 1242 o.Notification.SUCCESS = "success"; 1243 o.Notification.ERROR = "error"; 1244 h(function () { 1245 var t; 1246 t = new o.Notification; 1247 o.showNotification = t.show; 1248 return o.hideNotification = t.hide 1249 }); 1250 o.Plugin.Tags = (function () { 1251 q(t, o.Plugin); 1252 1253 function t() { 1254 this.setAnnotationTags = g(this.setAnnotationTags, this); 1255 this.updateField = g(this.updateField, this); 1256 t.__super__.constructor.apply(this, arguments) 1257 } 1258 t.prototype.field = null; 1259 t.prototype.input = null; 1260 t.prototype.pluginInit = function () { 1261 if (!o.supported()) { 1262 return 1263 } 1264 this.field = this.annotator.editor.addField({ 1265 label: "Add some tags here\u2026", 1266 load: this.updateField, 1267 submit: this.setAnnotationTags 1268 }); 1269 this.annotator.viewer.addField({ 1270 load: this.updateViewer 1271 }); 1272 if (this.annotator.plugins.Filter) { 1273 this.annotator.plugins.Filter.addFilter({ 1274 label: "Tag", 1275 property: "tags", 1276 isFiltered: o.Plugin.Tags.filterCallback 1277 }) 1278 } 1279 return this.input = h(this.field).find(":input") 1280 }; 1281 t.prototype.parseTags = function (v) { 1282 var u; 1283 v = h.trim(v); 1284 u = []; 1285 if (v) { 1286 u = v.split(/\s+/) 1287 } 1288 return u 1289 }; 1290 t.prototype.stringifyTags = function (u) { 1291 return u.join(" ") 1292 }; 1293 t.prototype.updateField = function (w, u) { 1294 var v; 1295 v = ""; 1296 if (u.tags) { 1297 v = this.stringifyTags(u.tags) 1298 } 1299 return this.input.val(v) 1300 }; 1301 t.prototype.setAnnotationTags = function (v, u) { 1302 return u.tags = this.parseTags(this.input.val()) 1303 }; 1304 t.prototype.updateViewer = function (v, u) { 1305 v = h(v); 1306 if (u.tags && h.isArray(u.tags) && u.tags.length) { 1307 return v.addClass("annotator-tags").html(function () { 1308 var w; 1309 return w = h.map(u.tags, function (x) { 1310 return '<span class="annotator-tag">' + o.$.escape(x) + "</span>" 1311 }).join(" ") 1312 }) 1313 } else { 1314 return v.remove() 1315 } 1316 }; 1317 return t 1318 })(); 1319 o.Plugin.Tags.filterCallback = function (z, B) { 1320 var y, x, w, C, v, u, t, A; 1321 if (B == null) { 1322 B = [] 1323 } 1324 w = 0; 1325 x = []; 1326 if (z) { 1327 x = z.split(/\s+/g); 1328 for (v = 0, t = x.length; v < t; v++) { 1329 y = x[v]; 1330 if (B.length) { 1331 for (u = 0, A = B.length; u < A; u++) { 1332 C = B[u]; 1333 if (C.indexOf(y) !== -1) { 1334 w += 1 1335 } 1336 } 1337 } 1338 } 1339 } 1340 return w === x.length 1341 }; 1342 n = function (u) { 1343 var y, t, x, v, w, z; 1344 v = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?"; 1345 y = u.match(new RegExp(v)); 1346 x = 0; 1347 t = new Date(y[1], 0, 1); 1348 if (y[3]) { 1349 t.setMonth(y[3] - 1) 1350 } 1351 if (y[5]) { 1352 t.setDate(y[5]) 1353 } 1354 if (y[7]) { 1355 t.setHours(y[7]) 1356 } 1357 if (y[8]) { 1358 t.setMinutes(y[8]) 1359 } 1360 if (y[10]) { 1361 t.setSeconds(y[10]) 1362 } 1363 if (y[12]) { 1364 t.setMilliseconds(Number("0." + y[12]) * 1000) 1365 } 1366 if (y[14]) { 1367 x = (Number(y[16]) * 60) + Number(y[17]); 1368 x *= (z = y[15] === "-") != null ? z : { 1369 1: -1 1370 } 1371 } 1372 x -= t.getTimezoneOffset(); 1373 w = Number(t) + (x * 60 * 1000); 1374 t.setTime(Number(w)); 1375 return t 1376 }; 1377 o.Plugin.Auth = (function () { 1378 q(t, o.Plugin); 1379 t.prototype.options = { 1380 token: null, 1381 tokenUrl: "/auth/token", 1382 autoFetch: true 1383 }; 1384 1385 function t(v, u) { 1386 this.haveValidToken = g(this.haveValidToken, this); 1387 t.__super__.constructor.apply(this, arguments); 1388 this.element.data("annotator:auth", this); 1389 this.waitingForToken = []; 1390 if (this.options.token) { 1391 this.setToken(this.options.token) 1392 } else { 1393 this.requestToken() 1394 } 1395 } 1396 t.prototype.requestToken = function () { 1397 this.requestInProgress = true; 1398 return h.getJSON(this.options.tokenUrl, g(function (v, u, w) { 1399 if (u !== "success") { 1400 return console.error("Couldn't get auth token: " + u, w) 1401 } else { 1402 this.setToken(v); 1403 return this.requestInProgress = false 1404 } 1405 }, this)) 1406 }; 1407 t.prototype.setToken = function (v) { 1408 var u; 1409 this.token = v; 1410 if (this.haveValidToken()) { 1411 if (this.options.autoFetch) { 1412 this.refreshTimeout = setTimeout((g(function () { 1413 return this.requestToken() 1414 }, this)), (this.timeToExpiry() - 2) * 1000) 1415 } 1416 this.updateHeaders(); 1417 u = []; 1418 while (this.waitingForToken.length > 0) { 1419 u.push(this.waitingForToken.pop().apply()) 1420 } 1421 return u 1422 } else { 1423 console.warn("Didn't get a valid token."); 1424 if (this.options.autoFetch) { 1425 console.warn("Getting a new token in 10s."); 1426 return setTimeout((g(function () { 1427 return this.requestToken() 1428 }, this)), 10 * 1000) 1429 } 1430 } 1431 }; 1432 t.prototype.haveValidToken = function () { 1433 var u; 1434 u = this.token && this.token.authToken && this.token.authTokenIssueTime && this.token.authTokenTTL && this.token.accountId && this.token.userId; 1435 return u && this.timeToExpiry() > 0 1436 }; 1437 t.prototype.timeToExpiry = function () { 1438 var w, u, v, x; 1439 v = new Date().getTime() / 1000; 1440 u = n(this.token.authTokenIssueTime).getTime() / 1000; 1441 w = u + this.token.authTokenTTL; 1442 x = w - v; 1443 if (x > 0) { 1444 return x 1445 } else { 1446 return 0 1447 } 1448 }; 1449 t.prototype.updateHeaders = function () { 1450 var u; 1451 u = this.element.data("annotator:headers"); 1452 return this.element.data("annotator:headers", h.extend(u, { 1453 "x-annotator-auth-token": this.token.authToken, 1454 "x-annotator-auth-token-issue-time": this.token.authTokenIssueTime, 1455 "x-annotator-auth-token-ttl": this.token.authTokenTTL, 1456 "x-annotator-account-id": this.token.accountId, 1457 "x-annotator-user-id": this.token.userId 1458 })) 1459 }; 1460 t.prototype.withToken = function (u) { 1461 if (!(u != null)) { 1462 return 1463 } 1464 if (this.haveValidToken()) { 1465 return u() 1466 } else { 1467 this.waitingForToken.push(u); 1468 if (!this.requestInProgress) { 1469 return this.requestToken() 1470 } 1471 } 1472 }; 1473 return t 1474 })(); 1475 o.Plugin.Store = (function () { 1476 q(t, o.Plugin); 1477 t.prototype.events = { 1478 annotationCreated: "annotationCreated", 1479 annotationDeleted: "annotationDeleted", 1480 annotationUpdated: "annotationUpdated" 1481 }; 1482 t.prototype.options = { 1483 prefix: "/store", 1484 autoFetch: true, 1485 annotationData: {}, 1486 loadFromSearch: false, 1487 urls: { 1488 create: "/annotations", 1489 read: "/annotations/:id", 1490 update: "/annotations/:id", 1491 destroy: "/annotations/:id", 1492 search: "/search" 1493 } 1494 }; 1495 1496 function t(v, u) { 1497 this._onError = g(this._onError, this); 1498 this._onBeforeSend = g(this._onBeforeSend, this); 1499 this._onLoadAnnotationsFromSearch = g(this._onLoadAnnotationsFromSearch, this); 1500 this._onLoadAnnotations = g(this._onLoadAnnotations, this); 1501 this._getAnnotations = g(this._getAnnotations, this); 1502 t.__super__.constructor.apply(this, arguments); 1503 this.annotations = [] 1504 } 1505 t.prototype.pluginInit = function () { 1506 var u; 1507 if (!o.supported()) { 1508 return 1509 } 1510 u = this.element.data("annotator:auth"); 1511 if (u) { 1512 return u.withToken(this._getAnnotations) 1513 } else { 1514 return this._getAnnotations() 1515 } 1516 }; 1517 t.prototype._getAnnotations = function () { 1518 if (this.options.loadFromSearch) { 1519 return this.loadAnnotationsFromSearch(this.options.loadFromSearch) 1520 } else { 1521 return this.loadAnnotations() 1522 } 1523 }; 1524 t.prototype.annotationCreated = function (u) { 1525 if (f.call(this.annotations, u) < 0) { 1526 this.registerAnnotation(u); 1527 return this._apiRequest("create", u, g(function (v) { 1528 if (!(v.id != null)) { 1529 console.warn("Warning: No ID returned from server for annotation ", u) 1530 } 1531 return this.updateAnnotation(u, v) 1532 }, this)) 1533 } else { 1534 return this.updateAnnotation(u, {}) 1535 } 1536 }; 1537 t.prototype.annotationUpdated = function (u) { 1538 if (f.call(this.annotations, u) >= 0) { 1539 return this._apiRequest("update", u, (g(function (v) { 1540 return this.updateAnnotation(u, v) 1541 }, this))) 1542 } 1543 }; 1544 t.prototype.annotationDeleted = function (u) { 1545 if (f.call(this.annotations, u) >= 0) { 1546 return this._apiRequest("destroy", u, (g(function () { 1547 return this.unregisterAnnotation(u) 1548 }, this))) 1549 } 1550 }; 1551 t.prototype.registerAnnotation = function (u) { 1552 return this.annotations.push(u) 1553 }; 1554 t.prototype.unregisterAnnotation = function (u) { 1555 return this.annotations.splice(this.annotations.indexOf(u), 1) 1556 }; 1557 t.prototype.updateAnnotation = function (u, v) { 1558 if (f.call(this.annotations, u) < 0) { 1559 console.error("Trying to update unregistered annotation!") 1560 } else { 1561 h.extend(u, v) 1562 } 1563 return h(u.highlights).data("annotation", u) 1564 }; 1565 t.prototype.loadAnnotations = function () { 1566 return this._apiRequest("read", null, this._onLoadAnnotations) 1567 }; 1568 t.prototype._onLoadAnnotations = function (u) { 1569 if (u == null) { 1570 u = [] 1571 } 1572 this.annotations = u; 1573 return this.annotator.loadAnnotations(u.slice()) 1574 }; 1575 t.prototype.loadAnnotationsFromSearch = function (u) { 1576 return this._apiRequest("search", u, this._onLoadAnnotationsFromSearch) 1577 }; 1578 t.prototype._onLoadAnnotationsFromSearch = function (u) { 1579 if (u == null) { 1580 u = {} 1581 } 1582 return this._onLoadAnnotations(u.rows || []) 1583 }; 1584 t.prototype.dumpAnnotations = function () { 1585 var w, v, y, x, u; 1586 x = this.annotations; 1587 u = []; 1588 for (v = 0, y = x.length; v < y; v++) { 1589 w = x[v]; 1590 u.push(JSON.parse(this._dataFor(w))) 1591 } 1592 return u 1593 }; 1594 t.prototype._apiRequest = function (x, y, z) { 1595 var A, v, w, u; 1596 A = y && y.id; 1597 u = this._urlFor(x, A); 1598 v = this._apiRequestOptions(x, y, z); 1599 w = h.ajax(u, v); 1600 w._id = A; 1601 w._action = x; 1602 return w 1603 }; 1604 t.prototype._apiRequestOptions = function (v, w, x) { 1605 var u; 1606 u = { 1607 type: this._methodFor(v), 1608 beforeSend: this._onBeforeSend, 1609 dataType: "json", 1610 success: x || 1611 function () {}, 1612 error: this._onError 1613 }; 1614 if (v === "search") { 1615 u = h.extend(u, { 1616 data: w 1617 }) 1618 } else { 1619 u = h.extend(u, { 1620 data: w && this._dataFor(w), 1621 contentType: "application/json; charset=utf-8" 1622 }) 1623 } 1624 return u 1625 }; 1626 t.prototype._urlFor = function (w, x) { 1627 var u, v; 1628 u = x != null ? "/" + x : ""; 1629 v = this.options.prefix || "/"; 1630 v += this.options.urls[w]; 1631 v = v.replace(/\/:id/, u); 1632 return v 1633 }; 1634 t.prototype._methodFor = function (v) { 1635 var u; 1636 u = { 1637 create: "POST", 1638 read: "GET", 1639 update: "PUT", 1640 destroy: "DELETE", 1641 search: "GET" 1642 }; 1643 return u[v] 1644 }; 1645 t.prototype._dataFor = function (u) { 1646 var v, w; 1647 w = u.highlights; 1648 delete u.highlights; 1649 h.extend(u, this.options.annotationData); 1650 v = JSON.stringify(u); 1651 if (w) { 1652 u.highlights = w 1653 } 1654 return v 1655 }; 1656 t.prototype._onBeforeSend = function (y) { 1657 var x, v, w, u; 1658 x = this.element.data("annotator:headers"); 1659 if (x) { 1660 u = []; 1661 for (v in x) { 1662 w = x[v]; 1663 u.push(y.setRequestHeader(v, w)) 1664 } 1665 return u 1666 } 1667 }; 1668 t.prototype._onError = function (w) { 1669 var v, u; 1670 v = w._action; 1671 u = "Sorry we could not " + v + " this annotation"; 1672 if (w._action === "search") { 1673 u = "Sorry we could not search the store for annotations" 1674 } else { 1675 if (w._action === "read" && !w._id) { 1676 u = "Sorry we could not " + v + " the annotations from the store" 1677 } 1678 } 1679 switch (w.status) { 1680 case 401: 1681 u = "Sorry you are not allowed to " + v + " this annotation"; 1682 break; 1683 case 404: 1684 u = "Sorry we could not connect to the annotations store"; 1685 break; 1686 case 500: 1687 u = "Sorry something went wrong with the annotation store" 1688 } 1689 o.showNotification(u, o.Notification.ERROR); 1690 return console.error("API request failed: '" + w.status + "'") 1691 }; 1692 return t 1693 })(); 1694 o.Plugin.Filter = (function () { 1695 q(t, o.Plugin); 1696 t.prototype.events = { 1697 ".annotator-filter-property input focus": "_onFilterFocus", 1698 ".annotator-filter-property input blur": "_onFilterBlur", 1699 ".annotator-filter-property input keyup": "_onFilterKeyup", 1700 ".annotator-filter-previous click": "_onPreviousClick", 1701 ".annotator-filter-next click": "_onNextClick", 1702 ".annotator-filter-clear click": "_onClearClick" 1703 }; 1704 t.prototype.classes = { 1705 active: "annotator-filter-active", 1706 hl: { 1707 hide: "annotator-hl-filtered", 1708 active: "annotator-hl-active" 1709 } 1710 }; 1711 t.prototype.html = { 1712 // element: '<div class="annotator-filter">\n <strong>Navigate:</strong>\n <span class="annotator-filter-navigation">\n <button class="annotator-filter-previous">Previous</button>\n <button class="annotator-filter-next">Next</button>\n </span>\n <strong>Filter by:</strong>\n</div>', 1713 filter: '<span class="annotator-filter-property">\n <label></label>\n <input/>\n <button class="annotator-filter-clear">Clear</button>\n</span>' 1714 }; 1715 t.prototype.options = { 1716 appendTo: "body", 1717 filters: [], 1718 addAnnotationFilter: true, 1719 isFiltered: function (v, x) { 1720 var u, w, z, y; 1721 if (!(v && x)) { 1722 return false 1723 } 1724 y = v.split(/\s*/); 1725 for (w = 0, z = y.length; w < z; w++) { 1726 u = y[w]; 1727 if (x.indexOf(u) === -1) { 1728 return false 1729 } 1730 } 1731 return true 1732 } 1733 }; 1734 1735 function t(v, u) { 1736 this._onPreviousClick = g(this._onPreviousClick, this); 1737 this._onNextClick = g(this._onNextClick, this); 1738 this._onFilterKeyup = g(this._onFilterKeyup, this); 1739 this._onFilterBlur = g(this._onFilterBlur, this); 1740 this._onFilterFocus = g(this._onFilterFocus, this); 1741 this.updateHighlights = g(this.updateHighlights, this); 1742 v = h(this.html.element).appendTo(this.options.appendTo); 1743 t.__super__.constructor.call(this, v, u); 1744 this.filter = h(this.html.filter); 1745 this.filters = []; 1746 this.current = 0 1747 } 1748 t.prototype.pluginInit = function () { 1749 var v, u, x, w; 1750 w = this.options.filters; 1751 for (u = 0, x = w.length; u < x; u++) { 1752 v = w[u]; 1753 this.addFilter(v) 1754 } 1755 this.updateHighlights(); 1756 this._setupListeners()._insertSpacer(); 1757 if (this.options.addAnnotationFilter === true) { 1758 return this.addFilter({ 1759 label: "Annotation", 1760 property: "text" 1761 }) 1762 } 1763 }; 1764 t.prototype._insertSpacer = function () { 1765 var v, u; 1766 u = h("html"); 1767 v = parseInt(u.css("padding-top"), 10) || 0; 1768 u.css("padding-top", v + this.element.outerHeight()); 1769 return this 1770 }; 1771 t.prototype._setupListeners = function () { 1772 var w, u, v, x; 1773 u = ["annotationsLoaded", "annotationCreated", "annotationUpdated", "annotationDeleted"]; 1774 for (v = 0, x = u.length; v < x; v++) { 1775 w = u[v]; 1776 this.annotator.subscribe(w, this.updateHighlights) 1777 } 1778 return this 1779 }; 1780 t.prototype.addFilter = function (u) { 1781 var w, v; 1782 v = h.extend({ 1783 label: "", 1784 property: "", 1785 isFiltered: this.options.isFiltered 1786 }, u); 1787 if (!((function () { 1788 var y, A, z, x; 1789 z = this.filters; 1790 x = []; 1791 for (y = 0, A = z.length; y < A; y++) { 1792 w = z[y]; 1793 if (w.property === v.property) { 1794 x.push(w) 1795 } 1796 } 1797 return x 1798 }).call(this)).length) { 1799 v.id = "annotator-filter-" + v.property; 1800 v.annotations = []; 1801 v.element = this.filter.clone().appendTo(this.element); 1802 v.element.find("label").html(v.label).attr("for", v.id); 1803 v.element.find("input").attr({ 1804 id: v.id, 1805 placeholder: "Filter by " + v.label + "\u2026" 1806 }); 1807 v.element.find("button").hide(); 1808 v.element.data("filter", v); 1809 this.filters.push(v) 1810 } 1811 return this 1812 }; 1813 t.prototype.updateFilter = function (x) { 1814 var u, z, v, y, w, B, A; 1815 x.annotations = []; 1816 this.updateHighlights(); 1817 this.resetHighlights(); 1818 v = h.trim(x.element.find("input").val()); 1819 if (v) { 1820 z = this.highlights.map(function () { 1821 return h(this).data("annotation") 1822 }); 1823 A = h.makeArray(z); 1824 for (w = 0, B = A.length; w < B; w++) { 1825 u = A[w]; 1826 y = u[x.property]; 1827 if (x.isFiltered(v, y)) { 1828 x.annotations.push(u) 1829 } 1830 } 1831 return this.filterHighlights() 1832 } 1833 }; 1834 t.prototype.updateHighlights = function () { 1835 this.highlights = this.annotator.element.find(".annotator-hl:visible"); 1836 return this.filtered = this.highlights.not(this.classes.hl.hide) 1837 }; 1838 t.prototype.filterHighlights = function () { 1839 var v, x, y, B, z, A, C, u, w; 1840 v = h.grep(this.filters, function (D) { 1841 return !!D.annotations.length 1842 }); 1843 B = ((w = v[0]) != null ? w.annotations : void 0) || []; 1844 if (v.length > 1) { 1845 y = []; 1846 h.each(v, function () { 1847 return h.merge(y, this.annotations) 1848 }); 1849 C = []; 1850 B = []; 1851 h.each(y, function () { 1852 if (h.inArray(this, C) === -1) { 1853 return C.push(this) 1854 } else { 1855 return B.push(this) 1856 } 1857 }) 1858 } 1859 z = this.highlights; 1860 for (A = 0, u = B.length; A < u; A++) { 1861 x = B[A]; 1862 z = z.not(x.highlights) 1863 } 1864 z.addClass(this.classes.hl.hide); 1865 this.filtered = this.highlights.not(this.classes.hl.hide); 1866 return this 1867 }; 1868 t.prototype.resetHighlights = function () { 1869 this.highlights.removeClass(this.classes.hl.hide); 1870 this.filtered = this.highlights; 1871 return this 1872 }; 1873 t.prototype._onFilterFocus = function (v) { 1874 var u; 1875 u = h(v.target); 1876 u.parent().addClass(this.classes.active); 1877 return u.next("button").show() 1878 }; 1879 t.prototype._onFilterBlur = function (v) { 1880 var u; 1881 if (!v.target.value) { 1882 u = h(v.target); 1883 u.parent().removeClass(this.classes.active); 1884 return u.next("button").hide() 1885 } 1886 }; 1887 t.prototype._onFilterKeyup = function (v) { 1888 var u; 1889 u = h(v.target).parent().data("filter"); 1890 if (u) { 1891 return this.updateFilter(u) 1892 } 1893 }; 1894 t.prototype._findNextHighlight = function (z) { 1895 var v, w, B, A, y, x, u, C; 1896 if (!this.highlights.length) { 1897 return this 1898 } 1899 x = z ? 0 : -1; 1900 C = z ? -1 : 0; 1901 u = z ? "lt" : "gt"; 1902 v = this.highlights.not("." + this.classes.hl.hide); 1903 B = v.filter("." + this.classes.hl.active); 1904 if (!B.length) { 1905 B = v.eq(x) 1906 } 1907 w = B.data("annotation"); 1908 A = v.index(B[0]); 1909 y = v.filter(":" + u + "(" + A + ")").not(w.highlights).eq(C); 1910 if (!y.length) { 1911 y = v.eq(C) 1912 } 1913 return this._scrollToHighlight(y.data("annotation").highlights) 1914 }; 1915 t.prototype._onNextClick = function (u) { 1916 return this._findNextHighlight() 1917 }; 1918 t.prototype._onPreviousClick = function (u) { 1919 return this._findNextHighlight(true) 1920 }; 1921 t.prototype._scrollToHighlight = function (u) { 1922 u = h(u); 1923 this.highlights.removeClass(this.classes.hl.active); 1924 u.addClass(this.classes.hl.active); 1925 return h("html, body").animate({ 1926 scrollTop: u.offset().top - (this.element.height() + 20) 1927 }, 150) 1928 }; 1929 t.prototype._onClearClick = function (u) { 1930 return h(u.target).prev("input").val("").keyup().blur() 1931 }; 1932 return t 1933 })(); 1934 o.Plugin.Markdown = (function () { 1935 q(t, o.Plugin); 1936 t.prototype.events = { 1937 annotationViewerTextField: "updateTextField" 1938 }; 1939 1940 function t(v, u) { 1941 this.updateTextField = g(this.updateTextField, this); 1942 if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) { 1943 t.__super__.constructor.apply(this, arguments); 1944 this.converter = new Showdown.converter() 1945 } else { 1946 console.error("To use the Markdown plugin, you must include Showdown into the page first.") 1947 } 1948 } 1949 t.prototype.updateTextField = function (v, u) { 1950 var w; 1951 w = o.$.escape(u.text || ""); 1952 return h(v).html(this.convert(w)) 1953 }; 1954 t.prototype.convert = function (u) { 1955 return this.converter.makeHtml(u) 1956 }; 1957 return t 1958 })(); 1959 o.Plugin.Unsupported = (function () { 1960 q(t, o.Plugin); 1961 1962 function t() { 1963 t.__super__.constructor.apply(this, arguments) 1964 } 1965 t.prototype.options = { 1966 message: "Sorry your current browser does not support the Annotator" 1967 }; 1968 t.prototype.pluginInit = function () { 1969 if (!o.supported()) { 1970 return h(g(function () { 1971 o.showNotification(this.options.message); 1972 if ((window.XMLHttpRequest === void 0) && (ActiveXObject !== void 0)) { 1973 return h("html").addClass("ie6") 1974 } 1975 }, this)) 1976 } 1977 }; 1978 return t 1979 })(); 1980 o.Plugin.Permissions = (function () { 1981 q(t, o.Plugin); 1982 t.prototype.events = { 1983 beforeAnnotationCreated: "addFieldsToAnnotation" 1984 }; 1985 t.prototype.options = { 1986 showViewPermissionsCheckbox: true, 1987 showEditPermissionsCheckbox: true, 1988 userId: function (u) { 1989 return u 1990 }, 1991 userString: function (u) { 1992 return u 1993 }, 1994 userAuthorize: function (u, v) { 1995 return this.userId(u) === v 1996 }, 1997 user: "", 1998 permissions: { 1999 read: [], 2000 update: [], 2001 "delete": [], 2002 admin: [] 2003 } 2004 }; 2005 2006 function t(v, u) { 2007 this.updateViewer = g(this.updateViewer, this); 2008 this.updateAnnotationPermissions = g(this.updateAnnotationPermissions, this); 2009 this.updatePermissionsField = g(this.updatePermissionsField, this); 2010 this.addFieldsToAnnotation = g(this.addFieldsToAnnotation, this); 2011 t.__super__.constructor.apply(this, arguments); 2012 if (this.options.user) { 2013 this.setUser(this.options.user); 2014 delete this.options.user 2015 } 2016 } 2017 t.prototype.pluginInit = function () { 2018 var u, v; 2019 if (!o.supported()) { 2020 return 2021 } 2022 v = this; 2023 u = function (x, w) { 2024 return function (z, y) { 2025 return v[x].call(v, w, z, y) 2026 } 2027 }; 2028 if (this.options.showViewPermissionsCheckbox === true) { 2029 this.annotator.editor.addField({ 2030 type: "checkbox", 2031 label: "Allow anyone to <strong>view</strong> this annotation", 2032 load: u("updatePermissionsField", "read"), 2033 submit: u("updateAnnotationPermissions", "read") 2034 }) 2035 } 2036 if (this.options.showEditPermissionsCheckbox === true) { 2037 this.annotator.editor.addField({ 2038 type: "checkbox", 2039 label: "Allow anyone to <strong>edit</strong> this annotation", 2040 load: u("updatePermissionsField", "update"), 2041 submit: u("updateAnnotationPermissions", "update") 2042 }) 2043 } 2044 this.annotator.viewer.addField({ 2045 load: this.updateViewer 2046 }); 2047 if (this.annotator.plugins.Filter) { 2048 return this.annotator.plugins.Filter.addFilter({ 2049 label: "User", 2050 property: "user", 2051 isFiltered: g(function (y, x) { 2052 var w, z, B, A; 2053 x = this.options.userString(x); 2054 if (!(y && x)) { 2055 return false 2056 } 2057 A = y.split(/\s*/); 2058 for (z = 0, B = A.length; z < B; z++) { 2059 w = A[z]; 2060 if (x.indexOf(w) === -1) { 2061 return false 2062 } 2063 } 2064 return true 2065 }, this) 2066 }) 2067 } 2068 }; 2069 t.prototype.setUser = function (u) { 2070 return this.user = u 2071 }; 2072 t.prototype.addFieldsToAnnotation = function (u) { 2073 if (u) { 2074 u.permissions = this.options.permissions; 2075 if (this.user) { 2076 return u.user = this.user 2077 } 2078 } 2079 }; 2080 t.prototype.authorize = function (y, u, v) { 2081 var w, z, x, A; 2082 if (v === void 0) { 2083 v = this.user 2084 } 2085 if (u.permissions) { 2086 z = u.permissions[y] || []; 2087 if (z.length === 0) { 2088 return true 2089 } 2090 for (x = 0, A = z.length; x < A; x++) { 2091 w = z[x]; 2092 if (this.options.userAuthorize.call(this.options, v, w)) { 2093 return true 2094 } 2095 } 2096 return false 2097 } else { 2098 if (u.user) { 2099 return v && this.options.userId(v) === u.user 2100 } 2101 } 2102 return true 2103 }; 2104 t.prototype.updatePermissionsField = function (w, y, u) { 2105 var x, v; 2106 y = h(y).show(); 2107 v = y.find("input").removeAttr("disabled"); 2108 if (!this.authorize("admin", u)) { 2109 y.hide() 2110 } 2111 if (this.authorize(w, u || {}, null)) { 2112 v.attr("checked", "checked"); 2113 x = { 2114 permissions: this.options.permissions 2115 }; 2116 if (this.authorize(w, x, null)) { 2117 return v.attr("disabled", "disabled") 2118 } 2119 } else { 2120 return v.removeAttr("checked") 2121 } 2122 }; 2123 t.prototype.updateAnnotationPermissions = function (w, x, u) { 2124 var y, v; 2125 if (!u.permissions) { 2126 u.permissions = this.options.permissions 2127 } 2128 y = w + "-permissions"; 2129 if (h(x).find("input").is(":checked")) { 2130 h.data(u, y, u.permissions[w]); 2131 return u.permissions[w] = [] 2132 } else { 2133 v = h.data(u, y); 2134 if (v) { 2135 return u.permissions[w] = v 2136 } 2137 } 2138 }; 2139 t.prototype.updateViewer = function (x, u, w) { 2140 var v, y; 2141 x = h(x); 2142 y = this.options.userString(u.user); 2143 if (u.user && y && typeof y === "string") { 2144 v = o.$.escape(this.options.userString(u.user)); 2145 x.html(v).addClass("annotator-user") 2146 } else { 2147 x.remove() 2148 } 2149 if (u.permissions) { 2150 if (!this.authorize("update", u)) { 2151 w.hideEdit() 2152 } 2153 if (!this.authorize("delete", u)) { 2154 return w.hideDelete() 2155 } 2156 } else { 2157 if (u.user && !this.authorize(null, u)) { 2158 w.hideEdit(); 2159 return w.hideDelete() 2160 } 2161 } 2162 }; 2163 return t 2164 })(); 2165 o.prototype.setupPlugins = function (w, E) { 2166 var B, D, u, t, y, v, A, C, z, x; 2167 if (w == null) { 2168 w = {} 2169 } 2170 if (E == null) { 2171 E = {} 2172 } 2173 z = a.getGlobal(); 2174 y = { 2175 Tags: {}, 2176 Filter: { 2177 filters: [{ 2178 label: "User", 2179 property: "user" 2180 }, { 2181 label: "Tags", 2182 property: "tags" 2183 }] 2184 }, 2185 Unsupported: {} 2186 }; 2187 if (z.Showdown) { 2188 y.Markdown = {} 2189 } 2190 A = w.userId, C = w.userName, B = w.accountId, D = w.authToken; 2191 if (A && C && B && D) { 2192 v = z.location.href.split(/#|\?/).shift() || ""; 2193 h.extend(y, { 2194 Store: { 2195 prefix: w.storeUri || "http://annotateit.org/api", 2196 annotationData: { 2197 uri: v 2198 }, 2199 loadFromSearch: { 2200 uri: v, 2201 all_fields: 1 2202 } 2203 }, 2204 Permissions: { 2205 user: { 2206 id: w.userId, 2207 name: w.userName 2208 }, 2209 permissions: { 2210 read: [w.userId], 2211 update: [w.userId], 2212 "delete": [w.userId], 2213 admin: [w.userId] 2214 }, 2215 userId: function (F) { 2216 if (F != null ? F.id : void 0) { 2217 return F.id 2218 } else { 2219 return "" 2220 } 2221 }, 2222 userString: function (F) { 2223 if (F != null ? F.name : void 0) { 2224 return F.name 2225 } else { 2226 return "" 2227 } 2228 } 2229 } 2230 }); 2231 this.element.data({ 2232 "annotator:headers": { 2233 "X-Annotator-User-Id": w.userId, 2234 "X-Annotator-Account-Id": w.accountId, 2235 "X-Annotator-Auth-Token": w.authToken 2236 } 2237 }) 2238 } 2239 h.extend(y, E); 2240 x = []; 2241 for (u in y) { 2242 if (!k.call(y, u)) { 2243 continue 2244 } 2245 t = y[u]; 2246 if (t !== null && t !== false) { 2247 x.push(this.addPlugin(u, t)) 2248 } 2249 } 2250 return x 2251 } 2252 }).call(this); -
main/trunk/model-cols-dev/peijones/js/documentmaker/PhotoNotes-1.5.js
r24780 r24821 276 276 { 277 277 textfield.focus(); 278 textfield.select();278 //textfield.select(); 279 279 } 280 280 catch(e) {} … … 333 333 var noteArea = document.createElement('div'); 334 334 noteArea.className = 'fn-note'; 335 335 noteArea.onmouseover = function(){_zoomEnabled = false;}; 336 noteArea.onmouseout = function(){_zoomEnabled = true;}; 336 337 var titleArea = document.createElement('div'); 337 338 titleArea.className = 'fn-note-text'; … … 356 357 newButtonOK.className = 'Butt'; 357 358 newButtonOK.value='SAVE'; 359 newButtonOK.onmouseover = function(){_zoomEnabled = false;}; 360 newButtonOK.onmouseout = function(){_zoomEnabled = true;}; 358 361 newButtonOK.onclick = function() { 359 362 if(currentNote.onsave) … … 385 388 newButtonCancel.className = 'CancelButt'; 386 389 newButtonCancel.value='CANCEL'; 390 newButtonCancel.onmouseover = function(){_zoomEnabled = false;}; 391 newButtonCancel.onmouseout = function(){_zoomEnabled = true;}; 387 392 newButtonCancel.onclick = function() { 388 393 currentNote.Cancel(); 389 390 394 }; 391 395 buttonsDiv.appendChild(newButtonCancel); … … 395 399 newButtonDelete.className = 'CancelButt'; 396 400 newButtonDelete.value='DELETE'; 401 newButtonDelete.onmouseover = function(){_zoomEnabled = false;}; 402 newButtonDelete.onmouseout = function(){_zoomEnabled = true;}; 397 403 newButtonDelete.onclick = function() { 398 404 … … 413 419 alert("ondelete must be implemented in order to *actually* delete"); 414 420 } 421 setTimeout(function(){_zoomEnabled = true;}, 100); 415 422 }; 416 423 buttonsDiv.appendChild(newButtonDelete); -
main/trunk/model-cols-dev/peijones/transform/pages/about.xsl
r24769 r24821 317 317 function getImages() 318 318 { 319 var url = "?a=g&s=GetAllImagesInCollection&rt=r&s1.extregex=Photo.*(jpg |png)&s1.c=" + gs.cgiParams.c + "&o=xml";319 var url = "?a=g&s=GetAllImagesInCollection&rt=r&s1.extregex=Photo.*(jpg$|png$)&s1.c=" + gs.cgiParams.c + "&o=xml"; 320 320 var callback = { 321 321 success: function(data)
Note:
See TracChangeset
for help on using the changeset viewer.