1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

Cleared out libs folder, use npm install or bower install instead. Cleaned examples. Fixed small issues in core.

This commit is contained in:
Fred Chasen 2015-09-16 13:05:08 -04:00
parent 1a782d0bd4
commit 2b6b7594c4
153 changed files with 2497 additions and 47756 deletions

View file

@ -8,9 +8,9 @@ module.exports = function(grunt) {
'<%= grunt.template.today("yyyy-mm-dd") %> */'
},
concat_sourcemap : {
'build/epub.js': ['<banner>', 'libs/rsvp/rsvp.js', 'src/*.js', 'libs/mime-types/mime-types.js'],
'build/epub.js': ['<banner>', 'node_modules/rsvp/dist/rsvp.js', 'src/*.js', 'libs/mime-types/mime-types.js'],
'build/reader.js': ['<banner>', 'reader_src/reader.js', 'reader_src/controllers/*.js'],
'build/hooks.js': ['<banner>', 'hooks/default/*.js'],
'build/hooks.js': ['<banner>', 'hooks/default/*.js']
},
uglify: {
my_target: {
@ -21,9 +21,7 @@ module.exports = function(grunt) {
files: {
'build/epub.min.js': ['build/epub.js'],
'build/reader.min.js': ['build/reader.js'],
'build/hooks.min.js': ['build/hooks.js'],
'build/libs/zip.min.js': ['libs/jszip/jszip.min.js'],
'build/libs/localforage.min.js': ['libs/localforage/localforage.min.js']
'build/hooks.min.js': ['build/hooks.js']
}
}
},
@ -36,10 +34,11 @@ module.exports = function(grunt) {
{src: 'build/epub.min.map', dest: 'reader/js/epub.js.map'},
{src: 'build/hooks.min.map', dest: 'reader/js/hooks.js.map'},
{src: 'build/reader.js.map', dest: 'reader/js/hooks.js.map'},
{src: 'node_modules/localforage/dist/localforage.min.js', dest: 'build/libs/localforage.min.js'},
{src: 'libs/jszip/jszip.min.js', dest: 'build/libs/zip.min.js'},
{src: 'build/libs/zip.min.js', dest: 'reader/js/libs/zip.min.js'},
// {src: 'build/libs/zip.min.js', dest: 'reader/js/libs/zip.min.map'},
{src: 'libs/jquery/jquery-2.1.0.min.js', dest:'reader/js/libs/jquery-2.1.0.min.js'},
{src: 'libs/screenfull.min.js', dest: 'reader/js/libs/screenfull.min.js'},
{src: 'node_modules/jquery/dist/jquery.min.js', dest:'reader/js/libs/jquery.min.js'},
{src: 'node_modules/screenfull/dist/screenfull.js', dest: 'reader/js/libs/screenfull.js'},
{src: 'reader_src/plugins/search.js', dest: 'reader/js/plugins/search.js'},
{src: 'reader_src/plugins/hypothesis.js', dest: 'reader/js/plugins/hypothesis.js'},
{src: 'hooks/extensions/highlight.js', dest: 'reader/js/hooks/extensions/highlight.js'}

View file

@ -25,6 +25,9 @@
],
"dependencies": {
"rsvp": "~3.0.8",
"underscore": "~1.8.3"
"underscore": "~1.8.3",
"polymer": "Polymer/polymer#^1.0.0",
"backbone": "~1.2.3",
"jquery-highlight": "~3.3.0"
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

14
build/epub.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,12 +10,13 @@ EPUBJS.reader.plugins = {}; //-- Attach extra Controllers as plugins (like searc
};
//exports to multiple environments
if (typeof define === 'function' && define.amd)
//AMD
define(function(){ return Reader; });
else if (typeof module != "undefined" && module.exports)
//Node
module.exports = ePubReader;
if (typeof define === 'function' && define.amd) {
//AMD
define(function(){ return Reader; });
} else if (typeof module != "undefined" && module.exports) {
//Node
module.exports = ePubReader;
}
})(window, jQuery);
@ -264,8 +265,8 @@ EPUBJS.Reader.prototype.applySavedSettings = function() {
if(stored) {
// Merge styles
if(store.styles) {
this.settings.styles = EPUBJS.core.defaults(this.settings.styles, store.styles);
if(stored.styles) {
this.settings.styles = EPUBJS.core.defaults(this.settings.styles || {}, stored.styles);
}
// Merge the rest
this.settings = EPUBJS.core.defaults(this.settings, stored);

File diff suppressed because one or more lines are too long

2
build/reader.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -8,12 +8,12 @@
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../libs/polymer/custom-elements.min.js"></script>
<script src="../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!-- <script src="../libs/polymer/custom-elements.min.js"></script> -->
<!-- EPUBJS Renderer -->
<script src="../build/epub.min.js"></script>
<link rel="stylesheet" href="basic.css">
<style type="text/css">
@ -40,7 +40,7 @@
border: none;
padding: 40px 40px;
}
iframe {
border: none;
}
@ -50,16 +50,16 @@
}
</style>
<script>
"use strict";
var epubPrototype = Object.create(HTMLElement.prototype);
epubPrototype.readyCallback = function() {
epubPrototype.readyCallback = function() {
this.create();
this.Book.renderTo(this);
this.Book.renderTo(this);
};
epubPrototype.create = function() {
@ -102,10 +102,10 @@
</div>
<div id="next" onclick="Book.nextPage();"class="arrow"></div>
</div>
<script>
Book = document.getElementById("book");
<script>
Book = document.getElementById("book");
</script>
</body>

View file

@ -11,8 +11,8 @@
<link rel="stylesheet" href="../reader/css/normalize.css">
<link rel="stylesheet" href="../reader/css/main.css">
<link rel="stylesheet" href="../reader/css/popup.css">
<script src="../libs/jquery/jquery-2.1.0.js"></script>
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script>
"use strict";
@ -24,45 +24,45 @@
}
};
document.onreadystatechange = function () {
document.onreadystatechange = function () {
if (document.readyState == "complete") {
EPUBJS.VERSION = "0.1.6";
EPUBJS.filePath = "js/libs/";
EPUBJS.cssPath = "../reader/css/";
// fileStorage.filePath = EPUBJS.filePath;
ePubReader("../reader/moby-dick/");
}
}
};
</script>
<!-- Render -->
<script src="../reader/js/epub.min.js"></script>
<!-- Hooks -->
<script src="../reader/js/hooks.min.js"></script>
<script src="../reader/js/hooks.min.js"></script>
<!-- Reader -->
<script src="../reader/js/reader.min.js"></script>
<!-- Plugins -->
<script src="../reader/plugins/search.js"></script>
<!-- <script src="../reader/plugins/search.js"></script> -->
<!-- Full Screen -->
<script src="../reader/js/libs/screenfull.min.js"></script>
<!-- Highlights -->
<script src="../reader/js/libs/jquery.highlight.js"></script>
<script src="./bower_components/jquery-highlight/jquery.highlight.js"></script>
<script src="../hooks/extensions/highlight.js"></script>
<!-- Hypothes.is -->
<script async src="../hooks/extensions/hypothesis.js"></script>
<script src="../reader_src/plugins/hypothesis.js"></script>
<script src="https://hypothes.is/app/embed.js"></script>
<style>
#hypothesis {
position: absolute;
@ -75,7 +75,7 @@
z-index: 0;
background: #4e4e4e;
}
#hypothesis .annotator-frame {
background: none;
position: absolute;
@ -84,28 +84,28 @@
width: 100%;
z-index: auto;
}
#annotator-notice {
display: none;
}
#main {
left: 0;
}
#main.single {
width: 66%;
}
#main.single.closed {
-webkit-transform: translate(51.6%, 0);
-moz-transform: translate(51.6%, 0);
}
#sidebar {
width: 34%
}
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
@ -122,7 +122,7 @@
<div id="sidebar">
<div id="panels">
<input id="searchBox" placeholder="search" type="search">
<a id="show-Search" class="show_view icon-search" data-view="Search">Search</a>
<a id="show-Toc" class="show_view icon-list-1 active" data-view="Toc">TOC</a>
<a id="show-Bookmarks" class="show_view icon-bookmark" data-view="Bookmarks">Bookmarks</a>
@ -146,7 +146,7 @@
</div>
<div id="hypothesis"></div>
<div id="main">
<div id="titlebar">
<div id="opener">
<a id="slider" class="icon-menu">Menu</a>
@ -163,12 +163,12 @@
<a id="annotations" class="h-icon-comment"></a>
</div>
</div>
<div id="divider"></div>
<div id="prev" class="arrow noselect"></div>
<div id="viewer"></div>
<div id="next" class="arrow noselect"></div>
<div id="loader"><img src="../reader/img/loader.gif"></div>
</div>
<div class="modal md-effect-1" id="settings-modal">

View file

@ -1,91 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Basic ePubJS Example</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../build/epub.js"></script>
<script src="../build/libs/zip.min.js"></script>
<style type="text/css">
body {
}
#main {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
#area {
width: 80%;
height: 80%;
margin: 5% auto;
max-width: 1250px;
}
#area iframe {
border: none;
}
#prev {
left: 40px;
}
#next {
right: 40px;
}
.arrow {
position: absolute;
top: 50%;
margin-top: -32px;
font-size: 64px;
color: #E2E2E2;
font-family: arial, sans-serif;
font-weight: bold;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.arrow:hover {
color: #777;
}
.arrow:active {
color: #000;
}
</style>
<script>
"use strict";
window.book = ePub("https://s3.amazonaws.com/moby-dick/", {restore: true, reload: true });
</script>
</head>
<body>
<div id="main">
<div id="prev" onclick="book.prevPage();" class="arrow"></div>
<div id="area"></div>
<div id="next" onclick="book.nextPage();" class="arrow"></div>
</div>
<script>
book.renderTo("area");
</script>
</body>
</html>

View file

@ -7,7 +7,6 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Zip Support -->
<script src="../build/libs/zip.min.js"></script>

File diff suppressed because it is too large Load diff

View file

@ -1,892 +0,0 @@
/* Base Reset
-------------------------------------------------------------------- */
.annotator-notice,
.annotator-filter *,
.annotator-widget * {
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
font-weight: normal;
text-align: left;
margin: 0;
padding: 0;
background: none;
-webkit-transition: none;
-moz-transition: none;
-o-transition: none;
transition: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
-o-box-shadow: none;
box-shadow: none;
color: rgb(144, 144, 144);
}
/* Images
-------------------------------------------------------------------- */
.annotator-adder {
background-image: url(../img/annotator-icon-sprite.png);
background-repeat: no-repeat;
}
.annotator-resize,
.annotator-widget::after,
.annotator-editor a::after,
.annotator-viewer .annotator-controls button,
.annotator-viewer .annotator-controls a,
.annotator-filter .annotator-filter-navigation button::after,
.annotator-filter .annotator-filter-property .annotator-filter-clear {
background-image: url(../img/annotator-glyph-sprite.png);
background-repeat: no-repeat;
}
/* Annotator Highlight
-------------------------------------------------------------------- */
.annotator-hl {
background: rgba(255, 255, 10, 0.3);
}
.annotator-hl-temporary {
background: rgba(0, 124, 255, 0.3);
}
/* Annotator Wrapper
-------------------------------------------------------------------- */
.annotator-wrapper {
position: relative;
}
/* NB: If you change the list of classes for which z-index is set,
you should update Annotator._setupDynamicStyle() */
.annotator-adder,
.annotator-outer,
.annotator-notice {
z-index: 1020;
}
.annotator-filter {
z-index: 1010;
}
.annotator-adder,
.annotator-outer,
.annotator-widget,
.annotator-notice {
position: absolute;
font-size: 10px;
line-height: 1;
}
.annotator-adder,
.annotator-outer {
position: fixed;
}
.annotator-hide {
display: none;
visibility: hidden;
}
/* Annotator Adder
-------------------------------------------------------------------- */
.annotator-adder {
margin-top: -48px;
margin-left: -24px;
width: 48px;
height: 48px;
background-position: left top;
}
.annotator-adder:hover {
background-position: center top;
}
.annotator-adder:active {
background-position: center right;
}
.annotator-adder button {
display: block;
width: 36px;
height: 41px;
margin: 0 auto;
border: none;
background: none;
text-indent: -999em;
cursor: pointer;
}
/* Annotator Widget
This applies to both the Viewer and the Editor
-------------------------------------------------------------------- */
.annotator-outer {
width: 0;
height: 0;
}
.annotator-widget {
margin: 0;
padding: 0;
bottom: 15px;
left: -18px;
min-width: 265px;
background-color: rgba(251, 251, 251, 0.98);
border: 1px solid rgba(122, 122, 122, 0.6);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
-o-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.annotator-invert-x .annotator-widget {
left: auto;
right: -18px;
}
.annotator-invert-y .annotator-widget {
bottom: auto;
top: 8px;
}
.annotator-widget strong {
font-weight: bold;
}
.annotator-widget .annotator-listing,
.annotator-widget .annotator-item {
padding: 0;
margin: 0;
list-style: none;
}
.annotator-widget::after {
content: "";
display: block;
width: 18px;
height: 10px;
background-position: 0 0;
position: absolute;
bottom: -10px;
left: 8px;
}
.annotator-invert-x .annotator-widget::after {
left: auto;
right: 8px;
}
.annotator-invert-y .annotator-widget::after {
background-position: 0 -15px;
bottom: auto;
top: -9px;
}
.annotator-widget .annotator-item,
.annotator-editor .annotator-item input,
.annotator-editor .annotator-item textarea {
position: relative;
font-size: 12px;
}
.annotator-viewer .annotator-item {
border-top: 2px solid rgba(122, 122, 122, 0.2);
}
.annotator-widget .annotator-item:first-child {
border-top: none;
}
.annotator-editor .annotator-item,
.annotator-viewer div {
border-top: 1px solid rgba(133, 133, 133, 0.11);
}
/* Annotator Viewer
-------------------------------------------------------------------- */
.annotator-viewer div {
padding: 6px 6px;
}
.annotator-viewer .annotator-item ol,
.annotator-viewer .annotator-item ul {
padding: 4px 16px;
}
.annotator-viewer .annotator-item li {
}
.annotator-viewer div:first-of-type,
.annotator-editor .annotator-item:first-child textarea {
padding-top: 12px;
padding-bottom: 12px;
color: rgb(60, 60, 60);
font-size: 13px;
font-style: italic;
line-height: 1.3;
border-top: none;
}
.annotator-viewer .annotator-controls {
position: relative;
top: 5px;
right: 5px;
padding-left: 5px;
opacity: 0;
-webkit-transition: opacity 0.2s ease-in;
-moz-transition: opacity 0.2s ease-in;
-o-transition: opacity 0.2s ease-in;
transition: opacity 0.2s ease-in;
float: right;
}
.annotator-viewer li:hover .annotator-controls,
.annotator-viewer li .annotator-controls.annotator-visible {
opacity: 1;
}
.annotator-viewer .annotator-controls button,
.annotator-viewer .annotator-controls a {
cursor: pointer;
display: inline-block;
width: 13px;
height: 13px;
margin-left: 2px;
border: none;
opacity: 0.2;
text-indent: -900em;
background-color: transparent;
outline: none;
}
.annotator-viewer .annotator-controls button:hover,
.annotator-viewer .annotator-controls button:focus,
.annotator-viewer .annotator-controls a:hover,
.annotator-viewer .annotator-controls a:focus {
opacity: 0.9;
}
.annotator-viewer .annotator-controls button:active,
.annotator-viewer .annotator-controls a:active {
opacity: 1;
}
.annotator-viewer .annotator-controls button[disabled] {
display: none;
}
.annotator-viewer .annotator-controls .annotator-edit {
background-position: 0 -60px;
}
.annotator-viewer .annotator-controls .annotator-delete {
background-position: 0 -75px;
}
.annotator-viewer .annotator-controls .annotator-link {
background-position: 0 -270px;
}
/* Annotator Editor
-------------------------------------------------------------------- */
.annotator-editor .annotator-item {
position: relative;
}
.annotator-editor .annotator-item label {
top: 0;
display: inline;
cursor: pointer;
font-size: 12px;
}
.annotator-editor .annotator-item input,
.annotator-editor .annotator-item textarea {
display: block;
min-width: 100%;
padding: 10px 8px;
border: none;
margin: 0;
color: rgb(60, 60, 60);
background: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
resize: none;
}
.annotator-editor .annotator-item textarea::-webkit-scrollbar {
height: 8px;
width: 8px;
}
.annotator-editor .annotator-item textarea::-webkit-scrollbar-track-piece {
margin: 13px 0 3px;
background-color: #e5e5e5;
-webkit-border-radius: 4px;
}
.annotator-editor .annotator-item textarea::-webkit-scrollbar-thumb:vertical {
height: 25px;
background-color: #ccc;
-webkit-border-radius: 4px;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
.annotator-editor .annotator-item textarea::-webkit-scrollbar-thumb:horizontal {
width: 25px;
background-color: #ccc;
-webkit-border-radius: 4px;
}
.annotator-editor .annotator-item:first-child textarea {
min-height: 5.5em;
-webkit-border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-o-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
}
.annotator-editor .annotator-item input:focus,
.annotator-editor .annotator-item textarea:focus{
background-color: rgb(243, 243, 243);
outline: none;
}
.annotator-editor .annotator-item input[type=radio],
.annotator-editor .annotator-item input[type=checkbox] {
width: auto;
min-width: 0;
padding: 0;
display: inline;
margin: 0 4px 0 0;
cursor: pointer;
}
.annotator-editor .annotator-checkbox {
padding: 8px 6px;
}
.annotator-filter,
.annotator-filter .annotator-filter-navigation button,
.annotator-editor .annotator-controls {
text-align: right;
padding: 3px;
border-top: 1px solid rgb(212,212,212);
background-color: rgb(212, 212, 212);
background-image: -webkit-gradient(
linear, left top, left bottom,
from(rgb(245, 245, 245)),
color-stop(0.6, rgb(220, 220, 220)),
to(rgb(210, 210, 210))
);
background-image: -moz-linear-gradient(
to bottom,
rgb(245, 245, 245),
rgb(220, 220, 220) 60%,
rgb(210, 210, 210)
);
background-image: -webkit-linear-gradient(
to bottom,
rgb(245, 245, 245),
rgb(220, 220, 220) 60%,
rgb(210, 210, 210)
);
background-image: linear-gradient(
to bottom,
rgb(245, 245, 245),
rgb(220, 220, 220) 60%,
rgb(210, 210, 210)
);
-webkit-box-shadow:
inset 1px 0 0 rgba(255, 255, 255, 0.7),
inset -1px 0 0 rgba(255, 255, 255, 0.7),
inset 0 1px 0 rgba(255, 255, 255, 0.7);
-moz-box-shadow:
inset 1px 0 0 rgba(255, 255, 255, 0.7),
inset -1px 0 0 rgba(255, 255, 255, 0.7),
inset 0 1px 0 rgba(255, 255, 255, 0.7);
-o-box-shadow:
inset 1px 0 0 rgba(255, 255, 255, 0.7),
inset -1px 0 0 rgba(255, 255, 255, 0.7),
inset 0 1px 0 rgba(255, 255, 255, 0.7);
box-shadow:
inset 1px 0 0 rgba(255, 255, 255, 0.7),
inset -1px 0 0 rgba(255, 255, 255, 0.7),
inset 0 1px 0 rgba(255, 255, 255, 0.7);
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-o-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
}
.annotator-editor.annotator-invert-y .annotator-controls {
border-top: none;
border-bottom: 1px solid rgb(180, 180, 180);
-webkit-border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-o-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
}
.annotator-editor a,
.annotator-filter .annotator-filter-property label {
position: relative;
display: inline-block;
padding: 0 6px 0 22px;
color: rgb(54, 54, 54);
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
text-decoration: none;
line-height: 24px;
font-size: 12px;
font-weight: bold;
border: 1px solid rgb(162, 162, 162);
background-color: rgb(212, 212, 212);
background-image: -webkit-gradient(
linear, left top, left bottom,
from(rgb(245, 245, 245)),
color-stop(0.5, rgb(210, 210, 210)),
color-stop(0.5, rgb(190, 190, 190)),
to(rgb(210, 210, 210))
);
background-image: -moz-linear-gradient(
to bottom,
rgb(245, 245, 245),
rgb(210, 210, 210) 50%,
rgb(190, 190, 190) 50%,
rgb(210, 210, 210)
);
background-image: -webkit-linear-gradient(
to bottom,
rgb(245, 245, 245),
rgb(210, 210, 210) 50%,
rgb(190, 190, 190) 50%,
rgb(210, 210, 210)
);
background-image: linear-gradient(
to bottom,
rgb(245, 245, 245),
rgb(210, 210, 210) 50%,
rgb(190, 190, 190) 50%,
rgb(210, 210, 210)
);
-webkit-box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
-moz-box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
-o-box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
}
.annotator-editor a::after {
position: absolute;
top: 50%;
left: 5px;
display: block;
content: "";
width: 15px;
height: 15px;
margin-top: -7px;
background-position: 0 -90px;
}
.annotator-editor a:hover,
.annotator-editor a:focus,
.annotator-editor a.annotator-focus,
.annotator-filter .annotator-filter-active label,
.annotator-filter .annotator-filter-navigation button:hover {
outline: none;
border-color: rgb(67, 90, 160);
background-color: rgb(56, 101, 249);
background-image: -webkit-gradient(
linear, left top, left bottom,
from(rgb(118, 145, 251)),
color-stop(0.5, rgb(80, 117, 251)),
color-stop(0.5, rgb(56, 101, 249)),
to(rgb(54, 101, 250))
);
background-image: -moz-linear-gradient(
to bottom,
rgb(118, 145, 251),
rgb(80, 117, 251) 50%,
rgb(56, 101, 249) 50%,
rgb(54, 101, 250)
);
background-image: -webkit-linear-gradient(
to bottom,
rgb(118, 145, 251),
rgb(80, 117, 251) 50%,
rgb(56, 101, 249) 50%,
rgb(54, 101, 250)
);
background-image: linear-gradient(
to bottom,
rgb(118, 145, 251),
rgb(80, 117, 251) 50%,
rgb(56, 101, 249) 50%,
rgb(54, 101, 250)
);
color: rgb(255, 255, 255);
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.42);
}
.annotator-editor a:hover::after,
.annotator-editor a:focus::after {
margin-top: -8px;
background-position: 0 -105px;
}
.annotator-editor a:active,
.annotator-filter .annotator-filter-navigation button:active {
border-color: rgb(112, 12, 73);
background-color: rgb(209, 46, 142);
background-image: -webkit-gradient(
linear, left top, left bottom,
from(rgb(252, 124, 202)),
color-stop(0.5, rgb(232, 93, 178)),
color-stop(0.5, rgb(209, 46, 142)),
to(rgb(255, 0, 156))
);
background-image: -moz-linear-gradient(
to bottom,
rgb(252, 124, 202),
rgb(232, 93, 178) 50%,
rgb(209, 46, 142) 50%,
rgb(255, 0, 156)
);
background-image: -webkit-linear-gradient(
to bottom,
rgb(252, 124, 202),
rgb(232, 93, 178) 50%,
rgb(209, 46, 142) 50%,
rgb(255, 0, 156)
);
background-image: linear-gradient(
to bottom,
rgb(252, 124, 202),
rgb(232, 93, 178) 50%,
rgb(209, 46, 142) 50%,
rgb(255, 0, 156)
);
}
.annotator-editor a.annotator-save::after {
background-position: 0 -120px;
}
.annotator-editor a.annotator-save:hover::after,
.annotator-editor a.annotator-save:focus::after,
.annotator-editor a.annotator-save.annotator-focus::after {
margin-top: -8px;
background-position: 0 -135px;
}
.annotator-editor .annotator-widget::after {
background-position: 0 -30px;
}
.annotator-editor.annotator-invert-y .annotator-widget .annotator-controls {
background-color: #f2f2f2;
}
.annotator-editor.annotator-invert-y .annotator-widget::after {
background-position: 0 -45px;
height: 11px;
}
.annotator-resize {
position: absolute;
top: 0;
right: 0;
width: 12px;
height: 12px;
background-position: 2px -150px;
}
.annotator-invert-x .annotator-resize {
right: auto;
left: 0;
background-position: 0 -195px;
}
.annotator-invert-y .annotator-resize {
top: auto;
bottom: 0;
background-position: 2px -165px;
}
.annotator-invert-y.annotator-invert-x .annotator-resize {
background-position: 0 -180px;
}
/* Annotator Notification
-------------------------------------------------------------------- */
.annotator-notice {
color: #fff;
position: absolute;
position: fixed;
top: -54px;
left: 0;
width: 100%;
font-size: 14px;
line-height: 50px;
text-align: center;
background: black;
background: rgba(0, 0, 0, 0.9);
border-bottom: 4px solid #d4d4d4;
-webkit-transition: top 0.4s ease-out;
-moz-transition: top 0.4s ease-out;
-o-transition: top 0.4s ease-out;
transition: top 0.4s ease-out;
}
.ie6 .annotator-notice {
position: absolute;
}
.annotator-notice-success {
border-color: #3665f9;
}
.annotator-notice-error {
border-color: #ff7e00;
}
.annotator-notice p {
margin: 0;
}
.annotator-notice a {
color: #fff;
}
.annotator-notice-show {
top: 0;
}
/* Annotator Tags Plugin
-------------------------------------------------------------------- */
.annotator-tags {
margin-bottom: -2px;
}
.annotator-tags .annotator-tag {
display: inline-block;
padding: 0 8px;
margin-bottom: 2px;
line-height: 1.6;
font-weight: bold;
background-color: rgb(230, 230, 230);
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
-o-border-radius: 8px;
border-radius: 8px;
}
/* Annotator Filter Plugin
-------------------------------------------------------------------- */
.annotator-filter {
position: fixed;
top: 0;
right: 0;
left: 0;
text-align: left;
line-height: 0;
border: none;
border-bottom: 1px solid #878787;
padding-left: 10px;
padding-right: 10px;
-webkit-border-radius: 0;
-moz-border-radius: 0;
-o-border-radius: 0;
border-radius: 0;
-webkit-box-shadow:
inset 0 -1px 0 rgba(255, 255, 255, 0.3);
-moz-box-shadow:
inset 0 -1px 0 rgba(255, 255, 255, 0.3);
-o-box-shadow:
inset 0 -1px 0 rgba(255, 255, 255, 0.3);
box-shadow:
inset 0 -1px 0 rgba(255, 255, 255, 0.3);
}
.annotator-filter strong {
font-size: 12px;
font-weight: bold;
color: #3c3c3c;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
position: relative;
top: -9px;
}
.annotator-filter .annotator-filter-property,
.annotator-filter .annotator-filter-navigation {
position: relative;
display: inline-block;
overflow: hidden;
line-height: 10px;
padding: 2px 0;
margin-right: 8px;
}
.annotator-filter .annotator-filter-property label,
.annotator-filter .annotator-filter-navigation button {
text-align: left;
display: block;
float: left;
line-height: 20px;
-webkit-border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
-o-border-radius: 10px 0 0 10px;
border-radius: 10px 0 0 10px;
}
.annotator-filter .annotator-filter-property label {
padding-left: 8px;
}
.annotator-filter .annotator-filter-property input {
display: block;
float: right;
-webkit-appearance: none;
background-color: #fff;
border: 1px solid #878787;
border-left: none;
padding: 2px 4px;
line-height: 16px;
min-height: 16px;
font-size: 12px;
width: 150px;
color: #333;
background-color: #f8f8f8;
-webkit-border-radius: 0 10px 10px 0;
-moz-border-radius: 0 10px 10px 0;
-o-border-radius: 0 10px 10px 0;
border-radius: 0 10px 10px 0;
-webkit-box-shadow:
inset 0 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow:
inset 0 1px 1px rgba(0, 0, 0, 0.2);
-o-box-shadow:
inset 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow:
inset 0 1px 1px rgba(0, 0, 0, 0.2);
}
.annotator-filter .annotator-filter-property input:focus {
outline: none;
background-color: #fff;
}
.annotator-filter .annotator-filter-clear {
position: absolute;
right: 3px;
top: 6px;
border: none;
text-indent: -900em;
width: 15px;
height: 15px;
background-position: 0 -90px;
opacity: 0.4;
}
.annotator-filter .annotator-filter-clear:hover,
.annotator-filter .annotator-filter-clear:focus {
opacity: 0.8;
}
.annotator-filter .annotator-filter-clear:active {
opacity: 1;
}
.annotator-filter .annotator-filter-navigation button {
border: 1px solid rgb(162, 162, 162);
padding: 0;
text-indent: -900px;
width: 20px;
min-height: 22px;
-webkit-box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
-moz-box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
-o-box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
box-shadow:
inset 0 0 5px rgba(255, 255, 255, 0.2),
inset 0 0 1px rgba(255, 255, 255, 0.8);
}
.annotator-filter .annotator-filter-navigation button,
.annotator-filter .annotator-filter-navigation button:hover,
.annotator-filter .annotator-filter-navigation button:focus {
color: transparent;
}
.annotator-filter .annotator-filter-navigation button::after {
position: absolute;
top: 8px;
left: 8px;
content: "";
display: block;
width: 9px;
height: 9px;
background-position: 0 -210px;
}
.annotator-filter .annotator-filter-navigation button:hover::after {
background-position: 0 -225px;
}
.annotator-filter .annotator-filter-navigation .annotator-filter-next {
-webkit-border-radius: 0 10px 10px 0;
-moz-border-radius: 0 10px 10px 0;
-o-border-radius: 0 10px 10px 0;
border-radius: 0 10px 10px 0;
border-left: none;
}
.annotator-filter .annotator-filter-navigation .annotator-filter-next::after {
left: auto;
right: 7px;
background-position: 0 -240px;
}
.annotator-filter .annotator-filter-navigation .annotator-filter-next:hover::after {
background-position: 0 -255px;
}
.annotator-hl-active {
background: rgba(255, 255, 10, 0.8);
}
.annotator-hl-filtered {
background-color: transparent;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

View file

@ -1,595 +0,0 @@
// Generated by CoffeeScript 1.6.3
var Annotator, g, _Annotator, _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
_Annotator = this.Annotator;
Annotator = (function(_super) {
__extends(Annotator, _super);
Annotator.prototype.events = {
".annotator-adder button click": "onAdderClick",
".annotator-adder button mousedown": "onAdderMousedown",
".annotator-hl mouseover": "onHighlightMouseover",
".annotator-hl mouseout": "startViewerHideTimer"
};
Annotator.prototype.html = {
adder: '<div class="annotator-adder"><button>' + _t('Annotate') + '</button></div>',
wrapper: '<div class="annotator-wrapper"></div>'
};
Annotator.prototype.options = {
readOnly: false
};
Annotator.prototype.plugins = {};
Annotator.prototype.editor = null;
Annotator.prototype.viewer = null;
Annotator.prototype.selectedRanges = null;
Annotator.prototype.mouseIsDown = false;
Annotator.prototype.ignoreMouseup = false;
Annotator.prototype.viewerHideTimer = null;
function Annotator(element, options) {
this.onDeleteAnnotation = __bind(this.onDeleteAnnotation, this);
this.onEditAnnotation = __bind(this.onEditAnnotation, this);
this.onAdderClick = __bind(this.onAdderClick, this);
this.onAdderMousedown = __bind(this.onAdderMousedown, this);
this.onHighlightMouseover = __bind(this.onHighlightMouseover, this);
this.checkForEndSelection = __bind(this.checkForEndSelection, this);
this.checkForStartSelection = __bind(this.checkForStartSelection, this);
this.clearViewerHideTimer = __bind(this.clearViewerHideTimer, this);
this.startViewerHideTimer = __bind(this.startViewerHideTimer, this);
this.showViewer = __bind(this.showViewer, this);
this.onEditorSubmit = __bind(this.onEditorSubmit, this);
this.onEditorHide = __bind(this.onEditorHide, this);
this.showEditor = __bind(this.showEditor, this);
Annotator.__super__.constructor.apply(this, arguments);
this.plugins = {};
this.document = element.ownerDocument || document;
if (!Annotator.supported()) {
return this;
}
if (!this.options.readOnly) {
this._setupDocumentEvents();
}
this._setupWrapper()._setupViewer()._setupEditor();
this._setupDynamicStyle();
this.adder = $(this.html.adder).appendTo(this.wrapper).hide();
Annotator._instances.push(this);
}
Annotator.prototype._setupWrapper = function() {
this.wrapper = $(this.html.wrapper);
this.element.find('script').remove();
this.element.wrapInner(this.wrapper);
this.wrapper = this.element.find('.annotator-wrapper');
return this;
};
Annotator.prototype._setupViewer = function() {
var _this = this;
this.viewer = new Annotator.Viewer({
readOnly: this.options.readOnly
});
this.viewer.hide().on("edit", this.onEditAnnotation).on("delete", this.onDeleteAnnotation).addField({
load: function(field, annotation) {
if (annotation.text) {
$(field).html(Util.escape(annotation.text));
} else {
$(field).html("<i>" + (_t('No Comment')) + "</i>");
}
return _this.publish('annotationViewerTextField', [field, annotation]);
}
}).element.appendTo(this.wrapper).bind({
"mouseover": this.clearViewerHideTimer,
"mouseout": this.startViewerHideTimer
});
return this;
};
Annotator.prototype._setupEditor = function() {
this.editor = new Annotator.Editor();
this.editor.hide().on('hide', this.onEditorHide).on('save', this.onEditorSubmit).addField({
type: 'textarea',
label: _t('Comments') + '\u2026',
load: function(field, annotation) {
return $(field).find('textarea').val(annotation.text || '');
},
submit: function(field, annotation) {
return annotation.text = $(field).find('textarea').val();
}
});
this.editor.element.appendTo(this.wrapper);
return this;
};
Annotator.prototype._setupDocumentEvents = function() {
$(this.document).bind({
"mouseup": this.checkForEndSelection,
"mousedown": this.checkForStartSelection
});
return this;
};
Annotator.prototype._setupDynamicStyle = function() {
var max, sel, style, x;
style = $('#annotator-dynamic-style');
if (!style.length) {
style = $('<style id="annotator-dynamic-style"></style>').appendTo(this.document.head);
}
sel = '*' + ((function() {
var _i, _len, _ref, _results;
_ref = ['adder', 'outer', 'notice', 'filter'];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
x = _ref[_i];
_results.push(":not(.annotator-" + x + ")");
}
return _results;
})()).join('');
max = Util.maxZIndex($(this.document.body).find(sel));
max = Math.max(max, 1000);
style.text([".annotator-adder, .annotator-outer, .annotator-notice {", " z-index: " + (max + 20) + ";", "}", ".annotator-filter {", " z-index: " + (max + 10) + ";", "}"].join("\n"));
return this;
};
Annotator.prototype.destroy = function() {
var idx, name, plugin, _ref;
$(this.document).unbind({
"mouseup": this.checkForEndSelection,
"mousedown": this.checkForStartSelection
});
$('#annotator-dynamic-style').remove();
this.adder.remove();
this.viewer.destroy();
this.editor.destroy();
this.wrapper.find('.annotator-hl').each(function() {
$(this).contents().insertBefore(this);
return $(this).remove();
});
this.wrapper.contents().insertBefore(this.wrapper);
this.wrapper.remove();
this.element.data('annotator', null);
_ref = this.plugins;
for (name in _ref) {
plugin = _ref[name];
this.plugins[name].destroy();
}
this.removeEvents();
idx = Annotator._instances.indexOf(this);
if (idx !== -1) {
return Annotator._instances.splice(idx, 1);
}
};
Annotator.prototype.getSelectedRanges = function() {
var browserRange, i, normedRange, r, ranges, rangesToIgnore, selection, _i, _len;
selection = this.document.getSelection();
ranges = [];
rangesToIgnore = [];
if (!selection.isCollapsed) {
ranges = (function() {
var _i, _ref, _results;
_results = [];
for (i = _i = 0, _ref = selection.rangeCount; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
r = selection.getRangeAt(i);
browserRange = new Range.BrowserRange(r);
normedRange = browserRange.normalize().limit(this.wrapper[0]);
if (normedRange === null) {
rangesToIgnore.push(r);
}
_results.push(normedRange);
}
return _results;
}).call(this);
selection.removeAllRanges();
}
for (_i = 0, _len = rangesToIgnore.length; _i < _len; _i++) {
r = rangesToIgnore[_i];
selection.addRange(r);
}
return $.grep(ranges, function(range) {
if (range) {
selection.addRange(range.toRange());
}
return range;
});
};
Annotator.prototype.createAnnotation = function() {
var annotation;
annotation = {};
this.publish('beforeAnnotationCreated', [annotation]);
return annotation;
};
Annotator.prototype.setupAnnotation = function(annotation) {
var e, normed, normedRanges, r, root, _i, _j, _len, _len1, _ref;
root = this.wrapper[0];
annotation.ranges || (annotation.ranges = this.selectedRanges);
normedRanges = [];
_ref = annotation.ranges;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
r = _ref[_i];
try {
normedRanges.push(Range.sniff(r).normalize(root));
} catch (_error) {
e = _error;
if (e instanceof Range.RangeError) {
this.publish('rangeNormalizeFail', [annotation, r, e]);
} else {
throw e;
}
}
}
annotation.quote = [];
annotation.ranges = [];
annotation.highlights = [];
for (_j = 0, _len1 = normedRanges.length; _j < _len1; _j++) {
normed = normedRanges[_j];
annotation.quote.push($.trim(normed.text()));
annotation.ranges.push(normed.serialize(this.wrapper[0], '.annotator-hl'));
$.merge(annotation.highlights, this.highlightRange(normed));
}
annotation.quote = annotation.quote.join(' / ');
$(annotation.highlights).data('annotation', annotation);
return annotation;
};
Annotator.prototype.updateAnnotation = function(annotation) {
this.publish('beforeAnnotationUpdated', [annotation]);
this.publish('annotationUpdated', [annotation]);
return annotation;
};
Annotator.prototype.deleteAnnotation = function(annotation) {
var child, h, _i, _len, _ref;
if (annotation.highlights != null) {
_ref = annotation.highlights;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
h = _ref[_i];
if (!(h.parentNode != null)) {
continue;
}
child = h.childNodes[0];
$(h).replaceWith(h.childNodes);
}
}
this.publish('annotationDeleted', [annotation]);
return annotation;
};
Annotator.prototype.loadAnnotations = function(annotations) {
var clone, loader,
_this = this;
if (annotations == null) {
annotations = [];
}
loader = function(annList) {
var n, now, _i, _len;
if (annList == null) {
annList = [];
}
now = annList.splice(0, 10);
for (_i = 0, _len = now.length; _i < _len; _i++) {
n = now[_i];
_this.setupAnnotation(n);
}
if (annList.length > 0) {
return setTimeout((function() {
return loader(annList);
}), 10);
} else {
return _this.publish('annotationsLoaded', [clone]);
}
};
clone = annotations.slice();
if (annotations.length) {
loader(annotations);
}
return this;
};
Annotator.prototype.dumpAnnotations = function() {
if (this.plugins['Store']) {
return this.plugins['Store'].dumpAnnotations();
} else {
console.warn(_t("Can't dump annotations without Store plugin."));
return false;
}
};
Annotator.prototype.highlightRange = function(normedRange, cssClass) {
var hl, node, white, _i, _len, _ref, _results;
if (cssClass == null) {
cssClass = 'annotator-hl';
}
white = /^\s*$/;
hl = $("<span class='" + cssClass + "'></span>");
_ref = normedRange.textNodes();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
node = _ref[_i];
if (!white.test(node.nodeValue)) {
_results.push($(node).wrapAll(hl).parent().show()[0]);
}
}
return _results;
};
Annotator.prototype.highlightRanges = function(normedRanges, cssClass) {
var highlights, r, _i, _len;
if (cssClass == null) {
cssClass = 'annotator-hl';
}
highlights = [];
for (_i = 0, _len = normedRanges.length; _i < _len; _i++) {
r = normedRanges[_i];
$.merge(highlights, this.highlightRange(r, cssClass));
}
return highlights;
};
Annotator.prototype.addPlugin = function(name, options) {
var klass, _base;
if (this.plugins[name]) {
console.error(_t("You cannot have more than one instance of any plugin."));
} else {
klass = Annotator.Plugin[name];
if (typeof klass === 'function') {
this.plugins[name] = new klass(this.element[0], options);
this.plugins[name].annotator = this;
if (typeof (_base = this.plugins[name]).pluginInit === "function") {
_base.pluginInit();
}
} else {
console.error(_t("Could not load ") + name + _t(" plugin. Have you included the appropriate <script> tag?"));
}
}
return this;
};
Annotator.prototype.showEditor = function(annotation, location) {
this.editor.element.css(location);
this.editor.load(annotation);
this.publish('annotationEditorShown', [this.editor, annotation]);
return this;
};
Annotator.prototype.onEditorHide = function() {
this.publish('annotationEditorHidden', [this.editor]);
return this.ignoreMouseup = false;
};
Annotator.prototype.onEditorSubmit = function(annotation) {
return this.publish('annotationEditorSubmit', [this.editor, annotation]);
};
Annotator.prototype.showViewer = function(annotations, location) {
this.viewer.element.css(location);
this.viewer.load(annotations);
return this.publish('annotationViewerShown', [this.viewer, annotations]);
};
Annotator.prototype.startViewerHideTimer = function() {
if (!this.viewerHideTimer) {
return this.viewerHideTimer = setTimeout(this.viewer.hide, 250);
}
};
Annotator.prototype.clearViewerHideTimer = function() {
clearTimeout(this.viewerHideTimer);
return this.viewerHideTimer = false;
};
Annotator.prototype.checkForStartSelection = function(event) {
if (!(event && this.isAnnotator(event.target))) {
this.startViewerHideTimer();
}
return this.mouseIsDown = true;
};
Annotator.prototype.checkForEndSelection = function(event) {
var container, range, _i, _len, _ref;
this.mouseIsDown = false;
if (this.ignoreMouseup) {
return;
}
this.selectedRanges = this.getSelectedRanges();
_ref = this.selectedRanges;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
container = range.commonAncestor;
if ($(container).hasClass('annotator-hl')) {
container = $(container).parents('[class!=annotator-hl]')[0];
}
if (this.isAnnotator(container)) {
return;
}
}
if (event && this.selectedRanges.length) {
return this.adder.css(Util.mousePosition(event, this.wrapper[0])).show();
} else {
return this.adder.hide();
}
};
Annotator.prototype.isAnnotator = function(element) {
return !!$(element).parents().andSelf().filter('[class^=annotator-]').not(this.wrapper).length;
};
Annotator.prototype.onHighlightMouseover = function(event) {
var annotations;
this.clearViewerHideTimer();
if (this.mouseIsDown || this.viewer.isShown()) {
return false;
}
annotations = $(event.target).parents('.annotator-hl').andSelf().map(function() {
return $(this).data("annotation");
});
return this.showViewer($.makeArray(annotations), Util.mousePosition(event, this.wrapper[0]));
};
Annotator.prototype.onAdderMousedown = function(event) {
if (event != null) {
event.preventDefault();
}
return this.ignoreMouseup = true;
};
Annotator.prototype.onAdderClick = function(event) {
var annotation, cancel, cleanup, position, save,
_this = this;
if (event != null) {
event.preventDefault();
}
position = this.adder.position();
this.adder.hide();
annotation = this.setupAnnotation(this.createAnnotation());
$(annotation.highlights).addClass('annotator-hl-temporary');
save = function() {
cleanup();
$(annotation.highlights).removeClass('annotator-hl-temporary');
return _this.publish('annotationCreated', [annotation]);
};
cancel = function() {
cleanup();
return _this.deleteAnnotation(annotation);
};
cleanup = function() {
_this.unsubscribe('annotationEditorHidden', cancel);
return _this.unsubscribe('annotationEditorSubmit', save);
};
this.subscribe('annotationEditorHidden', cancel);
this.subscribe('annotationEditorSubmit', save);
return this.showEditor(annotation, position);
};
Annotator.prototype.onEditAnnotation = function(annotation) {
var cleanup, offset, update,
_this = this;
offset = this.viewer.element.position();
update = function() {
cleanup();
return _this.updateAnnotation(annotation);
};
cleanup = function() {
_this.unsubscribe('annotationEditorHidden', cleanup);
return _this.unsubscribe('annotationEditorSubmit', update);
};
this.subscribe('annotationEditorHidden', cleanup);
this.subscribe('annotationEditorSubmit', update);
this.viewer.hide();
return this.showEditor(annotation, offset);
};
Annotator.prototype.onDeleteAnnotation = function(annotation) {
this.viewer.hide();
return this.deleteAnnotation(annotation);
};
return Annotator;
})(Delegator);
Annotator.Plugin = (function(_super) {
__extends(Plugin, _super);
function Plugin(element, options) {
Plugin.__super__.constructor.apply(this, arguments);
}
Plugin.prototype.pluginInit = function() {};
Plugin.prototype.destroy = function() {
return this.removeEvents();
};
return Plugin;
})(Delegator);
g = Util.getGlobal();
if (((_ref = g.document) != null ? _ref.evaluate : void 0) == null) {
$.getScript('http://assets.annotateit.org/vendor/xpath.min.js');
}
if (g.getSelection == null) {
$.getScript('http://assets.annotateit.org/vendor/ierange.min.js');
}
if (g.JSON == null) {
$.getScript('http://assets.annotateit.org/vendor/json2.min.js');
}
if (g.Node == null) {
g.Node = {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4,
ENTITY_REFERENCE_NODE: 5,
ENTITY_NODE: 6,
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NOTATION_NODE: 12
};
}
Annotator.$ = $;
Annotator.Delegator = Delegator;
Annotator.Range = Range;
Annotator.Util = Util;
Annotator._instances = [];
Annotator._t = _t;
Annotator.supported = function() {
return (function() {
return !!this.getSelection;
})();
};
Annotator.noConflict = function() {
Util.getGlobal().Annotator = _Annotator;
return this;
};
$.fn.annotator = function(options) {
var args;
args = Array.prototype.slice.call(arguments, 1);
return this.each(function() {
var instance;
instance = $.data(this, 'annotator');
if (instance) {
return options && instance[options].apply(instance, args);
} else {
instance = new Annotator(this, options);
return $.data(this, 'annotator', instance);
}
});
};
this.Annotator = Annotator;
/*
//@ sourceMappingURL=annotator.map
*/

File diff suppressed because one or more lines are too long

View file

@ -1,132 +0,0 @@
// Generated by CoffeeScript 1.6.3
var Delegator,
__slice = [].slice,
__hasProp = {}.hasOwnProperty;
Delegator = (function() {
Delegator.prototype.events = {};
Delegator.prototype.options = {};
Delegator.prototype.element = null;
function Delegator(element, options) {
this.options = $.extend(true, {}, this.options, options);
this.element = $(element);
this._closures = {};
this.on = this.subscribe;
this.addEvents();
}
Delegator.prototype.addEvents = function() {
var event, _i, _len, _ref, _results;
_ref = Delegator._parseEvents(this.events);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
_results.push(this._addEvent(event.selector, event.event, event.functionName));
}
return _results;
};
Delegator.prototype.removeEvents = function() {
var event, _i, _len, _ref, _results;
_ref = Delegator._parseEvents(this.events);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
_results.push(this._removeEvent(event.selector, event.event, event.functionName));
}
return _results;
};
Delegator.prototype._addEvent = function(selector, event, functionName) {
var closure,
_this = this;
closure = function() {
return _this[functionName].apply(_this, arguments);
};
if (selector === '' && Delegator._isCustomEvent(event)) {
this.subscribe(event, closure);
} else {
this.element.delegate(selector, event, closure);
}
this._closures["" + selector + "/" + event + "/" + functionName] = closure;
return this;
};
Delegator.prototype._removeEvent = function(selector, event, functionName) {
var closure;
closure = this._closures["" + selector + "/" + event + "/" + functionName];
if (selector === '' && Delegator._isCustomEvent(event)) {
this.unsubscribe(event, closure);
} else {
this.element.undelegate(selector, event, closure);
}
delete this._closures["" + selector + "/" + event + "/" + functionName];
return this;
};
Delegator.prototype.publish = function() {
this.element.triggerHandler.apply(this.element, arguments);
return this;
};
Delegator.prototype.subscribe = function(event, callback) {
var closure;
closure = function() {
return callback.apply(this, [].slice.call(arguments, 1));
};
closure.guid = callback.guid = ($.guid += 1);
this.element.bind(event, closure);
return this;
};
Delegator.prototype.unsubscribe = function() {
this.element.unbind.apply(this.element, arguments);
return this;
};
return Delegator;
})();
Delegator._parseEvents = function(eventsObj) {
var event, events, functionName, sel, selector, _i, _ref;
events = [];
for (sel in eventsObj) {
functionName = eventsObj[sel];
_ref = sel.split(' '), selector = 2 <= _ref.length ? __slice.call(_ref, 0, _i = _ref.length - 1) : (_i = 0, []), event = _ref[_i++];
events.push({
selector: selector.join(' '),
event: event,
functionName: functionName
});
}
return events;
};
Delegator.natives = (function() {
var key, specials, val;
specials = (function() {
var _ref, _results;
_ref = jQuery.event.special;
_results = [];
for (key in _ref) {
if (!__hasProp.call(_ref, key)) continue;
val = _ref[key];
_results.push(key);
}
return _results;
})();
return "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]+/).concat(specials);
})();
Delegator._isCustomEvent = function(event) {
event = event.split('.')[0];
return $.inArray(event, Delegator.natives) === -1;
};
/*
//@ sourceMappingURL=class.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "class.js",
"sourceRoot": "..",
"sources": [
"src/class.coffee"
],
"names": [],
"mappings": ";AAGA,IAAA,KAAA;GAAA;gCAAA;;AAAM,CAAN;CAGE,CAAA,CAAQ,GAAR;;CAAA,CAAA,CAGS,IAAT;;CAHA,EAMS,CANT,GAMA;;CAgBa,CAAA,CAAA,IAAA,YAAC;CACZ,CAA0B,CAAf,CAAX,EAAW,CAAX;CAAA,EACW,CAAX,GAAA;CADA,CAAA,CAKa,CAAb,KAAA;CALA,CAOA,CAAU,CAAV,KAPA;CAAA,GAQA,KAAA;CA/BF,EAsBa;;CAtBb,EA0DW,MAAX;CACE,OAAA,uBAAA;CAAA;CAAA;UAAA,iCAAA;wBAAA;CACE,CAA+B,EAA3B,CAAgB,GAApB,CAAA,GAAA;CADF;qBADS;CA1DX,EA0DW;;CA1DX,EAqEc,MA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E,CAAgC,EAAhC,CAAA,CAAe,CAAP,EAAR;CADW,UAEX;CApMF,EAkMa;;CAlMb;;CAHF;;AA4MA,CA5MA,EA4MyB,MAAhB,GAAT;CACI,KAAA,8CAAA;CAAA,CAAA,CAAS,GAAT;AACA,CAAA,MAAA,SAAA;mCAAA;CACE,CAAC,CAAyB,CAA1B,CAAuB,EAAA,sEAAvB;CAAA,GACA,EAAM;CAAM,CACA,CAAA,CAAA,EAAV,EAAA;CADU,CAEH,GAAP,CAAA;CAFU,CAGI,IAAd,MAAA;CAJF,KACA;CAFF,EADA;CAQA,KAAA,GAAO;CATc;;AAczB,CA1NA,EA0NuB,IAAvB,EAAS;CACP,KAAA,YAAA;CAAA,CAAA,MAAA;;CAAY;CAAA;UAAA,CAAA;;uBAAA;CAAA;CAAA;;CAAZ;CAKI,IAJJ,CAAA,EAAA,CAAA,sLAIG;CANkB;;AAqBvB,CA/OA,EA+O2B,EAAA,IAAlB,KAAT;CACE,CAAC,CAAS,EAAK;AACyB,CAAvC,CAAgB,GAAjB,EAAA,EAAA;CAFyB"
}

View file

@ -1,44 +0,0 @@
// Generated by CoffeeScript 1.6.3
var fn, functions, _i, _j, _len, _len1,
__slice = [].slice;
functions = ["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(name) {
return console.log("GROUP: ", name);
};
}
if (console.groupCollapsed == null) {
console.groupCollapsed = console.group;
}
for (_i = 0, _len = functions.length; _i < _len; _i++) {
fn = functions[_i];
if (console[fn] == null) {
console[fn] = function() {
return console.log(_t("Not implemented:") + (" console." + name));
};
}
}
} else {
this.console = {};
for (_j = 0, _len1 = functions.length; _j < _len1; _j++) {
fn = functions[_j];
this.console[fn] = function() {};
}
this.console['error'] = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return alert("ERROR: " + (args.join(', ')));
};
this.console['warn'] = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return alert("WARNING: " + (args.join(', ')));
};
}
/*
//@ sourceMappingURL=console.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "console.js",
"sourceRoot": "..",
"sources": [
"src/console.coffee"
],
"names": [],
"mappings": ";AAEA,IAAA,8BAAA;GAAA,eAAA;;AAAA,CAAA,CACS,CADG,EAAA,CAAA,CAAA,CAAA,CAAZ,CAAY,CAAA,CAAA,CAAA,EAAA,CAAA;;AAOZ,CAAA,GAAG,8CAAH;CAEE,CAAA,EAAO,iBAAP;CACE,EAAgB,CAAhB,CAAA,EAAO,EAAU;CAAiB,CAAe,CAAvB,CAAA,GAAO,EAAP,IAAA;CAA1B,IAAgB;IADlB;CAIA,CAAA,EAAO,0BAAP;CACE,EAAyB,CAAzB,CAAA,EAAO,OAAP;IALF;AAQA,CAAA,MAAA,yCAAA;wBAAA;CACE,GAAA,eAAA;CACE,CAAQ,CAAM,GAAd,CAAQ,EAAM;CAAW,CAAI,CAAZ,CAAqC,GAA9B,IAA+B,IAAtC,GAAY;CAA7B,MAAc;MAFlB;CAAA,EAVF;EAAA,IAAA;CAcE,CAAA,CAAe,CAAX,GAAJ;AAEA,CAAA,MAAA,2CAAA;wBAAA;CACE,CAAa,CAAM,CAAnB,GAAa,EAAM;CADrB,EAFA;CAAA,CAKA,CAAwB,CAApB,GAAS,EAAW;CACtB,GAAA,IAAA;CAAA,GADuB,mDACvB;CAAO,EAAQ,CAAI,CAAnB,IAAO,EAAP;CANF,EAKwB;CALxB,CAQA,CAAuB,CAAnB,EAAS,CAAA,EAAU;CACrB,GAAA,IAAA;CAAA,GADsB,mDACtB;CAAO,EAAU,CAAI,CAArB,MAAA;CATF,EAQuB;EA7BzB"
}

View file

@ -1,226 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator.Editor = (function(_super) {
__extends(Editor, _super);
Editor.prototype.events = {
"form submit": "submit",
".annotator-save click": "submit",
".annotator-cancel click": "hide",
".annotator-cancel mouseover": "onCancelButtonMouseover",
"textarea keydown": "processKeypress"
};
Editor.prototype.classes = {
hide: 'annotator-hide',
focus: 'annotator-focus'
};
Editor.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\">" + _t('Cancel') + "</a>\n<a href=\"#save\" class=\"annotator-save annotator-focus\">" + _t('Save') + "</a>\n </div>\n </form>\n</div>";
Editor.prototype.options = {};
function Editor(options) {
this.onCancelButtonMouseover = __bind(this.onCancelButtonMouseover, this);
this.processKeypress = __bind(this.processKeypress, this);
this.submit = __bind(this.submit, this);
this.load = __bind(this.load, this);
this.hide = __bind(this.hide, this);
this.show = __bind(this.show, this);
Editor.__super__.constructor.call(this, $(this.html)[0], options);
this.fields = [];
this.annotation = {};
}
Editor.prototype.show = function(event) {
Annotator.Util.preventEventDefault(event);
this.element.removeClass(this.classes.hide);
this.element.find('.annotator-save').addClass(this.classes.focus);
this.checkOrientation();
this.element.find(":input:first").focus();
this.setupDraggables();
return this.publish('show');
};
Editor.prototype.hide = function(event) {
Annotator.Util.preventEventDefault(event);
this.element.addClass(this.classes.hide);
return this.publish('hide');
};
Editor.prototype.load = function(annotation) {
var field, _i, _len, _ref;
this.annotation = annotation;
this.publish('load', [this.annotation]);
_ref = this.fields;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
field = _ref[_i];
field.load(field.element, this.annotation);
}
return this.show();
};
Editor.prototype.submit = function(event) {
var field, _i, _len, _ref;
Annotator.Util.preventEventDefault(event);
_ref = this.fields;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
field = _ref[_i];
field.submit(field.element, this.annotation);
}
this.publish('save', [this.annotation]);
return this.hide();
};
Editor.prototype.addField = function(options) {
var element, field, input;
field = $.extend({
id: 'annotator-field-' + Annotator.Util.uuid(),
type: 'input',
label: '',
load: function() {},
submit: function() {}
}, options);
input = null;
element = $('<li class="annotator-item" />');
field.element = element[0];
switch (field.type) {
case 'textarea':
input = $('<textarea />');
break;
case 'input':
case 'checkbox':
input = $('<input />');
break;
case 'select':
input = $('<select />');
}
element.append(input);
input.attr({
id: field.id,
placeholder: field.label
});
if (field.type === 'checkbox') {
input[0].type = 'checkbox';
element.addClass('annotator-checkbox');
element.append($('<label />', {
"for": field.id,
html: field.label
}));
}
this.element.find('ul:first').append(element);
this.fields.push(field);
return field.element;
};
Editor.prototype.checkOrientation = function() {
var controls, list;
Editor.__super__.checkOrientation.apply(this, arguments);
list = this.element.find('ul');
controls = this.element.find('.annotator-controls');
if (this.element.hasClass(this.classes.invert.y)) {
controls.insertBefore(list);
} else if (controls.is(':first-child')) {
controls.insertAfter(list);
}
return this;
};
Editor.prototype.processKeypress = function(event) {
if (event.keyCode === 27) {
return this.hide();
} else if (event.keyCode === 13 && !event.shiftKey) {
return this.submit();
}
};
Editor.prototype.onCancelButtonMouseover = function() {
return this.element.find('.' + this.classes.focus).removeClass(this.classes.focus);
};
Editor.prototype.setupDraggables = function() {
var classes, controls, cornerItem, editor, mousedown, onMousedown, onMousemove, onMouseup, resize, textarea, throttle,
_this = this;
this.element.find('.annotator-resize').remove();
if (this.element.hasClass(this.classes.invert.y)) {
cornerItem = this.element.find('.annotator-item:last');
} else {
cornerItem = this.element.find('.annotator-item:first');
}
if (cornerItem) {
$('<span class="annotator-resize"></span>').appendTo(cornerItem);
}
mousedown = null;
classes = this.classes;
editor = this.element;
textarea = null;
resize = editor.find('.annotator-resize');
controls = editor.find('.annotator-controls');
throttle = false;
onMousedown = function(event) {
if (event.target === this) {
mousedown = {
element: this,
top: event.pageY,
left: event.pageX
};
textarea = editor.find('textarea:first');
$(window).bind({
'mouseup.annotator-editor-resize': onMouseup,
'mousemove.annotator-editor-resize': onMousemove
});
return event.preventDefault();
}
};
onMouseup = function() {
mousedown = null;
return $(window).unbind('.annotator-editor-resize');
};
onMousemove = function(event) {
var diff, directionX, directionY, height, width;
if (mousedown && throttle === false) {
diff = {
top: event.pageY - mousedown.top,
left: event.pageX - mousedown.left
};
if (mousedown.element === resize[0]) {
height = textarea.outerHeight();
width = textarea.outerWidth();
directionX = editor.hasClass(classes.invert.x) ? -1 : 1;
directionY = editor.hasClass(classes.invert.y) ? 1 : -1;
textarea.height(height + (diff.top * directionY));
textarea.width(width + (diff.left * directionX));
if (textarea.outerHeight() !== height) {
mousedown.top = event.pageY;
}
if (textarea.outerWidth() !== width) {
mousedown.left = event.pageX;
}
} else if (mousedown.element === controls[0]) {
editor.css({
top: parseInt(editor.css('top'), 10) + diff.top,
left: parseInt(editor.css('left'), 10) + diff.left
});
mousedown.top = event.pageY;
mousedown.left = event.pageX;
}
throttle = true;
return setTimeout(function() {
return throttle = false;
}, 1000 / 60);
}
};
resize.bind('mousedown', onMousedown);
return controls.bind('mousedown', onMousedown);
};
return Editor;
})(Annotator.Widget);
/*
//@ sourceMappingURL=editor.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "editor.js",
"sourceRoot": "..",
"sources": [
"src/editor.coffee"
],
"names": [],
"mappings": ";AACA,IAAA;;kSAAA;;AAAM,CAAN,QAAe;CAGb;;CAAA,EACE,GADF;CACE,CAA+B,EAA/B,IAAA,KAAA;CAAA,CAC+B,EAA/B,IADA,eACA;CADA,CAE+B,EAA/B,EAFA,mBAEA;CAFA,CAG+B,EAA/B,qBAHA,IAGA;CAHA,CAI+B,EAA/B,aAJA,CAIA;CALF,GAAA;;CAAA,EASE,IADF;CACE,CAAO,EAAP,YAAA;CAAA,CACO,EAAP,CAAA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Selection.prototype.rangeCount = 1;
MockSelection.prototype.isCollapsed = false;
function MockSelection(fixElem, data) {
this.root = fixElem;
this.rootXPath = Util.xpathFromNode($(fixElem))[0];
this.startContainer = this.resolvePath(data[0]);
this.startOffset = data[1];
this.endContainer = this.resolvePath(data[2]);
this.endOffset = data[3];
this.expectation = data[4];
this.description = data[5];
this.commonAncestor = this.startContainer;
while (!Util.contains(this.commonAncestor, this.endContainer)) {
this.commonAncestor = this.commonAncestor.parentNode;
}
this.commonAncestorXPath = Util.xpathFromNode($(this.commonAncestor))[0];
}
MockSelection.prototype.getRangeAt = function() {
return {
startContainer: this.startContainer,
startOffset: this.startOffset,
endContainer: this.endContainer,
endOffset: this.endOffset,
commonAncestorContainer: this.commonAncestor
};
};
MockSelection.prototype.resolvePath = function(path) {
if (typeof path === "number") {
return Util.getTextNodes($(this.root))[path];
} else if (typeof path === "string") {
return this.resolveXPath(this.rootXPath + path);
}
};
MockSelection.prototype.resolveXPath = function(xpath) {
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
};
return MockSelection;
})();
this.textInNormedRange = function(range) {
var textNodes;
textNodes = Util.getTextNodes($(range.commonAncestor));
textNodes = textNodes.slice(textNodes.index(range.start), +textNodes.index(range.end) + 1 || 9e9).get();
return textNodes.reduce((function(acc, next) {
return acc += next.nodeValue;
}), "");
};
this.DateToISO8601String = function(format, offset) {
var d, date, offsetnum, secs, str, zeropad;
if (format == null) {
format = 6;
}
/*
accepted values for the format [1-6]:
1 Year:
YYYY (eg 1997)
2 Year and month:
YYYY-MM (eg 1997-07)
3 Complete date:
YYYY-MM-DD (eg 1997-07-16)
4 Complete date plus hours and minutes:
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
5 Complete date plus hours, minutes and seconds:
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
6 Complete date plus hours, minutes, seconds and a decimal
fraction of a second
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
*/
if (!offset) {
offset = 'Z';
date = this;
} else {
d = offset.match(/([-+])([0-9]{2}):([0-9]{2})/);
offsetnum = (Number(d[2]) * 60) + Number(d[3]);
offsetnum *= d[1] === '-' ? -1 : 1;
date = new Date(Number(Number(this) + (offsetnum * 60000)));
}
zeropad = function(num) {
return (num < 10 ? '0' : '') + num;
};
str = "";
str += date.getUTCFullYear();
if (format > 1) {
str += "-" + zeropad(date.getUTCMonth() + 1);
}
if (format > 2) {
str += "-" + zeropad(date.getUTCDate());
}
if (format > 3) {
str += "T" + zeropad(date.getUTCHours()) + ":" + zeropad(date.getUTCMinutes());
}
if (format > 5) {
secs = Number(date.getUTCSeconds() + "." + (date.getUTCMilliseconds() < 100 ? '0' : '') + zeropad(date.getUTCMilliseconds()));
str += ":" + zeropad(secs);
} else if (format > 4) {
str += ":" + zeropad(date.getUTCSeconds());
}
if (format > 3) {
str += offset;
}
return str;
};
fixtureElem = document.getElementById('fixtures');
fixtureMemo = {};
this.setFixtureElem = function(elem) {
return fixtureElem = elem;
};
this.fix = function() {
return fixtureElem;
};
this.getFixture = function(fname) {
if (fixtureMemo[fname] == null) {
fixtureMemo[fname] = $.ajax({
url: "fixtures/" + fname + ".html",
async: false
}).responseText;
}
return fixtureMemo[fname];
};
this.addFixture = function(fname) {
return $(this.getFixture(fname)).appendTo(fixtureElem);
};
this.clearFixtures = function() {
return $(fixtureElem).empty();
};
/*
//@ sourceMappingURL=spec_helper.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "spec_helper.js",
"sourceRoot": "../..",
"sources": [
"test/helpers/spec_helper.coffee"
],
"names": [],
"mappings": ";AAAA,IAAA,oBAAA;;AAAM,CAAN,GAAU;CACR,EAAY,OAAZ;;CAAA,EACa,EADb,MACA;;CAEa,CAAA,CAAA,CAAA,GAAA,gBAAC;CAEZ,EAAQ,CAAR,GAAA;CAAA,EACa,CAAb,GAAgC,EAAhC,IAAa;CADb,EAG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,KAHmB,MAArB;IADF;CAMY,IAAA,IAAZ,EAAY;CAPI;;AASlB,CAhHA,EAgHkB,CAAd,CAAc,IAAC,CAAnB;CACE,GAAM,CAAJ,GAAF,CAAA,CAAE,CAAF;CADgB;;AAGlB,CAnHA,EAmHqB,CAAjB,KAAiB,IAArB;CACE,IAAA,IAAA,EAAA;CADmB"
}

View file

@ -1,65 +0,0 @@
// Generated by CoffeeScript 1.6.3
var Annotator,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator = Annotator || {};
Annotator.Notification = (function(_super) {
__extends(Notification, _super);
Notification.prototype.events = {
"click": "hide"
};
Notification.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 Notification(options) {
this.hide = __bind(this.hide, this);
this.show = __bind(this.show, this);
Notification.__super__.constructor.call(this, $(this.options.html).appendTo(document.body)[0], options);
}
Notification.prototype.show = function(message, status) {
if (status == null) {
status = Annotator.Notification.INFO;
}
$(this.element).addClass(this.options.classes.show).addClass(this.options.classes[status]).html(Util.escape(message || ""));
setTimeout(this.hide, 5000);
return this;
};
Notification.prototype.hide = function() {
$(this.element).removeClass(this.options.classes.show);
return this;
};
return Notification;
})(Delegator);
Annotator.Notification.INFO = 'show';
Annotator.Notification.SUCCESS = 'success';
Annotator.Notification.ERROR = 'error';
$(function() {
var notification;
notification = new Annotator.Notification;
Annotator.showNotification = notification.show;
return Annotator.hideNotification = notification.hide;
});
/*
//@ sourceMappingURL=notification.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "notification.js",
"sourceRoot": "..",
"sources": [
"src/notification.coffee"
],
"names": [],
"mappings": ";AAAA,IAAA,KAAA;GAAA;;kSAAA;;AAAA,CAAA,CAAA,CAAY,CAAa,KAAzB;;AAMM,CANN,QAMe;CAGb;;CAAA,EACE,GADF;CACE,CAAS,EAAT,EAAA,CAAA;CADF,GAAA;;CAAA,EAKE,IADF;CACE,CAAM,EAAN,kCAAA;CAAA,CAEE,EADF,GAAA;CACE,CAAS,EAAT,EAAA,iBAAA;CAAA,CACS,EAAT,EAAA,iBADA;CAAA,CAES,IAAT,CAAA,mBAFA;CAAA,CAGS,GAAT,CAAA,kBAHA;MAFF;CALF,GAAA;;CA0Ba,CAAA,CAAA,IAAA,eAAC;CACZ,kCAAA;CAAA,kCAAA;CAAA,CAAmD,EAAnD,GAAgB,CAAV,sCAAA;CA3BR,EA0Ba;;CA1Bb,CA6CgB,CAAV,CAAN,EAAM,CAAA,EAAC;;CAA0B,EAAV,GAAP,GAAgB,GAAa;MAC3C;CAAA,CAGQ,EAHR,EAE6B,CAF7B,CAAA;CAAA,CAKsB,EAAtB,MAAA;CANI,UAOJ;CApDF,EA6CM;;CA7CN,EA8DM,CAAN,KAAM;CACJ,GAAA,GAAA,IAAA;CADI,UAEJ;CAhEF,EA8DM;;CA9DN;;CAHmC;;AAuErC,CA7EA,EA6EiC,CAAjC,EA7EA,GA6ES,GAAa;;AACtB,CA9EA,EA8EiC,IAAjC,EAAS,GAAa;;AACtB,CA/EA,EA+EiC,EAAjC,EA/EA,EA+ES,GAAa;;AAGtB,CAlFA,EAkFE,MAAA;CACA,KAAA,MAAA;AAAe,CAAf,CAAA,CAAe,MAAa,GAA5B;CAAA,CAEA,CAA6B,CAF7B,KAES,GAAgC,IAAzC;CACU,EAAmB,MAA7B,GAAyC,IAAzC;CAJA"
}

View file

@ -1,116 +0,0 @@
// Generated by CoffeeScript 1.6.3
var _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
Annotator.Plugin.AnnotateItPermissions = (function(_super) {
__extends(AnnotateItPermissions, _super);
function AnnotateItPermissions() {
this._setAuthFromToken = __bind(this._setAuthFromToken, this);
this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);
this.updatePermissionsField = __bind(this.updatePermissionsField, this);
this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this);
_ref = AnnotateItPermissions.__super__.constructor.apply(this, arguments);
return _ref;
}
AnnotateItPermissions.prototype.options = {
showViewPermissionsCheckbox: true,
showEditPermissionsCheckbox: true,
groups: {
world: 'group:__world__',
authenticated: 'group:__authenticated__',
consumer: 'group:__consumer__'
},
userId: function(user) {
return user.userId;
},
userString: function(user) {
return user.userId;
},
userAuthorize: function(action, annotation, user) {
var action_field, permissions, _ref1, _ref2, _ref3, _ref4;
permissions = annotation.permissions || {};
action_field = permissions[action] || [];
if (_ref1 = this.groups.world, __indexOf.call(action_field, _ref1) >= 0) {
return true;
} else if ((user != null) && (user.userId != null) && (user.consumerKey != null)) {
if (user.userId === annotation.user && user.consumerKey === annotation.consumer) {
return true;
} else if (_ref2 = this.groups.authenticated, __indexOf.call(action_field, _ref2) >= 0) {
return true;
} else if (user.consumerKey === annotation.consumer && (_ref3 = this.groups.consumer, __indexOf.call(action_field, _ref3) >= 0)) {
return true;
} else if (user.consumerKey === annotation.consumer && (_ref4 = user.userId, __indexOf.call(action_field, _ref4) >= 0)) {
return true;
} else if (user.consumerKey === annotation.consumer && user.admin) {
return true;
} else {
return false;
}
} else {
return false;
}
},
permissions: {
'read': ['group:__world__'],
'update': [],
'delete': [],
'admin': []
}
};
AnnotateItPermissions.prototype.addFieldsToAnnotation = function(annotation) {
if (annotation) {
annotation.permissions = this.options.permissions;
if (this.user) {
annotation.user = this.user.userId;
return annotation.consumer = this.user.consumerKey;
}
}
};
AnnotateItPermissions.prototype.updatePermissionsField = function(action, field, annotation) {
var input;
field = $(field).show();
input = field.find('input').removeAttr('disabled');
if (!this.authorize('admin', annotation)) {
field.hide();
}
if (this.user && this.authorize(action, annotation || {}, {
userId: '__nonexistentuser__',
consumerKey: this.user.consumerKey
})) {
return input.attr('checked', 'checked');
} else {
return input.removeAttr('checked');
}
};
AnnotateItPermissions.prototype.updateAnnotationPermissions = function(type, field, annotation) {
var dataKey;
if (!annotation.permissions) {
annotation.permissions = this.options.permissions;
}
dataKey = type + '-permissions';
if ($(field).find('input').is(':checked')) {
return annotation.permissions[type] = [type === 'read' ? this.options.groups.world : this.options.groups.consumer];
} else {
return annotation.permissions[type] = [];
}
};
AnnotateItPermissions.prototype._setAuthFromToken = function(token) {
return this.setUser(token);
};
return AnnotateItPermissions;
})(Annotator.Plugin.Permissions);
/*
//@ sourceMappingURL=annotateitpermissions.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "annotateitpermissions.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/annotateitpermissions.coffee"
],
"names": [],
"mappings": ";AAYA,IAAA;GAAA;;;wJAAA;;AAAM,CAAN,KAAsB,GAAP;CAGb;;;;;;;;;CAAA;;CAAA,EAGE,IAHF;CAGE,CAA6B,EAA7B,uBAAA;CAAA,CAG6B,EAA7B,uBAAA;CAHA,CAOE,EADF,EAAA;CACE,CAAO,GAAP,CAAA,WAAA;CAAA,CACe,IAAf,OAAA,YADA;CAAA,CAEU,IAAV,EAAA,YAFA;MAPF;CAAA,CAWQ,CAAA,CAAR,EAAA,GAAS;CAAc,GAAD,SAAJ;CAXlB,IAWQ;CAXR,CAYY,CAAA,CAAZ,KAAa,CAAb;CAA2B,GAAD,SAAJ;CAZtB,IAYY;CAZZ,CAsBe,CAAA,CAAf,EAAe,GAAC,CAAD,GAAf;CACE,SAAA,2CAAA;CAAA,CAAA,CAAc,CAA0B,EA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a,GAAA,CAAuB;CAAkB,CAAS,IAAR,eAAD;CAAA,CAA6C,EAAC,EAAd,KAAA;CAAtF,KAAa;CACL,CAAgB,EAAtB,CAAK,IAAL,IAAA;MADF;CAGQ,IAAD,IAAL,CAAA,GAAA;MAXoB;CApFxB,EAoFwB;;CApFxB,CA0GoC,CAAP,CAAA,CAAA,IAAC,CAAD,iBAA7B;CACE,MAAA,CAAA;AAAqD,CAArD,GAAA,MAA+D,CAA/D;CAAA,EAAyB,CAAC,EAA1B,CAAiC,GAAvB,CAAV;MAAA;CAAA,EAEU,CAAV,GAAA,OAFA;CAIA,CAAG,EAAH,CAAG,EAAA,GAAA;CACU,EAAoB,CAAR,CAAoB,CAAX,CAA+B,CAAhC,EAArB,CAAa,EAAvB;MADF;CAGa,EAAoB,CAAR,MAAb,CAAa,EAAvB;MARyB;CA1G7B,EA0G6B;;CA1G7B,EA0HmB,EAAA,IAAC,QAApB;CACO,GAAD,CAAJ,EAAA,IAAA;CA3HF,EA0HmB;;CA1HnB;;CAHmD,KAAgB,GAAP"
}

View file

@ -1,215 +0,0 @@
// Generated by CoffeeScript 1.6.3
var base64Decode, base64UrlDecode, createDateFromISO8601, parseToken,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
createDateFromISO8601 = function(string) {
var d, date, offset, regexp, time, _ref;
regexp = "([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})))?)?)?)?";
d = string.match(new RegExp(regexp));
offset = 0;
date = new Date(d[1], 0, 1);
if (d[3]) {
date.setMonth(d[3] - 1);
}
if (d[5]) {
date.setDate(d[5]);
}
if (d[7]) {
date.setHours(d[7]);
}
if (d[8]) {
date.setMinutes(d[8]);
}
if (d[10]) {
date.setSeconds(d[10]);
}
if (d[12]) {
date.setMilliseconds(Number("0." + d[12]) * 1000);
}
if (d[14]) {
offset = (Number(d[16]) * 60) + Number(d[17]);
offset *= (_ref = d[15] === '-') != null ? _ref : {
1: -1
};
}
offset -= date.getTimezoneOffset();
time = Number(date) + (offset * 60 * 1000);
date.setTime(Number(time));
return date;
};
base64Decode = function(data) {
var ac, b64, bits, dec, h1, h2, h3, h4, i, o1, o2, o3, tmp_arr;
if (typeof atob !== "undefined" && atob !== null) {
return atob(data);
} else {
b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
i = 0;
ac = 0;
dec = "";
tmp_arr = [];
if (!data) {
return data;
}
data += '';
while (i < data.length) {
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.charAt(i++));
h3 = b64.indexOf(data.charAt(i++));
h4 = b64.indexOf(data.charAt(i++));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
if (h3 === 64) {
tmp_arr[ac++] = String.fromCharCode(o1);
} else if (h4 === 64) {
tmp_arr[ac++] = String.fromCharCode(o1, o2);
} else {
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
}
}
return tmp_arr.join('');
}
};
base64UrlDecode = function(data) {
var i, m, _i, _ref;
m = data.length % 4;
if (m !== 0) {
for (i = _i = 0, _ref = 4 - m; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
data += '=';
}
}
data = data.replace(/-/g, '+');
data = data.replace(/_/g, '/');
return base64Decode(data);
};
parseToken = function(token) {
var head, payload, sig, _ref;
_ref = token.split('.'), head = _ref[0], payload = _ref[1], sig = _ref[2];
return JSON.parse(base64UrlDecode(payload));
};
Annotator.Plugin.Auth = (function(_super) {
__extends(Auth, _super);
Auth.prototype.options = {
token: null,
tokenUrl: '/auth/token',
autoFetch: true
};
function Auth(element, options) {
Auth.__super__.constructor.apply(this, arguments);
this.waitingForToken = [];
if (this.options.token) {
this.setToken(this.options.token);
} else {
this.requestToken();
}
}
Auth.prototype.requestToken = function() {
var _this = this;
this.requestInProgress = true;
return $.ajax({
url: this.options.tokenUrl,
dataType: 'text',
xhrFields: {
withCredentials: true
}
}).done(function(data, status, xhr) {
return _this.setToken(data);
}).fail(function(xhr, status, err) {
var msg;
msg = Annotator._t("Couldn't get auth token:");
console.error("" + msg + " " + err, xhr);
return Annotator.showNotification("" + msg + " " + xhr.responseText, Annotator.Notification.ERROR);
}).always(function() {
return _this.requestInProgress = false;
});
};
Auth.prototype.setToken = function(token) {
var _results,
_this = this;
this.token = token;
this._unsafeToken = parseToken(token);
if (this.haveValidToken()) {
if (this.options.autoFetch) {
this.refreshTimeout = setTimeout((function() {
return _this.requestToken();
}), (this.timeToExpiry() - 2) * 1000);
}
this.updateHeaders();
_results = [];
while (this.waitingForToken.length > 0) {
_results.push(this.waitingForToken.pop()(this._unsafeToken));
}
return _results;
} else {
console.warn(Annotator._t("Didn't get a valid token."));
if (this.options.autoFetch) {
console.warn(Annotator._t("Getting a new token in 10s."));
return setTimeout((function() {
return _this.requestToken();
}), 10 * 1000);
}
}
};
Auth.prototype.haveValidToken = function() {
var allFields;
allFields = this._unsafeToken && this._unsafeToken.issuedAt && this._unsafeToken.ttl && this._unsafeToken.consumerKey;
if (allFields && this.timeToExpiry() > 0) {
return true;
} else {
return false;
}
};
Auth.prototype.timeToExpiry = function() {
var expiry, issue, now, timeToExpiry;
now = new Date().getTime() / 1000;
issue = createDateFromISO8601(this._unsafeToken.issuedAt).getTime() / 1000;
expiry = issue + this._unsafeToken.ttl;
timeToExpiry = expiry - now;
if (timeToExpiry > 0) {
return timeToExpiry;
} else {
return 0;
}
};
Auth.prototype.updateHeaders = function() {
var current;
current = this.element.data('annotator:headers');
return this.element.data('annotator:headers', $.extend(current, {
'x-annotator-auth-token': this.token
}));
};
Auth.prototype.withToken = function(callback) {
if (callback == null) {
return;
}
if (this.haveValidToken()) {
return callback(this._unsafeToken);
} else {
this.waitingForToken.push(callback);
if (!this.requestInProgress) {
return this.requestToken();
}
}
};
return Auth;
})(Annotator.Plugin);
/*
//@ sourceMappingURL=auth.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "auth.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/auth.coffee"
],
"names": [],
"mappings": ";AAKA,IAAA,4DAAA;GAAA;kSAAA;;AAAA,CAAA,EAAwB,GAAA,GAAC,YAAzB;CACE,KAAA,6BAAA;CAAA,CAAA,CAAS,GAAT,8BAAS,MAAT,WAAS;CAAT,CAIA,CAAI,CAAiB,CAAjB,CAAM;CAJV,CAMA,CAAS,GAAT;CANA,CAOA,CAAW,CAAX;CAEA,CAAA,EAA2B;CAA3B,EAAqB,CAArB,IAAA;IATA;CAUA,CAAA,EAAsB;CAAtB,GAAA,GAAA;IAVA;CAWA,CAAA,EAAuB;CAAvB,GAAA,IAAA;IAXA;CAYA,CAAA,EAAyB;CAAzB,GAAA,MAAA;IAZA;CAaA,CAAA,EAA0B;CAA1B,CAAkB,EAAlB,MAAA;IAbA;CAcA,CAAA,EAAqD;CAArD,CAAqC,CAAF,CAAnC,EAAqB,SAArB;IAdA;CAgBA,CAAA,EAAG;CACD,CAAmB,CAAV,CAAT,EAAA;CAAA,EAC4B,CAA5B,EAAA;AAAiC,CAAL,CAAI,IAAJ;CAF9B,KACE;IAjBF;CAAA,CAoBA,EAAU,EAAV,WAAU;CApBV,CAqBA,CAAQ,CAAR,EAAQ;CArBR,CAuBA,EAAI,EAAS,CAAb;CAxBsB,QAyBtB;CAzBsB;;AA2BxB,CA3BA,EA2Be,CAAA,KAAC,GAAhB;CACE,KAAA,oDAAA;CAAA,CAAA,EAAG,wCAAH;CAEO,GAAL,OAAA;IAFF,EAAA;CAME,EAAA,CAAA,+DAAA;CAAA,EACI,CAAJ;CADA,CAEA,CAAK,CAAL;CAFA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AAb,EAAA,CAAO,EAAe,kBAAT;CACb,GAAG,EAAH,CAAW,EAAX;CACE,CAAa,EAAb,GAAO,CAAP,CAAsB,oBAAT;CACF,EAAC,MAAA,CAAZ,KAAA;CAAuB,IAAD,OAAJ,KAAA;CAAP,CAA6B,CAAK,CAA7C,KAAY;QAhBhB;MALQ;CA3EV,EA2EU;;CA3EV,EA0GgB,MAAA,KAAhB;CACE,OAAA,CAAA;CAAA,EAAY,CAAZ,IAAY,CAAZ,EAAA,CAAY;CAKZ,EAAsC,CAAtC,KAAG,GAAa;CACd,GAAA,SAAO;MADT;CAGE,IAAA,QAAO;MATK;CA1GhB,EA0GgB;;CA1GhB,EAwHc,MAAA,GAAd;CACE,OAAA,wBAAA;CAAA,EAAA,CAAA,GAAU;CAAV,EACQ,CAAR,CAAA,EAAQ,CAAA,IAAmC,SAAnC;CADR,EAGS,CAAT,CAAS,CAAT,MAA8B;CAH9B,EAIe,CAAf,EAAe,MAAf;CAEA,EAAmB,CAAnB,QAAI;CAAJ,YAA2B;MAA3B;CAAA,YAA6C;MAPjC;CAxHd,EAwHc;;CAxHd,EAsIe,MAAA,IAAf;CACE,MAAA,CAAA;CAAA,EAAU,CAAV,GAAA,YAAU;CACT,CAAkC,EAAlC,EAAkC,CAA3B,IAAR,QAAA;CAAqD,CACzB,EAAC,CADwB,CACnD,kBAAA;CADF,KAAmC;CAxIrC,EAsIe;;CAtIf,EAuJW,KAAA,CAAX;CACE,GAAA,YAAA;CACE,WAAA;MADF;CAGA,GAAA,UAAG;CACQ,GAAC,IAAV,IAAA,CAAA;MADF;CAGE,GAAI,EAAJ,EAAA,OAAoB;AACb,CAAP,GAAG,EAAH,WAAA;CACO,GAAD,QAAJ,GAAA;QALJ;MAJS;CAvJX,EAuJW;;CAvJX;;CAFkC,QAAS"
}

View file

@ -1,259 +0,0 @@
// Generated by CoffeeScript 1.6.3
var _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator.Plugin.Document = (function(_super) {
var $;
__extends(Document, _super);
function Document() {
this._getFavicon = __bind(this._getFavicon, this);
this._getLinks = __bind(this._getLinks, this);
this._getTitle = __bind(this._getTitle, this);
this._getMetaTags = __bind(this._getMetaTags, this);
this._getEprints = __bind(this._getEprints, this);
this._getPrism = __bind(this._getPrism, this);
this._getDublinCore = __bind(this._getDublinCore, this);
this._getTwitter = __bind(this._getTwitter, this);
this._getFacebook = __bind(this._getFacebook, this);
this._getHighwire = __bind(this._getHighwire, this);
this.getDocumentMetadata = __bind(this.getDocumentMetadata, this);
this.beforeAnnotationCreated = __bind(this.beforeAnnotationCreated, this);
this.uris = __bind(this.uris, this);
this.uri = __bind(this.uri, this);
_ref = Document.__super__.constructor.apply(this, arguments);
return _ref;
}
$ = Annotator.$;
Document.prototype.events = {
'beforeAnnotationCreated': 'beforeAnnotationCreated'
};
Document.prototype.pluginInit = function() {
return this.getDocumentMetadata();
};
Document.prototype.uri = function() {
var link, uri, _i, _len, _ref1;
uri = decodeURIComponent(document.location.href);
_ref1 = this.metadata;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
link = _ref1[_i];
if (link.rel === "canonical") {
uri = link.href;
}
}
return uri;
};
Document.prototype.uris = function() {
var href, link, uniqueUrls, _i, _len, _ref1;
uniqueUrls = {};
_ref1 = this.metadata.link;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
link = _ref1[_i];
if (link.href) {
uniqueUrls[link.href] = true;
}
}
return (function() {
var _results;
_results = [];
for (href in uniqueUrls) {
_results.push(href);
}
return _results;
})();
};
Document.prototype.beforeAnnotationCreated = function(annotation) {
return annotation.document = this.metadata;
};
Document.prototype.getDocumentMetadata = function() {
this.metadata = {};
this._getHighwire();
this._getDublinCore();
this._getFacebook();
this._getEprints();
this._getPrism();
this._getTwitter();
this._getFavicon();
this._getTitle();
this._getLinks();
return this.metadata;
};
Document.prototype._getHighwire = function() {
return this.metadata.highwire = this._getMetaTags("citation", "name", "_");
};
Document.prototype._getFacebook = function() {
return this.metadata.facebook = this._getMetaTags("og", "property", ":");
};
Document.prototype._getTwitter = function() {
return this.metadata.twitter = this._getMetaTags("twitter", "name", ":");
};
Document.prototype._getDublinCore = function() {
return this.metadata.dc = this._getMetaTags("dc", "name", ".");
};
Document.prototype._getPrism = function() {
return this.metadata.prism = this._getMetaTags("prism", "name", ".");
};
Document.prototype._getEprints = function() {
return this.metadata.eprints = this._getMetaTags("eprints", "name", ".");
};
Document.prototype._getMetaTags = function(prefix, attribute, delimiter) {
var content, match, meta, n, name, tags, _i, _len, _ref1;
tags = {};
_ref1 = $("meta");
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
meta = _ref1[_i];
name = $(meta).attr(attribute);
content = $(meta).prop("content");
if (name) {
match = name.match(RegExp("^" + prefix + delimiter + "(.+)$", "i"));
if (match) {
n = match[1];
if (tags[n]) {
tags[n].push(content);
} else {
tags[n] = [content];
}
}
}
}
return tags;
};
Document.prototype._getTitle = function() {
if (this.metadata.highwire.title) {
return this.metadata.title = this.metadata.highwire.title[0];
} else if (this.metadata.eprints.title) {
return this.metadata.title = this.metadata.eprints.title;
} else if (this.metadata.prism.title) {
return this.metadata.title = this.metadata.prism.title;
} else if (this.metadata.facebook.title) {
return this.metadata.title = this.metadata.facebook.title;
} else if (this.metadata.twitter.title) {
return this.metadata.title = this.metadata.twitter.title;
} else if (this.metadata.dc.title) {
return this.metadata.title = this.metadata.dc.title;
} else {
return this.metadata.title = $("head title").text();
}
};
Document.prototype._getLinks = function() {
var doi, href, id, l, link, name, rel, type, url, values, _i, _j, _k, _len, _len1, _len2, _ref1, _ref2, _ref3, _results;
this.metadata.link = [
{
href: document.location.href
}
];
_ref1 = $("link");
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
link = _ref1[_i];
l = $(link);
href = this._absoluteUrl(l.prop('href'));
rel = l.prop('rel');
type = l.prop('type');
if ((rel === "alternate" || rel === "canonical" || rel === "bookmark") && (type !== "application/rss+xml" && type !== "application/atom+xml")) {
this.metadata.link.push({
href: href,
rel: rel,
type: type
});
}
}
_ref2 = this.metadata.highwire;
for (name in _ref2) {
values = _ref2[name];
if (name === "pdf_url") {
for (_j = 0, _len1 = values.length; _j < _len1; _j++) {
url = values[_j];
this.metadata.link.push({
href: this._absoluteUrl(url),
type: "application/pdf"
});
}
}
if (name === "doi") {
for (_k = 0, _len2 = values.length; _k < _len2; _k++) {
doi = values[_k];
if (doi.slice(0, 4) !== "doi:") {
doi = "doi:" + doi;
}
this.metadata.link.push({
href: doi
});
}
}
}
_ref3 = this.metadata.dc;
_results = [];
for (name in _ref3) {
values = _ref3[name];
if (name === "identifier") {
_results.push((function() {
var _l, _len3, _results1;
_results1 = [];
for (_l = 0, _len3 = values.length; _l < _len3; _l++) {
id = values[_l];
if (id.slice(0, 4) === "doi:") {
_results1.push(this.metadata.link.push({
href: id
}));
} else {
_results1.push(void 0);
}
}
return _results1;
}).call(this));
} else {
_results.push(void 0);
}
}
return _results;
};
Document.prototype._getFavicon = function() {
var link, _i, _len, _ref1, _ref2, _results;
_ref1 = $("link");
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
link = _ref1[_i];
if ((_ref2 = $(link).prop("rel")) === "shortcut icon" || _ref2 === "icon") {
_results.push(this.metadata["favicon"] = this._absoluteUrl(link.href));
} else {
_results.push(void 0);
}
}
return _results;
};
Document.prototype._absoluteUrl = function(url) {
var img;
img = $("<img src='" + url + "'>");
url = img.prop('src');
img.prop('src', null);
return url;
};
return Document;
})(Annotator.Plugin);
/*
//@ sourceMappingURL=document.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "document.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/document.coffee"
],
"names": [],
"mappings": ";AAAA,IAAA;GAAA;;kSAAA;;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A;CAAA;QADF;CAAA;qBAjCS;CAhGX,EAgGW;;CAhGX,EAuIa,MAAA,EAAb;CACE,OAAA,8BAAA;CAAA;CAAA;UAAA,kCAAA;wBAAA;CACE,EAAG,CAAA,CAAA,CAAH,SAAG;CACD,EAAuB,CAAtB,IAAS,CAAA,GAAa;MADzB,EAAA;CAAA;QADF;CAAA;qBADW;CAvIb,EAuIa;;CAvIb,EA8Ic,MAAC,GAAf;CACE,EAAA,KAAA;CAAA,EAAA,CAAA,QAAS;CAAT,EACA,CAAA,CAAM;CADN,CAEgB,CAAb,CAAH,CAAA;CACA,EAAA,QAAO;CAlJT,EA8Ic;;CA9Id;;CAFsC,QAAS"
}

View file

@ -1,282 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator.Plugin.Filter = (function(_super) {
__extends(Filter, _super);
Filter.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"
};
Filter.prototype.classes = {
active: 'annotator-filter-active',
hl: {
hide: 'annotator-hl-filtered',
active: 'annotator-hl-active'
}
};
Filter.prototype.html = {
element: "<div class=\"annotator-filter\">\n <strong>" + Annotator._t('Navigate:') + "</strong>\n<span class=\"annotator-filter-navigation\">\n <button class=\"annotator-filter-previous\">" + Annotator._t('Previous') + "</button>\n<button class=\"annotator-filter-next\">" + Annotator._t('Next') + "</button>\n</span>\n<strong>" + Annotator._t('Filter by:') + "</strong>\n</div>",
filter: "<span class=\"annotator-filter-property\">\n <label></label>\n <input/>\n <button class=\"annotator-filter-clear\">" + Annotator._t('Clear') + "</button>\n</span>"
};
Filter.prototype.options = {
appendTo: 'body',
filters: [],
addAnnotationFilter: true,
isFiltered: function(input, property) {
var keyword, _i, _len, _ref;
if (!(input && property)) {
return false;
}
_ref = input.split(/\s*/);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
keyword = _ref[_i];
if (property.indexOf(keyword) === -1) {
return false;
}
}
return true;
}
};
function Filter(element, options) {
this._onPreviousClick = __bind(this._onPreviousClick, this);
this._onNextClick = __bind(this._onNextClick, this);
this._onFilterKeyup = __bind(this._onFilterKeyup, this);
this._onFilterBlur = __bind(this._onFilterBlur, this);
this._onFilterFocus = __bind(this._onFilterFocus, this);
this.updateHighlights = __bind(this.updateHighlights, this);
var _base;
element = $(this.html.element).appendTo((options != null ? options.appendTo : void 0) || this.options.appendTo);
Filter.__super__.constructor.call(this, element, options);
(_base = this.options).filters || (_base.filters = []);
this.filter = $(this.html.filter);
this.filters = [];
this.current = 0;
}
Filter.prototype.pluginInit = function() {
var filter, _i, _len, _ref;
_ref = this.options.filters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
filter = _ref[_i];
this.addFilter(filter);
}
this.updateHighlights();
this._setupListeners()._insertSpacer();
if (this.options.addAnnotationFilter === true) {
return this.addFilter({
label: Annotator._t('Annotation'),
property: 'text'
});
}
};
Filter.prototype.destroy = function() {
var currentMargin, html;
Filter.__super__.destroy.apply(this, arguments);
html = $('html');
currentMargin = parseInt(html.css('padding-top'), 10) || 0;
html.css('padding-top', currentMargin - this.element.outerHeight());
return this.element.remove();
};
Filter.prototype._insertSpacer = function() {
var currentMargin, html;
html = $('html');
currentMargin = parseInt(html.css('padding-top'), 10) || 0;
html.css('padding-top', currentMargin + this.element.outerHeight());
return this;
};
Filter.prototype._setupListeners = function() {
var event, events, _i, _len;
events = ['annotationsLoaded', 'annotationCreated', 'annotationUpdated', 'annotationDeleted'];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
this.annotator.subscribe(event, this.updateHighlights);
}
return this;
};
Filter.prototype.addFilter = function(options) {
var f, filter;
filter = $.extend({
label: '',
property: '',
isFiltered: this.options.isFiltered
}, options);
if (!((function() {
var _i, _len, _ref, _results;
_ref = this.filters;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
f = _ref[_i];
if (f.property === filter.property) {
_results.push(f);
}
}
return _results;
}).call(this)).length) {
filter.id = 'annotator-filter-' + filter.property;
filter.annotations = [];
filter.element = this.filter.clone().appendTo(this.element);
filter.element.find('label').html(filter.label).attr('for', filter.id);
filter.element.find('input').attr({
id: filter.id,
placeholder: Annotator._t('Filter by ') + filter.label + '\u2026'
});
filter.element.find('button').hide();
filter.element.data('filter', filter);
this.filters.push(filter);
}
return this;
};
Filter.prototype.updateFilter = function(filter) {
var annotation, annotations, input, property, _i, _len, _ref;
filter.annotations = [];
this.updateHighlights();
this.resetHighlights();
input = $.trim(filter.element.find('input').val());
if (input) {
annotations = this.highlights.map(function() {
return $(this).data('annotation');
});
_ref = $.makeArray(annotations);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
annotation = _ref[_i];
property = annotation[filter.property];
if (filter.isFiltered(input, property)) {
filter.annotations.push(annotation);
}
}
return this.filterHighlights();
}
};
Filter.prototype.updateHighlights = function() {
this.highlights = this.annotator.element.find('.annotator-hl:visible');
return this.filtered = this.highlights.not(this.classes.hl.hide);
};
Filter.prototype.filterHighlights = function() {
var activeFilters, annotation, annotations, filtered, highlights, index, uniques, _i, _len, _ref;
activeFilters = $.grep(this.filters, function(filter) {
return !!filter.annotations.length;
});
filtered = ((_ref = activeFilters[0]) != null ? _ref.annotations : void 0) || [];
if (activeFilters.length > 1) {
annotations = [];
$.each(activeFilters, function() {
return $.merge(annotations, this.annotations);
});
uniques = [];
filtered = [];
$.each(annotations, function() {
if ($.inArray(this, uniques) === -1) {
return uniques.push(this);
} else {
return filtered.push(this);
}
});
}
highlights = this.highlights;
for (index = _i = 0, _len = filtered.length; _i < _len; index = ++_i) {
annotation = filtered[index];
highlights = highlights.not(annotation.highlights);
}
highlights.addClass(this.classes.hl.hide);
this.filtered = this.highlights.not(this.classes.hl.hide);
return this;
};
Filter.prototype.resetHighlights = function() {
this.highlights.removeClass(this.classes.hl.hide);
this.filtered = this.highlights;
return this;
};
Filter.prototype._onFilterFocus = function(event) {
var input;
input = $(event.target);
input.parent().addClass(this.classes.active);
return input.next('button').show();
};
Filter.prototype._onFilterBlur = function(event) {
var input;
if (!event.target.value) {
input = $(event.target);
input.parent().removeClass(this.classes.active);
return input.next('button').hide();
}
};
Filter.prototype._onFilterKeyup = function(event) {
var filter;
filter = $(event.target).parent().data('filter');
if (filter) {
return this.updateFilter(filter);
}
};
Filter.prototype._findNextHighlight = function(previous) {
var active, annotation, current, index, next, offset, operator, resetOffset;
if (!this.highlights.length) {
return this;
}
offset = previous ? 0 : -1;
resetOffset = previous ? -1 : 0;
operator = previous ? 'lt' : 'gt';
active = this.highlights.not('.' + this.classes.hl.hide);
current = active.filter('.' + this.classes.hl.active);
if (!current.length) {
current = active.eq(offset);
}
annotation = current.data('annotation');
index = active.index(current[0]);
next = active.filter(":" + operator + "(" + index + ")").not(annotation.highlights).eq(resetOffset);
if (!next.length) {
next = active.eq(resetOffset);
}
return this._scrollToHighlight(next.data('annotation').highlights);
};
Filter.prototype._onNextClick = function(event) {
return this._findNextHighlight();
};
Filter.prototype._onPreviousClick = function(event) {
return this._findNextHighlight(true);
};
Filter.prototype._scrollToHighlight = function(highlight) {
highlight = $(highlight);
this.highlights.removeClass(this.classes.hl.active);
highlight.addClass(this.classes.hl.active);
return $('html, body').animate({
scrollTop: highlight.offset().top - (this.element.height() + 20)
}, 150);
};
Filter.prototype._onClearClick = function(event) {
return $(event.target).prev('input').val('').keyup().blur();
};
return Filter;
})(Annotator.Plugin);
/*
//@ sourceMappingURL=filter.map
*/

File diff suppressed because one or more lines are too long

View file

@ -1,67 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __hasProp = {}.hasOwnProperty,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
Annotator.prototype.setupPlugins = function(config, options) {
var name, opts, pluginConfig, plugins, uri, win, _i, _len, _results;
if (config == null) {
config = {};
}
if (options == null) {
options = {};
}
win = Annotator.Util.getGlobal();
plugins = ['Unsupported', 'Auth', 'Tags', 'Filter', 'Store', 'AnnotateItPermissions'];
if (win.Showdown) {
plugins.push('Markdown');
}
uri = win.location.href.split(/#|\?/).shift() || '';
pluginConfig = {
Tags: {},
Filter: {
filters: [
{
label: Annotator._t('User'),
property: 'user'
}, {
label: Annotator._t('Tags'),
property: 'tags'
}
]
},
Auth: {
tokenUrl: config.tokenUrl || 'http://annotateit.org/api/token'
},
Store: {
prefix: config.storeUrl || 'http://annotateit.org/api',
annotationData: {
uri: uri
},
loadFromSearch: {
uri: uri
}
}
};
for (name in options) {
if (!__hasProp.call(options, name)) continue;
opts = options[name];
if (__indexOf.call(plugins, name) < 0) {
plugins.push(name);
}
}
$.extend(true, pluginConfig, options);
_results = [];
for (_i = 0, _len = plugins.length; _i < _len; _i++) {
name = plugins[_i];
if (!(name in pluginConfig) || pluginConfig[name]) {
_results.push(this.addPlugin(name, pluginConfig[name]));
} else {
_results.push(void 0);
}
}
return _results;
};
/*
//@ sourceMappingURL=kitchensink.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "kitchensink.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/kitchensink.coffee"
],
"names": [],
"mappings": ";AA2BA,IAAA;wJAAA;;AAAA,CAAA,CAAsC,CAAZ,GAAA,CAAA,EAAjB,GAAT;CACE,KAAA,yDAAA;;GADgC,CAAP;IACzB;;GAD4C,CAAR;IACpC;CAAA,CAAA,CAAA,CAAoB,KAAL;CAAf,CAGA,CAAU,GAAA,CAAV,CAAU,KAAA,UAAA;CAGV,CAAA,CAAM,CAAH,IAAH;CACE,GAAA,GAAO,GAAP;IAPF;CAAA,CAUA,CAAA,CAAuB,CAAjB,CAAA,EAAY;CAVlB,CAYA,CACE,SADF;CACE,CAAM,EAAN;CAAA,CAEE,EADF,EAAA;CACE,CAAS,IAAT,CAAA;SACE;CAAA,CAAQ,GAAP,CAAO,GAAS,CAAhB;CAAD,CAAwC,IAAxC,EAA8B,EAAA;EAC9B,QAFO;CAEP,CAAQ,GAAP,CAAO,GAAS,CAAhB;CAAD,CAAwC,IAAxC,EAA8B,EAAA;UAFvB;QAAT;MAFF;CAAA,CAOE,EADF;CACE,CAAU,EAAmB,EAA7B,EAAA,yBAAA;MAPF;CAAA,CASE,EADF,CAAA;CACE,CAAQ,EAAmB,EAA3B,EAAQ,mBAAR;CAAA,CAEE,IADF,QAAA;CACE,CAAK,CAAL,KAAA;QAFF;CAAA,CAIE,IADF,QAAA;CACE,CAAK,CAAL,KAAA;QAJF;MATF;CAbF,GAAA;AA4BA,CAAA,MAAA,QAAA;;0BAAA;CACE,CAAG,EAAH,CAAA,EAAG,QAAY;CACb,GAAA,EAAA,CAAO;MAFX;CAAA,EA5BA;CAAA,CAgCA,EAAA,EAAA,CAAA,KAAA;AAEA,CAAA;QAAA,sCAAA;wBAAA;AACK,CAAH,GAAA,QAAG;CACD,CAAqB,EAAjB,KAAJ,GAAkC;MADpC;CAAA;MADF;CAAA;mBAnCwB;CAAA"
}

View file

@ -1,39 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator.Plugin.Markdown = (function(_super) {
__extends(Markdown, _super);
Markdown.prototype.events = {
'annotationViewerTextField': 'updateTextField'
};
function Markdown(element, options) {
this.updateTextField = __bind(this.updateTextField, this);
if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) {
Markdown.__super__.constructor.apply(this, arguments);
this.converter = new Showdown.converter();
} else {
console.error(Annotator._t("To use the Markdown plugin, you must include Showdown into the page first."));
}
}
Markdown.prototype.updateTextField = function(field, annotation) {
var text;
text = Annotator.Util.escape(annotation.text || '');
return $(field).html(this.convert(text));
};
Markdown.prototype.convert = function(text) {
return this.converter.makeHtml(text);
};
return Markdown;
})(Annotator.Plugin);
/*
//@ sourceMappingURL=markdown.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "markdown.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/markdown.coffee"
],
"names": [],
"mappings": ";AAEA,IAAA;;kSAAA;;AAAM,CAAN,KAAsB,GAAP;CAEb;;CAAA,EACE,GADF;CACE,CAA6B,EAA7B,aAAA,UAAA;CADF,GAAA;;CAaa,CAAA,CAAA,IAAA,WAAC;CACZ,wDAAA;CAAA,GAAA,wFAAA;CACE,KAAA,GAAA,kCAAA;CAAA,EACiB,CAAhB,EAAD,EAAyB,CAAzB;MAFF;CAIE,CAAc,GAAd,CAAA,CAAO,EAAgB,mEAAT;MALL;CAbb,EAaa;;CAbb,CAiCyB,CAAR,EAAA,IAAC,CAAD,KAAjB;CAEE,GAAA,IAAA;CAAA,CAAO,CAAA,CAAP,EAAO,GAAS,CAAuB;CACvC,GAAA,CAAA,EAAc,IAAd;CApCF,EAiCiB;;CAjCjB,EAgDS,CAAA,GAAT,EAAU;CACP,GAAA,IAAD,CAAU,EAAV;CAjDF,EAgDS;;CAhDT;;CAFsC,QAAS"
}

View file

@ -1,205 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator.Plugin.Permissions = (function(_super) {
__extends(Permissions, _super);
Permissions.prototype.events = {
'beforeAnnotationCreated': 'addFieldsToAnnotation'
};
Permissions.prototype.options = {
showViewPermissionsCheckbox: true,
showEditPermissionsCheckbox: true,
userId: function(user) {
return user;
},
userString: function(user) {
return user;
},
userAuthorize: function(action, annotation, user) {
var token, tokens, _i, _len;
if (annotation.permissions) {
tokens = annotation.permissions[action] || [];
if (tokens.length === 0) {
return true;
}
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
if (this.userId(user) === token) {
return true;
}
}
return false;
} else if (annotation.user) {
if (user) {
return this.userId(user) === this.userId(annotation.user);
} else {
return false;
}
}
return true;
},
user: '',
permissions: {
'read': [],
'update': [],
'delete': [],
'admin': []
}
};
function Permissions(element, options) {
this._setAuthFromToken = __bind(this._setAuthFromToken, this);
this.updateViewer = __bind(this.updateViewer, this);
this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);
this.updatePermissionsField = __bind(this.updatePermissionsField, this);
this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this);
Permissions.__super__.constructor.apply(this, arguments);
if (this.options.user) {
this.setUser(this.options.user);
delete this.options.user;
}
}
Permissions.prototype.pluginInit = function() {
var createCallback, self,
_this = this;
if (!Annotator.supported()) {
return;
}
self = this;
createCallback = function(method, type) {
return function(field, annotation) {
return self[method].call(self, type, field, annotation);
};
};
if (!this.user && this.annotator.plugins.Auth) {
this.annotator.plugins.Auth.withToken(this._setAuthFromToken);
}
if (this.options.showViewPermissionsCheckbox === true) {
this.annotator.editor.addField({
type: 'checkbox',
label: Annotator._t('Allow anyone to <strong>view</strong> this annotation'),
load: createCallback('updatePermissionsField', 'read'),
submit: createCallback('updateAnnotationPermissions', 'read')
});
}
if (this.options.showEditPermissionsCheckbox === true) {
this.annotator.editor.addField({
type: 'checkbox',
label: Annotator._t('Allow anyone to <strong>edit</strong> this annotation'),
load: createCallback('updatePermissionsField', 'update'),
submit: createCallback('updateAnnotationPermissions', 'update')
});
}
this.annotator.viewer.addField({
load: this.updateViewer
});
if (this.annotator.plugins.Filter) {
return this.annotator.plugins.Filter.addFilter({
label: Annotator._t('User'),
property: 'user',
isFiltered: function(input, user) {
var keyword, _i, _len, _ref;
user = _this.options.userString(user);
if (!(input && user)) {
return false;
}
_ref = input.split(/\s*/);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
keyword = _ref[_i];
if (user.indexOf(keyword) === -1) {
return false;
}
}
return true;
}
});
}
};
Permissions.prototype.setUser = function(user) {
return this.user = user;
};
Permissions.prototype.addFieldsToAnnotation = function(annotation) {
if (annotation) {
annotation.permissions = this.options.permissions;
if (this.user) {
return annotation.user = this.user;
}
}
};
Permissions.prototype.authorize = function(action, annotation, user) {
if (user === void 0) {
user = this.user;
}
if (this.options.userAuthorize) {
return this.options.userAuthorize.call(this.options, action, annotation, user);
} else {
return true;
}
};
Permissions.prototype.updatePermissionsField = function(action, field, annotation) {
var input;
field = $(field).show();
input = field.find('input').removeAttr('disabled');
if (!this.authorize('admin', annotation)) {
field.hide();
}
if (this.authorize(action, annotation || {}, null)) {
return input.attr('checked', 'checked');
} else {
return input.removeAttr('checked');
}
};
Permissions.prototype.updateAnnotationPermissions = function(type, field, annotation) {
var dataKey;
if (!annotation.permissions) {
annotation.permissions = this.options.permissions;
}
dataKey = type + '-permissions';
if ($(field).find('input').is(':checked')) {
return annotation.permissions[type] = [];
} else {
return annotation.permissions[type] = [this.user];
}
};
Permissions.prototype.updateViewer = function(field, annotation, controls) {
var user, username;
field = $(field);
username = this.options.userString(annotation.user);
if (annotation.user && username && typeof username === 'string') {
user = Annotator.Util.escape(this.options.userString(annotation.user));
field.html(user).addClass('annotator-user');
} else {
field.remove();
}
if (controls) {
if (!this.authorize('update', annotation)) {
controls.hideEdit();
}
if (!this.authorize('delete', annotation)) {
return controls.hideDelete();
}
}
};
Permissions.prototype._setAuthFromToken = function(token) {
return this.setUser(token.userId);
};
return Permissions;
})(Annotator.Plugin);
/*
//@ sourceMappingURL=permissions.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,CAAa,EAAvB;MADF;CAOa,EAAoB,CAAR,MAAb,CAAa,EAAvB;MAZyB;CAjQ7B,EAiQ6B;;CAjQ7B,CAuRsB,CAAR,EAAA,GAAA,CAAC,CAAD,EAAd;CACE,OAAA,MAAA;CAAA,EAAQ,CAAR,CAAA;CAAA,EAEW,CAAX,GAAmB,CAAnB,EAAW;AACyB,CAApC,GAAA,CAAuD,CAAnB,EAAjC,EAAU;CACX,EAAO,CAAP,EAAA,CAAqC,EAArB,CAAa;CAA7B,GACA,CAAK,CAAL,EAAA,QAAA;MAFF;CAIE,IAAK,CAAL;MAPF;CASA,GAAA,IAAA;AAC+B,CAA7B,CAAsD,EAAtD,EAAA,EAA6B,CAAA,CAAA;CAA7B,OAAA;QAAA;AAC6B,CAA7B,CAAsD,EAAtD,EAAA,EAA6B,CAAA,CAAA;CAApB,OAAD,EAAR,KAAA;QAFF;MAVY;CAvRd,EAuRc;;CAvRd,EA0SmB,EAAA,IAAC,QAApB;CACO,GAAD,CAAc,CAAlB,CAAA,IAAA;CA3SF,EA0SmB;;CA1SnB;;CAJyC,QAAS"
}

View file

@ -1,271 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
Annotator.Plugin.Store = (function(_super) {
__extends(Store, _super);
Store.prototype.events = {
'annotationCreated': 'annotationCreated',
'annotationDeleted': 'annotationDeleted',
'annotationUpdated': 'annotationUpdated'
};
Store.prototype.options = {
annotationData: {},
emulateHTTP: false,
loadFromSearch: false,
prefix: '/store',
urls: {
create: '/annotations',
read: '/annotations/:id',
update: '/annotations/:id',
destroy: '/annotations/:id',
search: '/search'
}
};
function Store(element, options) {
this._onError = __bind(this._onError, this);
this._onLoadAnnotationsFromSearch = __bind(this._onLoadAnnotationsFromSearch, this);
this._onLoadAnnotations = __bind(this._onLoadAnnotations, this);
this._getAnnotations = __bind(this._getAnnotations, this);
Store.__super__.constructor.apply(this, arguments);
this.annotations = [];
}
Store.prototype.pluginInit = function() {
if (!Annotator.supported()) {
return;
}
if (this.annotator.plugins.Auth) {
return this.annotator.plugins.Auth.withToken(this._getAnnotations);
} else {
return this._getAnnotations();
}
};
Store.prototype._getAnnotations = function() {
if (this.options.loadFromSearch) {
return this.loadAnnotationsFromSearch(this.options.loadFromSearch);
} else {
return this.loadAnnotations();
}
};
Store.prototype.annotationCreated = function(annotation) {
var _this = this;
if (__indexOf.call(this.annotations, annotation) < 0) {
this.registerAnnotation(annotation);
return this._apiRequest('create', annotation, function(data) {
if (data.id == null) {
console.warn(Annotator._t("Warning: No ID returned from server for annotation "), annotation);
}
return _this.updateAnnotation(annotation, data);
});
} else {
return this.updateAnnotation(annotation, {});
}
};
Store.prototype.annotationUpdated = function(annotation) {
var _this = this;
if (__indexOf.call(this.annotations, annotation) >= 0) {
return this._apiRequest('update', annotation, (function(data) {
return _this.updateAnnotation(annotation, data);
}));
}
};
Store.prototype.annotationDeleted = function(annotation) {
var _this = this;
if (__indexOf.call(this.annotations, annotation) >= 0) {
return this._apiRequest('destroy', annotation, (function() {
return _this.unregisterAnnotation(annotation);
}));
}
};
Store.prototype.registerAnnotation = function(annotation) {
return this.annotations.push(annotation);
};
Store.prototype.unregisterAnnotation = function(annotation) {
return this.annotations.splice(this.annotations.indexOf(annotation), 1);
};
Store.prototype.updateAnnotation = function(annotation, data) {
if (__indexOf.call(this.annotations, annotation) < 0) {
console.error(Annotator._t("Trying to update unregistered annotation!"));
} else {
$.extend(annotation, data);
}
return $(annotation.highlights).data('annotation', annotation);
};
Store.prototype.loadAnnotations = function() {
return this._apiRequest('read', null, this._onLoadAnnotations);
};
Store.prototype._onLoadAnnotations = function(data) {
var a, annotation, annotationMap, newData, _i, _j, _len, _len1, _ref;
if (data == null) {
data = [];
}
annotationMap = {};
_ref = this.annotations;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
annotationMap[a.id] = a;
}
newData = [];
for (_j = 0, _len1 = data.length; _j < _len1; _j++) {
a = data[_j];
if (annotationMap[a.id]) {
annotation = annotationMap[a.id];
this.updateAnnotation(annotation, a);
} else {
newData.push(a);
}
}
this.annotations = this.annotations.concat(newData);
return this.annotator.loadAnnotations(newData.slice());
};
Store.prototype.loadAnnotationsFromSearch = function(searchOptions) {
return this._apiRequest('search', searchOptions, this._onLoadAnnotationsFromSearch);
};
Store.prototype._onLoadAnnotationsFromSearch = function(data) {
if (data == null) {
data = {};
}
return this._onLoadAnnotations(data.rows || []);
};
Store.prototype.dumpAnnotations = function() {
var ann, _i, _len, _ref, _results;
_ref = this.annotations;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
ann = _ref[_i];
_results.push(JSON.parse(this._dataFor(ann)));
}
return _results;
};
Store.prototype._apiRequest = function(action, obj, onSuccess) {
var id, options, request, url;
id = obj && obj.id;
url = this._urlFor(action, id);
options = this._apiRequestOptions(action, obj, onSuccess);
request = $.ajax(url, options);
request._id = id;
request._action = action;
return request;
};
Store.prototype._apiRequestOptions = function(action, obj, onSuccess) {
var data, method, opts;
method = this._methodFor(action);
opts = {
type: method,
headers: this.element.data('annotator:headers'),
dataType: "json",
success: onSuccess || function() {},
error: this._onError
};
if (this.options.emulateHTTP && (method === 'PUT' || method === 'DELETE')) {
opts.headers = $.extend(opts.headers, {
'X-HTTP-Method-Override': method
});
opts.type = 'POST';
}
if (action === "search") {
opts = $.extend(opts, {
data: obj
});
return opts;
}
data = obj && this._dataFor(obj);
if (this.options.emulateJSON) {
opts.data = {
json: data
};
if (this.options.emulateHTTP) {
opts.data._method = method;
}
return opts;
}
opts = $.extend(opts, {
data: data,
contentType: "application/json; charset=utf-8"
});
return opts;
};
Store.prototype._urlFor = function(action, id) {
var url;
url = this.options.prefix != null ? this.options.prefix : '';
url += this.options.urls[action];
url = url.replace(/\/:id/, id != null ? '/' + id : '');
url = url.replace(/:id/, id != null ? id : '');
return url;
};
Store.prototype._methodFor = function(action) {
var table;
table = {
'create': 'POST',
'read': 'GET',
'update': 'PUT',
'destroy': 'DELETE',
'search': 'GET'
};
return table[action];
};
Store.prototype._dataFor = function(annotation) {
var data, highlights;
highlights = annotation.highlights;
delete annotation.highlights;
$.extend(annotation, this.options.annotationData);
data = JSON.stringify(annotation);
if (highlights) {
annotation.highlights = highlights;
}
return data;
};
Store.prototype._onError = function(xhr) {
var action, message;
action = xhr._action;
message = Annotator._t("Sorry we could not ") + action + Annotator._t(" this annotation");
if (xhr._action === 'search') {
message = Annotator._t("Sorry we could not search the store for annotations");
} else if (xhr._action === 'read' && !xhr._id) {
message = Annotator._t("Sorry we could not ") + action + Annotator._t(" the annotations from the store");
}
switch (xhr.status) {
case 401:
message = Annotator._t("Sorry you are not allowed to ") + action + Annotator._t(" this annotation");
break;
case 404:
message = Annotator._t("Sorry we could not connect to the annotations store");
break;
case 500:
message = Annotator._t("Sorry something went wrong with the annotation store");
}
Annotator.showNotification(message, Annotator.Notification.ERROR);
return console.error(Annotator._t("API request failed:") + (" '" + xhr.status + "'"));
};
return Store;
})(Annotator.Plugin);
/*
//@ sourceMappingURL=store.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "store.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/store.coffee"
],
"names": [],
"mappings": ";AAiBA,IAAA;;;wJAAA;;AAAM,CAAN,KAAsB,GAAP;CAKb;;CAAA,EACE,GADF;CACE,CAAqB,EAArB,eAAA;CAAA,CACqB,EAArB,eAAA;CADA,CAEqB,EAArB,eAAA;CAHF,GAAA;;CAAA,EAUE,IAJF;CAIE,CAAgB,EAAhB,UAAA;CAAA,CAOa,EAAb,CAPA,MAOA;CAPA,CAkBgB,EAAh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AA;CAAA,CACU,CAAA,CAAV,EAAU,CAAV,EAAmB,SAAsC,GAA/C;CAEV,EAAM,CAAN,CAAkB,EAAf,CAAH;CACE,CAAU,CAAA,GAAV,CAAA,EAAmB,4CAAT;AACsB,CAAtB,EAAD,CAAH,CAAe,CAFvB,CAEQ;CACN,CAAU,CAAA,GAAV,CAAA,EAAmB,YAAT,YAA+C;MAN3D;CAQA,EAAU,GAAV,MAAO;CAAP,EAAA,QACO;CAAS,CAAU,CAAA,GAAA,CAAV,CAAA,CAAmB,SAAgD,aAAzD;CAAnB;CADP,EAAA,QAEO;CAAS,CAAU,CAAA,IAAV,CAAA,CAAmB,4CAAT;CAAnB;CAFP,EAAA,QAGO;CAAS,CAAU,CAAA,IAAV,CAAA,CAAmB,6CAAT;CAH1B,IARA;CAAA,CAaoC,EAApC,CAAA,EAAA,EAAS,GAAiD,IAA1D;CAEQ,CAAM,CAAsC,CAAC,CAArD,CAAqD,CAA9C,EAAgB,EAAvB,UAAc;CA5dhB,EA4cU;;CA5cV;;CALmC,QAAS"
}

View file

@ -1,123 +0,0 @@
// Generated by CoffeeScript 1.6.3
var _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator.Plugin.Tags = (function(_super) {
__extends(Tags, _super);
function Tags() {
this.setAnnotationTags = __bind(this.setAnnotationTags, this);
this.updateField = __bind(this.updateField, this);
_ref = Tags.__super__.constructor.apply(this, arguments);
return _ref;
}
Tags.prototype.options = {
parseTags: function(string) {
var tags;
string = $.trim(string);
tags = [];
if (string) {
tags = string.split(/\s+/);
}
return tags;
},
stringifyTags: function(array) {
return array.join(" ");
}
};
Tags.prototype.field = null;
Tags.prototype.input = null;
Tags.prototype.pluginInit = function() {
if (!Annotator.supported()) {
return;
}
this.field = this.annotator.editor.addField({
label: Annotator._t('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: Annotator._t('Tag'),
property: 'tags',
isFiltered: Annotator.Plugin.Tags.filterCallback
});
}
return this.input = $(this.field).find(':input');
};
Tags.prototype.parseTags = function(string) {
return this.options.parseTags(string);
};
Tags.prototype.stringifyTags = function(array) {
return this.options.stringifyTags(array);
};
Tags.prototype.updateField = function(field, annotation) {
var value;
value = '';
if (annotation.tags) {
value = this.stringifyTags(annotation.tags);
}
return this.input.val(value);
};
Tags.prototype.setAnnotationTags = function(field, annotation) {
return annotation.tags = this.parseTags(this.input.val());
};
Tags.prototype.updateViewer = function(field, annotation) {
field = $(field);
if (annotation.tags && $.isArray(annotation.tags) && annotation.tags.length) {
return field.addClass('annotator-tags').html(function() {
var string;
return string = $.map(annotation.tags, function(tag) {
return '<span class="annotator-tag">' + Annotator.Util.escape(tag) + '</span>';
}).join(' ');
});
} else {
return field.remove();
}
};
return Tags;
})(Annotator.Plugin);
Annotator.Plugin.Tags.filterCallback = function(input, tags) {
var keyword, keywords, matches, tag, _i, _j, _len, _len1;
if (tags == null) {
tags = [];
}
matches = 0;
keywords = [];
if (input) {
keywords = input.split(/\s+/g);
for (_i = 0, _len = keywords.length; _i < _len; _i++) {
keyword = keywords[_i];
if (tags.length) {
for (_j = 0, _len1 = tags.length; _j < _len1; _j++) {
tag = tags[_j];
if (tag.indexOf(keyword) !== -1) {
matches += 1;
}
}
}
}
}
return matches === keywords.length;
};
/*
//@ sourceMappingURL=tags.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "tags.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/tags.coffee"
],
"names": [],
"mappings": ";AAEA,IAAA;GAAA;;kSAAA;;AAAM,CAAN,KAAsB,GAAP;CAEb;;;;;;;CAAA;;CA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AA,IAAqC,GAA7B;MADR;CAGC,EAAD,CAAC,CAAK,MAAN;CA9FF,EA0Fa;;CA1Fb,CA+G2B,CAAR,EAAA,IAAC,CAAD,OAAnB;CACa,EAAO,CAAlB,CAAuC,IAArB,CAAR,CAAV;CAhHF,EA+GmB;;CA/GnB,CA+HsB,CAAR,EAAA,IAAC,CAAD,EAAd;CACE,EAAQ,CAAR,CAAA;CAEA,GAAA,EAAA,CAAuB,GAAV;CACL,EAAgC,CAAtC,CAAK,GAAL,CAAsC,IAAtC,GAAA;CACE,KAAA,MAAA;CAAU,CAAqB,CAAtB,CAAA,EAAT,GAAgC,CAAP,KAAzB;CAC+C,EAAV,CAAc,EAAd,GAAS,QAA1C,aAAA;CADK,EAAA,CAAA,KAAsB;CADjC,MAAsC;MADxC;CAOQ,IAAD,CAAL,OAAA;MAVU;CA/Hd,EA+Hc;;CA/Hd;;CAFkC,QAAS;;AA0J7C,CA1JA,CA0J+C,CAAR,CAAlB,CAAkB,CAAvB,GAAP,KAAT;CACE,KAAA,8CAAA;;GADoD,CAAP;IAC7C;CAAA,CAAA,CAAW,IAAX;CAAA,CACA,CAAW,KAAX;CACA,CAAA,EAAG,CAAH;CACE,EAAW,CAAX,CAAgB,CAAL,EAAX;AACA,CAAA,QAAA,sCAAA;8BAAA;CAAkC,GAAL;AAC3B,CAAA,YAAA,gCAAA;0BAAA;AAA2D,CAArB,EAAD,CAAH,CAAwB,EAAxB;CAAlC,GAAW,GAAX,KAAA;YAAA;CAAA;QADF;CAAA,IAFF;IAFA;CAOoB,IAAT,EAAX,CAAmB,CAAnB;CARqC"
}

View file

@ -1,36 +0,0 @@
// Generated by CoffeeScript 1.6.3
var _ref,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Annotator.Plugin.Unsupported = (function(_super) {
__extends(Unsupported, _super);
function Unsupported() {
_ref = Unsupported.__super__.constructor.apply(this, arguments);
return _ref;
}
Unsupported.prototype.options = {
message: Annotator._t("Sorry your current browser does not support the Annotator")
};
Unsupported.prototype.pluginInit = function() {
var _this = this;
if (!Annotator.supported()) {
return $(function() {
Annotator.showNotification(_this.options.message);
if ((window.XMLHttpRequest === void 0) && (ActiveXObject !== void 0)) {
return $('html').addClass('ie6');
}
});
}
};
return Unsupported;
})(Annotator.Plugin);
/*
//@ sourceMappingURL=unsupported.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "unsupported.js",
"sourceRoot": "../..",
"sources": [
"src/plugin/unsupported.coffee"
],
"names": [],
"mappings": ";AAEA,IAAA;GAAA;kSAAA;;AAAM,CAAN,KAAsB,GAAP;CAEb;;;;;CAAA;;CAAA,EACE,IADF;CACE,CAAS,EAAT,GAAA,EAAkB,kDAAT;CADX,GAAA;;CAAA,EAOY,MAAA,CAAZ;CACE,OAAA,IAAA;AAAO,CAAP,GAAA,KAAgB;CACd,EAAE,MAAA,IAAF;CAEE,IAA4B,EAAO,CAAnC,CAAS,OAAT;CAIA,GAAG,CAA0B,CAAnB,EAAV,KAA6C,CAAzC;CACF,IAAA,CAAA,EAAA,SAAA;UAPF;CAAF,MAAE;MAFM;CAPZ,EAOY;;CAPZ;;CAFyC,QAAS"
}

View file

@ -1,17 +0,0 @@
// Generated by CoffeeScript 1.6.3
/*
** Annotator {{VERSION}}
** https://github.com/okfn/annotator/
**
** Copyright 2012 {{AUTHORS}}.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: {{DATE}}
*/
/*
//@ sourceMappingURL=preamble.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "preamble.js",
"sourceRoot": "..",
"sources": [
"src/preamble.coffee"
],
"names": [],
"mappings": ";AAAA;;;;;;;;;;CAAA;CAAA"
}

View file

@ -1,326 +0,0 @@
// Generated by CoffeeScript 1.6.3
var Range,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Range = {};
Range.sniff = function(r) {
if (r.commonAncestorContainer != null) {
return new Range.BrowserRange(r);
} else if (typeof r.start === "string") {
return new Range.SerializedRange(r);
} else if (r.start && typeof r.start === "object") {
return new Range.NormalizedRange(r);
} else {
console.error(_t("Could not sniff range type"));
return false;
}
};
Range.nodeFromXPath = function(xpath, root) {
var customResolver, evaluateXPath, namespace, node, segment;
if (root == null) {
root = document;
}
this.document = root.ownerDocument || document;
evaluateXPath = function(xp, nsResolver) {
var exception;
if (nsResolver == null) {
nsResolver = null;
}
try {
return this.document.evaluate('.' + xp, root, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
} catch (_error) {
exception = _error;
console.log("XPath evaluation failed.");
console.log("Trying fallback...");
return Util.nodeFromXPath(xp, root);
}
};
if (!$.isXMLDoc(document.documentElement)) {
return evaluateXPath(xpath);
} else {
customResolver = document.createNSResolver(document.ownerDocument === null ? document.documentElement : document.ownerDocument.documentElement);
node = evaluateXPath(xpath, customResolver);
if (!node) {
xpath = ((function() {
var _i, _len, _ref, _results;
_ref = xpath.split('/');
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
segment = _ref[_i];
if (segment && segment.indexOf(':') === -1) {
_results.push(segment.replace(/^([a-z]+)/, 'xhtml:$1'));
} else {
_results.push(segment);
}
}
return _results;
})()).join('/');
namespace = document.lookupNamespaceURI(null);
customResolver = function(ns) {
if (ns === 'xhtml') {
return namespace;
} else {
return document.documentElement.getAttribute('xmlns:' + ns);
}
};
node = evaluateXPath(xpath, customResolver);
}
return node;
}
};
Range.RangeError = (function(_super) {
__extends(RangeError, _super);
function RangeError(type, message, parent) {
this.type = type;
this.message = message;
this.parent = parent != null ? parent : null;
RangeError.__super__.constructor.call(this, this.message);
}
return RangeError;
})(Error);
Range.BrowserRange = (function() {
function BrowserRange(obj) {
this.commonAncestorContainer = obj.commonAncestorContainer;
this.startContainer = obj.startContainer;
this.startOffset = obj.startOffset;
this.endContainer = obj.endContainer;
this.endOffset = obj.endOffset;
}
BrowserRange.prototype.normalize = function(root) {
var it, node, nr, offset, p, r, _i, _len, _ref;
if (this.tainted) {
console.error(_t("You may only call normalize() once on a BrowserRange!"));
return false;
} else {
this.tainted = true;
}
r = {};
nr = {};
_ref = ['start', 'end'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
p = _ref[_i];
node = this[p + 'Container'];
offset = this[p + 'Offset'];
if (node.nodeType === Node.ELEMENT_NODE) {
it = node.childNodes[offset];
node = it || node.childNodes[offset - 1];
if (node.nodeType === Node.ELEMENT_NODE && !node.firstChild) {
it = null;
node = node.previousSibling;
}
while (node.nodeType !== Node.TEXT_NODE) {
node = node.firstChild;
}
offset = it ? 0 : node.nodeValue.length;
}
r[p] = node;
r[p + 'Offset'] = offset;
}
nr.start = r.startOffset > 0 ? r.start.splitText(r.startOffset) : r.start;
if (r.start === r.end) {
if ((r.endOffset - r.startOffset) < nr.start.nodeValue.length) {
nr.start.splitText(r.endOffset - r.startOffset);
}
nr.end = nr.start;
} else {
if (r.endOffset < r.end.nodeValue.length) {
r.end.splitText(r.endOffset);
}
nr.end = r.end;
}
nr.commonAncestor = this.commonAncestorContainer;
while (nr.commonAncestor.nodeType !== Node.ELEMENT_NODE) {
nr.commonAncestor = nr.commonAncestor.parentNode;
}
return new Range.NormalizedRange(nr);
};
BrowserRange.prototype.serialize = function(root, ignoreSelector) {
return this.normalize(root).serialize(root, ignoreSelector);
};
return BrowserRange;
})();
Range.NormalizedRange = (function() {
function NormalizedRange(obj) {
this.commonAncestor = obj.commonAncestor;
this.start = obj.start;
this.end = obj.end;
}
NormalizedRange.prototype.normalize = function(root) {
return this;
};
NormalizedRange.prototype.limit = function(bounds) {
var nodes, parent, startParents, _i, _len, _ref;
nodes = $.grep(this.textNodes(), function(node) {
return node.parentNode === bounds || $.contains(bounds, node.parentNode);
});
if (!nodes.length) {
return null;
}
this.start = nodes[0];
this.end = nodes[nodes.length - 1];
startParents = $(this.start).parents();
_ref = $(this.end).parents();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
parent = _ref[_i];
if (startParents.index(parent) !== -1) {
this.commonAncestor = parent;
break;
}
}
return this;
};
NormalizedRange.prototype.serialize = function(root, ignoreSelector) {
var end, serialization, start;
serialization = function(node, isEnd) {
var n, nodes, offset, origParent, textNodes, xpath, _i, _len;
if (ignoreSelector) {
origParent = $(node).parents(":not(" + ignoreSelector + ")").eq(0);
} else {
origParent = $(node).parent();
}
xpath = Util.xpathFromNode(origParent, root)[0];
textNodes = Util.getTextNodes(origParent);
nodes = textNodes.slice(0, textNodes.index(node));
offset = 0;
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
n = nodes[_i];
offset += n.nodeValue.length;
}
if (isEnd) {
return [xpath, offset + node.nodeValue.length];
} else {
return [xpath, offset];
}
};
start = serialization(this.start);
end = serialization(this.end, true);
return new Range.SerializedRange({
start: start[0],
end: end[0],
startOffset: start[1],
endOffset: end[1]
});
};
NormalizedRange.prototype.text = function() {
var node;
return ((function() {
var _i, _len, _ref, _results;
_ref = this.textNodes();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
node = _ref[_i];
_results.push(node.nodeValue);
}
return _results;
}).call(this)).join('');
};
NormalizedRange.prototype.textNodes = function() {
var end, start, textNodes, _ref;
textNodes = Util.getTextNodes($(this.commonAncestor));
_ref = [textNodes.index(this.start), textNodes.index(this.end)], start = _ref[0], end = _ref[1];
return $.makeArray(textNodes.slice(start, +end + 1 || 9e9));
};
NormalizedRange.prototype.toRange = function() {
var range;
range = document.createRange();
range.setStartBefore(this.start);
range.setEndAfter(this.end);
return range;
};
return NormalizedRange;
})();
Range.SerializedRange = (function() {
function SerializedRange(obj) {
this.start = obj.start;
this.startOffset = obj.startOffset;
this.end = obj.end;
this.endOffset = obj.endOffset;
}
SerializedRange.prototype.normalize = function(root) {
var contains, e, length, node, p, range, tn, _i, _j, _len, _len1, _ref, _ref1;
range = {};
_ref = ['start', 'end'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
p = _ref[_i];
try {
node = Range.nodeFromXPath(this[p], root);
} catch (_error) {
e = _error;
throw new Range.RangeError(p, ("Error while finding " + p + " node: " + this[p] + ": ") + e, e);
}
if (!node) {
throw new Range.RangeError(p, "Couldn't find " + p + " node: " + this[p]);
}
length = 0;
_ref1 = Util.getTextNodes($(node));
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
tn = _ref1[_j];
if (length + tn.nodeValue.length >= this[p + 'Offset']) {
range[p + 'Container'] = tn;
range[p + 'Offset'] = this[p + 'Offset'] - length;
break;
} else {
length += tn.nodeValue.length;
}
}
if (range[p + 'Offset'] == null) {
throw new Range.RangeError("" + p + "offset", "Couldn't find offset " + this[p + 'Offset'] + " in element " + this[p]);
}
}
contains = document.compareDocumentPosition == null ? function(a, b) {
return a.contains(b);
} : function(a, b) {
return a.compareDocumentPosition(b) & 16;
};
$(range.startContainer).parents().each(function() {
if (contains(this, range.endContainer)) {
range.commonAncestorContainer = this;
return false;
}
});
return new Range.BrowserRange(range).normalize(root);
};
SerializedRange.prototype.serialize = function(root, ignoreSelector) {
return this.normalize(root).serialize(root, ignoreSelector);
};
SerializedRange.prototype.toObject = function() {
return {
start: this.start,
startOffset: this.startOffset,
end: this.end,
endOffset: this.endOffset
};
};
return SerializedRange;
})();
/*
//@ sourceMappingURL=range.map
*/

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,166 +0,0 @@
// Generated by CoffeeScript 1.6.3
var DelegatedExample,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
DelegatedExample = (function(_super) {
__extends(DelegatedExample, _super);
DelegatedExample.prototype.events = {
'div click': 'pushA',
'baz': 'pushB',
'li click': 'pushC'
};
DelegatedExample.prototype.options = {
foo: "bar",
bar: function(a) {
return a;
}
};
function DelegatedExample(elem) {
DelegatedExample.__super__.constructor.apply(this, arguments);
this.returns = [];
}
DelegatedExample.prototype.pushA = function() {
return this.returns.push("A");
};
DelegatedExample.prototype.pushB = function() {
return this.returns.push("B");
};
DelegatedExample.prototype.pushC = function() {
return this.returns.push("C");
};
return DelegatedExample;
})(Delegator);
describe('Delegator', function() {
var $fix, delegator;
delegator = null;
$fix = null;
beforeEach(function() {
addFixture('delegator');
delegator = new DelegatedExample(fix());
return $fix = $(fix());
});
afterEach(function() {
return clearFixtures();
});
describe("options", function() {
it("should provide access to an options object", function() {
assert.equal(delegator.options.foo, "bar");
return delegator.options.bar = function(a) {
return "<" + a + ">";
};
});
return it("should be unique to an instance", function() {
return assert.equal(delegator.options.bar("hello"), "hello");
});
});
it("automatically binds events described in its events property", function() {
$fix.find('p').click();
return assert.deepEqual(delegator.returns, ['A']);
});
it("will bind events in its events property to its root element if no selector is specified", function() {
$fix.trigger('baz');
return assert.deepEqual(delegator.returns, ['B']);
});
it("uses event delegation to bind the events", function() {
$fix.find('ol').append("<li>Hi there, I'm new round here.</li>");
$fix.find('li').click();
return assert.deepEqual(delegator.returns, ['C', 'A', 'C', 'A']);
});
describe("removeEvents", function() {
return it("should remove all events previously bound by addEvents", function() {
delegator.removeEvents();
$fix.find('ol').append("<li>Hi there, I'm new round here.</li>");
$fix.find('li').click();
$fix.trigger('baz');
return assert.deepEqual(delegator.returns, []);
});
});
describe("on", function() {
return it("should be an alias of Delegator#subscribe()", function() {
return assert.strictEqual(delegator.on, delegator.subscribe);
});
});
describe("subscribe", function() {
it("should bind an event to the Delegator#element", function() {
var callback;
callback = sinon.spy();
delegator.subscribe('custom', callback);
delegator.element.trigger('custom');
return assert(callback.called);
});
it("should remove the event object from the parameters passed to the callback", function() {
var callback;
callback = sinon.spy();
delegator.subscribe('custom', callback);
delegator.element.trigger('custom', ['first', 'second', 'third']);
return assert(callback.calledWith('first', 'second', 'third'));
});
it("should ensure the bound function is unbindable", function() {
var callback;
callback = sinon.spy();
delegator.subscribe('custom', callback);
delegator.unsubscribe('custom', callback);
delegator.publish('custom');
return assert.isFalse(callback.called);
});
return it("should not bubble custom events", function() {
var callback;
callback = sinon.spy();
$('body').bind('custom', callback);
delegator.element = $('<div />').appendTo('body');
delegator.publish('custom');
return assert.isFalse(callback.called);
});
});
describe("unsubscribe", function() {
return it("should unbind an event from the Delegator#element", function() {
var callback;
callback = sinon.spy();
delegator.element.bind('custom', callback);
delegator.unsubscribe('custom', callback);
delegator.element.trigger('custom');
assert.isFalse(callback.called);
callback = sinon.spy();
delegator.element.bind('custom', callback);
delegator.unsubscribe('custom');
delegator.element.trigger('custom');
return assert.isFalse(callback.called);
});
});
describe("publish", function() {
return it("should trigger an event on the Delegator#element", function() {
var callback;
callback = sinon.spy();
delegator.element.bind('custom', callback);
delegator.publish('custom');
return assert(callback.called);
});
});
return describe("Delegator._isCustomEvent", function() {
var events;
events = [['click', false], ['mouseover', false], ['mousedown', false], ['submit', false], ['load', false], ['click.namespaced', false], ['save', true], ['cancel', true], ['update', true]];
return it("should return true if the string passed is a custom event", function() {
var event, result, _ref, _results;
_results = [];
while (events.length) {
_ref = events.shift(), event = _ref[0], result = _ref[1];
_results.push(assert.equal(Delegator._isCustomEvent(event), result));
}
return _results;
});
});
});
/*
//@ sourceMappingURL=class_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "class_spec.js",
"sourceRoot": "../..",
"sources": [
"test/spec/class_spec.coffee"
],
"names": [],
"mappings": ";AAAA,IAAA,YAAA;GAAA;kSAAA;;AAAM,CAAN;CACE;;CAAA,EACE,GADF;CACE,CAAa,EAAb,GAAA,IAAA;CAAA,CACO,EAAP,CAAA,EAD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AAiB,CAAM,CAAN,CAAlB;CAAA,CAC8C,GAA9C,CAAM,GAAgB,KAAT;CAFf,MAAA;uBAD8D;CAAhE,IAAgE;CAblE,EAAqC;CA3GjB"
}

View file

@ -1,6 +0,0 @@
// Generated by CoffeeScript 1.6.3
/*
//@ sourceMappingURL=console_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "console_spec.js",
"sourceRoot": "../..",
"sources": [
"test/spec/console_spec.coffee"
],
"names": [],
"mappings": ";AA6I6D"
}

View file

@ -1,246 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Annotator.Editor', function() {
var editor;
editor = null;
beforeEach(function() {
return editor = new Annotator.Editor();
});
afterEach(function() {
return editor.element.remove();
});
it("should have an element property", function() {
assert.ok(editor.element);
return assert.isTrue(editor.element.hasClass('annotator-editor'));
});
describe("events", function() {
it("should call Editor#submit() when the form is submitted", function() {
sinon.spy(editor, 'submit');
editor.element.find('form').submit(function(e) {
return e.preventDefault();
}).submit();
return assert(editor.submit.calledOnce);
});
it("should call Editor#submit() when the save button is clicked", function() {
sinon.spy(editor, 'submit');
editor.element.find('.annotator-save').click();
return assert(editor.submit.calledOnce);
});
it("should call Editor#hide() when the cancel button is clicked", function() {
sinon.spy(editor, 'hide');
editor.element.find('.annotator-cancel').click();
return assert(editor.hide.calledOnce);
});
it("should call Editor#onCancelButtonMouseover() when mouse moves over cancel", function() {
sinon.spy(editor, 'onCancelButtonMouseover');
editor.element.find('.annotator-cancel').mouseover();
return assert(editor.onCancelButtonMouseover.calledOnce);
});
return it("should call Editor#processKeypress() when a key is pressed in a textarea", function() {
editor.element.find('ul').append('<li><textarea></textarea></li>');
sinon.spy(editor, 'processKeypress');
editor.element.find('textarea').keydown();
return assert(editor.processKeypress.calledOnce);
});
});
describe("show", function() {
it("should make the editor visible", function() {
editor.show();
return assert.isFalse(editor.element.hasClass('annotator-hide'));
});
return it("should publish the 'show' event", function() {
sinon.spy(editor, 'publish');
editor.show();
return assert.isTrue(editor.publish.calledWith('show'));
});
});
describe("hide", function() {
it("should hide the editor from view", function() {
editor.hide();
return assert.isTrue(editor.element.hasClass('annotator-hide'));
});
return it("should publish the 'show' event", function() {
sinon.spy(editor, 'publish');
editor.hide();
return assert.isTrue(editor.publish.calledWith('hide'));
});
});
describe("load", function() {
beforeEach(function() {
editor.annotation = {
text: 'test'
};
return editor.fields = [
{
element: 'element0',
load: sinon.spy()
}, {
element: 'element1',
load: sinon.spy()
}
];
});
it("should call #show()", function() {
sinon.spy(editor, 'show');
editor.load();
return assert(editor.show.calledOnce);
});
it("should set the current annotation", function() {
editor.load({
text: 'Hello there'
});
return assert.equal(editor.annotation.text, 'Hello there');
});
it("should call the load callback on each field in the group", function() {
editor.load();
assert(editor.fields[0].load.calledOnce);
return assert(editor.fields[1].load.calledOnce);
});
it("should pass the field element and an annotation to the callback", function() {
editor.load();
return assert(editor.fields[0].load.calledWith(editor.fields[0].element, editor.annotation));
});
return it("should publish the 'load' event", function() {
sinon.spy(editor, 'publish');
editor.load();
return assert.isTrue(editor.publish.calledWith('load', [editor.annotation]));
});
});
describe("submit", function() {
beforeEach(function() {
editor.annotation = {
text: 'test'
};
return editor.fields = [
{
element: 'element0',
submit: sinon.spy()
}, {
element: 'element1',
submit: sinon.spy()
}
];
});
it("should call #hide()", function() {
sinon.spy(editor, 'hide');
editor.submit();
return assert(editor.hide.calledOnce);
});
it("should call the submit callback on each field in the group", function() {
editor.submit();
assert(editor.fields[0].submit.calledOnce);
return assert(editor.fields[1].submit.calledOnce);
});
it("should pass the field element and an annotation to the callback", function() {
editor.submit();
return assert(editor.fields[0].submit.calledWith(editor.fields[0].element, editor.annotation));
});
return it("should publish the 'save' event", function() {
sinon.spy(editor, 'publish');
editor.submit();
return assert.isTrue(editor.publish.calledWith('save', [editor.annotation]));
});
});
describe("addField", function() {
var content;
content = null;
beforeEach(function() {
return content = editor.element.children();
});
afterEach(function() {
editor.element.empty().append(content);
return editor.fields = [];
});
it("should append a new field to the @fields property", function() {
var length;
length = editor.fields.length;
editor.addField();
assert.lengthOf(editor.fields, length + 1);
editor.addField();
return assert.lengthOf(editor.fields, length + 2);
});
it("should append a new list element to the editor", function() {
var length;
length = editor.element.find('li').length;
editor.addField();
assert.lengthOf(editor.element.find('li'), length + 1);
editor.addField();
return assert.lengthOf(editor.element.find('li'), length + 2);
});
it("should append an input element if no type is specified", function() {
editor.addField();
return assert.equal(editor.element.find('li:last :input').prop('type'), 'text');
});
it("should give each element a new id", function() {
var firstID, secondID;
editor.addField();
firstID = editor.element.find('li:last :input').attr('id');
editor.addField();
secondID = editor.element.find('li:last :input').attr('id');
return assert.notEqual(firstID, secondID);
});
it("should append a textarea element if 'textarea' type is specified", function() {
editor.addField({
type: 'textarea'
});
return assert.equal(editor.element.find('li:last :input').prop('type'), 'textarea');
});
it("should append a checkbox element if 'checkbox' type is specified", function() {
editor.addField({
type: 'checkbox'
});
return assert.equal(editor.element.find('li:last :input').prop('type'), 'checkbox');
});
it("should append a label element with a for attribute matching the checkbox id", function() {
editor.addField({
type: 'checkbox'
});
return assert.equal(editor.element.find('li:last :input').attr('id'), editor.element.find('li:last label').attr('for'));
});
it("should set placeholder text if a label is provided", function() {
editor.addField({
type: 'textarea',
label: 'Tags…'
});
return assert.equal(editor.element.find('li:last :input').attr('placeholder'), 'Tags…');
});
return it("should return the created list item", function() {
return assert.equal(editor.addField().tagName, 'LI');
});
});
describe("processKeypress", function() {
beforeEach(function() {
sinon.spy(editor, 'hide');
return sinon.spy(editor, 'submit');
});
it("should call Editor#hide() if the escape key is pressed", function() {
editor.processKeypress({
keyCode: 27
});
return assert(editor.hide.calledOnce);
});
it("should call Editor#submit() if the enter key is pressed", function() {
editor.processKeypress({
keyCode: 13
});
return assert(editor.submit.calledOnce);
});
return it("should NOT call Editor#submit() if the shift key is held down", function() {
editor.processKeypress({
keyCode: 13,
shiftKey: true
});
return assert.isFalse(editor.submit.called);
});
});
return describe("onCancelButtonMouseover", function() {
return it("should remove the focus class from submit when cancel is hovered", function() {
editor.element.find('.annotator-save').addClass('annotator-focus');
editor.onCancelButtonMouseover();
return assert.lengthOf(editor.element.find('.annotator-focus'), 0);
});
});
});
/*
//@ sourceMappingURL=editor_spec.map
*/

File diff suppressed because one or more lines are too long

View file

@ -1,39 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Annotator.Notification', function() {
var notification;
notification = null;
beforeEach(function() {
return notification = new Annotator.Notification();
});
afterEach(function() {
return notification.element.remove();
});
it('should be appended to the document.body', function() {
return assert.equal(notification.element[0].parentNode, document.body);
});
describe('.show()', function() {
var message;
message = 'This is a notification message';
beforeEach(function() {
return notification.show(message);
});
it('should have a class named "annotator-notice-show"', function() {
return assert.isTrue(notification.element.hasClass('annotator-notice-show'));
});
return it('should update the notification message', function() {
return assert.equal(notification.element.html(), message);
});
});
return describe('.hide()', function() {
beforeEach(function() {
return notification.hide();
});
return it('should not have a class named "show"', function() {
return assert.isFalse(notification.element.hasClass('show'));
});
});
});
/*
//@ sourceMappingURL=notification_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "notification_spec.js",
"sourceRoot": "../..",
"sources": [
"test/spec/notification_spec.coffee"
],
"names": [],
"mappings": ";AAAA,CAAS,CAA0B,CAAA,KAAnC,CAAmC,eAAnC;CACE,KAAA,MAAA;CAAA,CAAA,CAAe,CAAf,QAAA;CAAA,CAEA,CAAW,MAAA,CAAX;CAC+B,EAAV,CAAA,KAAS,EAA5B,CAAA;CADF,EAAW;CAFX,CAKA,CAAU,MAAV;CACe,KAAb,CAAoB,IAApB,CAAY;CADd,EAAU;CALV,CAQA,CAA8C,MAAA,gCAA9C;CACS,CAA0C,EAAjD,CAAA,CAAM,CAA4B,CAAuB,EAAzD,CAAA,CAAyB;CAD3B,EAA8C;CAR9C,CAWA,CAAoB,KAApB,CAAA;CACE,MAAA,CAAA;CAAA,EAAU,CAAV,GAAA,yBAAA;CAAA,EAEW,CAAX,KAAW,CAAX;CACe,GAAb,GAAA,KAAY,CAAZ;CADF,IAAW;CAFX,CAKA,CAAwD,CAAxD,KAAwD,0CAAxD;CACS,KAAD,CAA4B,CAApB,IAAY,CAA1B,UAAc;CADhB,IAAwD;CAGrD,CAAH,CAA6C,MAAA,EAA7C,6BAAA;CACS,CAAmC,EAA7B,CAAb,CAAM,CAA2B,KAAR,CAAzB;CADF,IAA6C;CAT/C,EAAoB;CAYX,CAAW,CAAA,KAApB,CAAA;CACE,EAAW,CAAX,KAAW,CAAX;CACe,GAAb,QAAY,CAAZ;CADF,IAAW;CAGR,CAAH,CAA2C,MAAA,EAA3C,2BAAA;CACS,KAAD,CAAN,CAAe,IAAY,CAA3B;CADF,IAA2C;CAJ7C,EAAoB;CAxBa"
}

View file

@ -1,178 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Annotator.Plugin.AnnotateItPermissions', function() {
var el, permissions;
el = null;
permissions = null;
beforeEach(function() {
el = $("<div class='annotator-viewer'></div>").appendTo('body')[0];
return permissions = new Annotator.Plugin.AnnotateItPermissions(el);
});
afterEach(function() {
return $(el).remove();
});
it("it should set user for newly created annotations on beforeAnnotationCreated", function() {
var ann;
ann = {};
permissions.setUser({
userId: 'alice',
consumerKey: 'fookey'
});
$(el).trigger('beforeAnnotationCreated', [ann]);
return assert.equal(ann.user, 'alice');
});
it("it should set consumer for newly created annotations on beforeAnnotationCreated", function() {
var ann;
ann = {};
permissions.setUser({
userId: 'alice',
consumerKey: 'fookey'
});
$(el).trigger('beforeAnnotationCreated', [ann]);
return assert.equal(ann.consumer, 'fookey');
});
return describe('authorize', function() {
var annotations;
annotations = null;
beforeEach(function() {
return annotations = [
{}, {
user: 'alice'
}, {
user: 'alice',
consumer: 'annotateit'
}, {
permissions: {}
}, {
permissions: {
'read': ['group:__world__']
}
}, {
permissions: {
'update': ['group:__authenticated__']
}
}, {
consumer: 'annotateit',
permissions: {
'read': ['group:__consumer__']
}
}
];
});
it('should NOT allow any action for an annotation with no owner info and no permissions', function() {
var a;
a = annotations[0];
assert.isFalse(permissions.authorize(null, a));
assert.isFalse(permissions.authorize('foo', a));
permissions.setUser({
userId: 'alice',
consumerKey: 'annotateit'
});
assert.isFalse(permissions.authorize(null, a));
return assert.isFalse(permissions.authorize('foo', a));
});
it('should NOT allow any action if an annotation has only user set (but no consumer)', function() {
var a;
a = annotations[1];
assert.isFalse(permissions.authorize(null, a));
assert.isFalse(permissions.authorize('foo', a));
permissions.setUser({
userId: 'alice',
consumerKey: 'annotateit'
});
assert.isFalse(permissions.authorize(null, a));
return assert.isFalse(permissions.authorize('foo', a));
});
it('should allow any action if the current auth info identifies the owner of the annotation', function() {
var a;
a = annotations[2];
permissions.setUser({
userId: 'alice',
consumerKey: 'annotateit'
});
assert.isTrue(permissions.authorize(null, a));
return assert.isTrue(permissions.authorize('foo', a));
});
it('should NOT allow any action for an annotation with no owner info and empty permissions field', function() {
var a;
a = annotations[3];
assert.isFalse(permissions.authorize(null, a));
assert.isFalse(permissions.authorize('foo', a));
permissions.setUser({
userId: 'alice',
consumerKey: 'annotateit'
});
assert.isFalse(permissions.authorize(null, a));
return assert.isFalse(permissions.authorize('foo', a));
});
it('should allow an action when the action field contains the world group', function() {
var a;
a = annotations[4];
assert.isTrue(permissions.authorize('read', a));
permissions.setUser({
userId: 'alice',
consumerKey: 'annotateit'
});
return assert.isTrue(permissions.authorize('read', a));
});
it('should allow an action when the action field contains the authenticated group and the plugin has auth info', function() {
var a;
a = annotations[5];
assert.isFalse(permissions.authorize('update', a));
permissions.setUser({
userId: 'anyone',
consumerKey: 'anywhere'
});
return assert.isTrue(permissions.authorize('update', a));
});
it('should allow an action when the action field contains the consumer group and the plugin has auth info with a matching consumer', function() {
var a;
a = annotations[6];
assert.isFalse(permissions.authorize('read', a));
permissions.setUser({
userId: 'anyone',
consumerKey: 'anywhere'
});
assert.isFalse(permissions.authorize('read', a));
permissions.setUser({
userId: 'anyone',
consumerKey: 'annotateit'
});
return assert.isTrue(permissions.authorize('read', a));
});
it('should allow an action when the action field contains the consumer group and the plugin has auth info with a matching consumer', function() {
var a;
a = annotations[6];
assert.isFalse(permissions.authorize('read', a));
permissions.setUser({
userId: 'anyone',
consumerKey: 'anywhere'
});
assert.isFalse(permissions.authorize('read', a));
permissions.setUser({
userId: 'anyone',
consumerKey: 'annotateit'
});
return assert.isTrue(permissions.authorize('read', a));
});
return it('should allow an action when the user is an admin of the annotation\'s consumer', function() {
var a;
a = annotations[2];
permissions.setUser({
userId: 'anyone',
consumerKey: 'anywhere',
admin: true
});
assert.isFalse(permissions.authorize('read', a));
permissions.setUser({
userId: 'anyone',
consumerKey: 'annotateit',
admin: true
});
return assert.isTrue(permissions.authorize('read', a));
});
});
});
/*
//@ sourceMappingURL=annotateitpermissions_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "annotateitpermissions_spec.js",
"sourceRoot": "../../..",
"sources": [
"test/spec/plugin/annotateitpermissions_spec.coffee"
],
"names": [],
"mappings": ";AAAA,CAAS,CAA0C,CAAA,KAAnD,CAAmD,+BAAnD;CACE,KAAA,SAAA;CAAA,CAAA,CAAK,CAAL;CAAA,CACA,CAAc,CADd,OACA;CADA,CAGA,CAAW,MAAA,CAAX;CACE,CAAA,CAAK,CAAL,EAAK,EAAA,8BAAA;CACuB,CAAV,CAAA,CAAA,EAAgB,GAAP,EAA3B,UAAkB;CAFpB,EAAW;CAHX,CAOA,CAAU,MAAV;CAAa,CAAA,IAAA,KAAA;CAAb,EAAU;CAPV,CASA,CAAkF,MAAA,oEAAlF;CACE,EAAA,KAAA;CAAA,CAAA,CAAA,CAAA;CAAA,GACA,GAAA,IAAW;CAAS,CAAS,IAAR,CAAD;CAAA,CAA+B,IAAb,EAAlB,GAAkB;CADtC,KACA;CADA,CAEA,CAAyC,CAAzC,GAAA,kBAAA;CACO,CAAgB,CAAP,CAAhB,CAAA,CAAM,CAAN,IAAA;CAJF,EAAkF;CATlF,CAeA,CAAsF,MAAA,wEAAtF;CACE,EAAA,KAAA;CAAA,CAAA,CAAA,CAAA;CAAA,GACA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GAAA;CADhE,OACA;CADA,CAE6C,IAA7C,CAAA,EAAe,EAAW;CAF1B,KAGA,CAAA,IAAW;CAAS,CAAS,IAAR,EAAA;CAAD,CAAgC,MAAb,GAAA,CAAnB;CAAA,CAAqD,EAArD,CAA8C,GAAA;CAHlE,OAGA;CACO,CAAqC,IAAtC,GAAQ,EAAW,EAAzB;CALF,IAAqF;CArFvF,EAAsB;CAtB2B"
}

View file

@ -1,131 +0,0 @@
// Generated by CoffeeScript 1.6.3
var B64, base64Encode, base64UrlEncode, makeToken;
Date.prototype.toISO8601String = DateToISO8601String;
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
base64Encode = function(data) {
var ac, bits, enc, h1, h2, h3, h4, i, o1, o2, o3, r, tmp_arr;
if (typeof btoa !== "undefined" && btoa !== null) {
return btoa(data);
} else {
i = 0;
ac = 0;
enc = "";
tmp_arr = [];
if (!data) {
return data;
}
data += '';
while (i < data.length) {
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);
bits = o1 << 16 | o2 << 8 | o3;
h1 = bits >> 18 & 0x3f;
h2 = bits >> 12 & 0x3f;
h3 = bits >> 6 & 0x3f;
h4 = bits & 0x3f;
tmp_arr[ac++] = B64.charAt(h1) + B64.charAt(h2) + B64.charAt(h3) + B64.charAt(h4);
}
enc = tmp_arr.join('');
r = data.length % 3;
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
}
};
base64UrlEncode = function(data) {
var chop;
data = base64Encode(data);
chop = data.indexOf('=');
if (chop !== -1) {
data = data.slice(0, chop);
}
data = data.replace(/\+/g, '-');
data = data.replace(/\//g, '_');
return data;
};
makeToken = function() {
var rawToken;
rawToken = {
consumerKey: "key",
issuedAt: new Date().toISO8601String(),
ttl: 300,
userId: "testUser"
};
return {
rawToken: rawToken,
encodedToken: 'header.' + base64UrlEncode(JSON.stringify(rawToken)) + '.signature'
};
};
describe('Annotator.Plugin.Auth', function() {
var encodedToken, mock, mockAuth, rawToken;
mock = null;
rawToken = null;
encodedToken = null;
mockAuth = function(options) {
var a, el;
el = $('<div></div>')[0];
a = new Annotator.Plugin.Auth(el, options);
return {
elem: el,
auth: a
};
};
beforeEach(function() {
var _ref;
_ref = makeToken(), rawToken = _ref.rawToken, encodedToken = _ref.encodedToken;
return mock = mockAuth({
token: encodedToken,
autoFetch: false
});
});
it("uses token supplied in options by default", function() {
return assert.equal(mock.auth.token, encodedToken);
});
xit("makes an ajax request to tokenUrl to retrieve token otherwise");
it("sets annotator:headers data on its element with token data", function() {
var data;
data = $(mock.elem).data('annotator:headers');
assert.isNotNull(data);
return assert.equal(data['x-annotator-auth-token'], encodedToken);
});
it("should call callbacks given to #withToken immediately if it has a valid token", function() {
var callback;
callback = sinon.spy();
mock.auth.withToken(callback);
return assert.isTrue(callback.calledWith(rawToken));
});
xit("should call callbacks given to #withToken after retrieving a token");
return describe("#haveValidToken", function() {
it("returns true when the current token is valid", function() {
return assert.isTrue(mock.auth.haveValidToken());
});
it("returns false when the current token is missing a consumerKey", function() {
delete mock.auth._unsafeToken.consumerKey;
return assert.isFalse(mock.auth.haveValidToken());
});
it("returns false when the current token is missing an issuedAt", function() {
delete mock.auth._unsafeToken.issuedAt;
return assert.isFalse(mock.auth.haveValidToken());
});
it("returns false when the current token is missing a ttl", function() {
delete mock.auth._unsafeToken.ttl;
return assert.isFalse(mock.auth.haveValidToken());
});
return it("returns false when the current token expires in the past", function() {
mock.auth._unsafeToken.ttl = 0;
assert.isFalse(mock.auth.haveValidToken());
mock.auth._unsafeToken.ttl = 86400;
mock.auth._unsafeToken.issuedAt = "1970-01-01T00:00";
return assert.isFalse(mock.auth.haveValidToken());
});
});
});
/*
//@ sourceMappingURL=auth_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "auth_spec.js",
"sourceRoot": "../../..",
"sources": [
"test/spec/plugin/auth_spec.coffee"
],
"names": [],
"mappings": ";AAAA,I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KAAmD,qCAAnD;CACS,GAAW,EAAZ,OAAN,CAAc;CADhB,IAAmD;CAAnD,CAGA,CAAoE,CAApE,KAAoE,sDAApE;AACE,CAAA,GAAW,EAAX,KAAA,CAA6B;CACtB,GAAY,EAAb,CAAN,MAAA,CAAe;CAFjB,IAAoE;CAHpE,CAOA,CAAkE,CAAlE,KAAkE,oDAAlE;AACE,CAAA,GAAW,EAAX,EAAA,IAA6B;CACtB,GAAY,EAAb,CAAN,MAAA,CAAe;CAFjB,IAAkE;CAPlE,CAWA,CAA4D,CAA5D,KAA4D,8CAA5D;AACE,CAAA,EAAA,CAAW,EAAX,MAA6B;CACtB,GAAY,EAAb,CAAN,MAAA,CAAe;CAFjB,IAA4D;CAIzD,CAAH,CAA+D,MAAA,EAA/D,+CAAA;CACE,EAAA,CAAI,EAAJ,MAAsB;CAAtB,GACmB,EAAnB,CAAA,OAAe;CADf,EAEA,CAAI,CAFJ,CAEA,MAAsB;CAFtB,EAGkC,CAA9B,EAAJ,EAAA,IAAsB,MAHtB;CAIO,GAAY,EAAb,CAAN,MAAA,CAAe;CALjB,IAA+D;CAhBjE,EAA4B;CAnCI"
}

View file

@ -1,110 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Annotator.Plugin.Document', function() {
var $fix, annotator;
$fix = null;
annotator = null;
beforeEach(function() {
annotator = new Annotator($('<div></div>')[0], {});
return annotator.addPlugin('Document');
});
afterEach(function() {
return $(document).unbind();
});
describe('has an annotator', function() {
return it('should have an annotator', function() {
return assert.ok(annotator);
});
});
describe('has the plugin', function() {
return it('should have Document plugin', function() {
return assert.ok('Document' in annotator.plugins);
});
});
return describe('annotation should have some metadata', function() {
var annotation, head;
head = $("head");
head.append('<link rel="alternate" href="foo.pdf" type="application/pdf"></link>');
head.append('<link rel="alternate" href="foo.doc" type="application/msword"></link>');
head.append('<link rel="bookmark" href="http://example.com/bookmark"></link>');
head.append('<meta name="citation_doi" content="10.1175/JCLI-D-11-00015.1">');
head.append('<meta name="citation_title" content="Foo">');
head.append('<meta name="citation_pdf_url" content="foo.pdf">');
head.append('<meta name="dc.identifier" content="doi:10.1175/JCLI-D-11-00015.1">');
head.append('<meta name="dc.identifier" content="isbn:123456789">');
head.append('<meta name="DC.type" content="Article">');
head.append('<meta property="og:url" content="http://example.com">');
head.append('<meta name="twitter:site" content="@okfn">');
head.append('<link rel="icon" href="http://example.com/images/icon.ico"></link>');
head.append('<meta name="eprints.title" content="Computer Lib / Dream Machines">');
head.append('<meta name="prism.title" content="Literary Machines">');
annotation = null;
beforeEach(function() {
return annotation = annotator.createAnnotation();
});
it('can create annotation', function() {
return assert.ok(annotation);
});
it('should have a document', function() {
return assert.ok(annotation.document);
});
it('should have a title, derived from highwire metadata if possible', function() {
return assert.equal(annotation.document.title, 'Foo');
});
it('should have links with absoulte hrefs and types', function() {
assert.ok(annotation.document.link);
assert.equal(annotation.document.link.length, 7);
assert.match(annotation.document.link[0].href, /^.+runner.html(\?.*)?$/);
assert.equal(annotation.document.link[1].rel, "alternate");
assert.match(annotation.document.link[1].href, /^.+foo\.pdf$/);
assert.equal(annotation.document.link[1].type, "application/pdf");
assert.equal(annotation.document.link[2].rel, "alternate");
assert.match(annotation.document.link[2].href, /^.+foo\.doc$/);
assert.equal(annotation.document.link[2].type, "application/msword");
assert.equal(annotation.document.link[3].rel, "bookmark");
assert.equal(annotation.document.link[3].href, "http://example.com/bookmark");
assert.equal(annotation.document.link[4].href, "doi:10.1175/JCLI-D-11-00015.1");
assert.match(annotation.document.link[5].href, /.+foo\.pdf$/);
assert.equal(annotation.document.link[5].type, "application/pdf");
return assert.equal(annotation.document.link[6].href, "doi:10.1175/JCLI-D-11-00015.1");
});
it('should have highwire metadata', function() {
assert.ok(annotation.document.highwire);
assert.deepEqual(annotation.document.highwire.pdf_url, ['foo.pdf']);
assert.deepEqual(annotation.document.highwire.doi, ['10.1175/JCLI-D-11-00015.1']);
return assert.deepEqual(annotation.document.highwire.title, ['Foo']);
});
it('should have dublincore metadata', function() {
assert.ok(annotation.document.dc);
assert.deepEqual(annotation.document.dc.identifier, ["doi:10.1175/JCLI-D-11-00015.1", "isbn:123456789"]);
return assert.deepEqual(annotation.document.dc.type, ["Article"]);
});
it('should have facebook metadata', function() {
assert.ok(annotation.document.facebook);
return assert.deepEqual(annotation.document.facebook.url, ["http://example.com"]);
});
it('should have eprints metadata', function() {
assert.ok(annotation.document.eprints);
return assert.deepEqual(annotation.document.eprints.title, ['Computer Lib / Dream Machines']);
});
it('should have prism metadata', function() {
assert.ok(annotation.document.prism);
return assert.deepEqual(annotation.document.prism.title, ['Literary Machines']);
});
it('should have twitter card metadata', function() {
assert.ok(annotation.document.twitter);
return assert.deepEqual(annotation.document.twitter.site, ['@okfn']);
});
it('should have unique uris', function() {
var uris;
uris = annotator.plugins.Document.uris();
return assert.equal(uris.length, 5);
});
return it('should have a favicon', function() {
return assert.equal(annotation.document.favicon, 'http://example.com/images/icon.ico');
});
});
});
/*
//@ sourceMappingURL=document_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "document_spec.js",
"sourceRoot": "../../..",
"sources": [
"test/spec/plugin/document_spec.coffee"
],
"names": [],
"mappings": ";AAAA,CAAS,CAA6B,CAAA,KAAtC,CAAsC,kBAAtC;CACE,KAAA,SAAA;CAAA,CAAA,CAAO,CAAP;CAAA,CACA,CAAY,CADZ,KACA;CADA,CAGA,CAAW,MAAA,CAAX;CACE,CAA+C,CAA/B,CAAhB,KAAA,IAA0B;CAChB,QAAD,CAAT,CAAA;CAFF,EAAW;CAHX,CAOA,CAAW,MAAX;CAAc,KAAA,EAAA,GAAA;CAAd,EAAW;CAPX,CASA,CAA6B,KAA7B,CAA6B,SAA7B;CACK,CAAH,CAA+B,MAAA,EAA/B,eAAA;CACS,CAAP,IAAM,GAAN,IAAA;CADF,IAA+B;CADjC,EAA6B;CAT7B,CAaA,CAA2B,KAA3B,CAA2B,OAA3B;CACK,CAAH,CAAkC,MAAA,EAAlC,kBAAA;CACS,CAAP,EAAw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FtD,IAAmC;CA9DnC,CAkEA,CAAiC,CAAjC,KAAiC,mBAAjC;CACE,CAAA,GAAA,CAAA,EAA6B,EAAT;CACb,CAA2C,GAAR,CAApC,EAA8B,CAApC,CAA2B,GAA3B,MAAkD;CAFpD,IAAiC;CAlEjC,CAsEC,CAAwC,CAAxC,KAAwC,0BAAxC;CACC,CAAA,IAAA,CAAA,CAA6B,EAAT;CACb,CAA4C,EAAnD,EAAM,CAAsC,CAAR,CAApC,CAA2B,GAA3B;CAFD,IAAwC;CAtEzC,CA0EA,CAA8B,CAA9B,KAA8B,gBAA9B;CACE,GAAA,MAAA;CAAA,EAAO,CAAP,EAAA,CAAwB,CAAS,CAAjB;CACT,CAAmB,EAAT,CAAjB,CAAM,OAAN;CAFF,IAA8B;CAI3B,CAAH,CAA4B,MAAA,EAA5B,YAAA;CACS,CAEL,GAFF,CAAM,CAAN,CACqB,EAAT,GADZ,uBAAA;CADF,IAA4B;CAhF9B,EAAiD;CAlBb"
}

View file

@ -1,468 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe("Filter", function() {
var element, plugin;
plugin = null;
element = null;
beforeEach(function() {
var annotator;
element = $('<div />');
annotator = {
subscribe: sinon.spy(),
element: {
find: sinon.stub().returns($())
}
};
plugin = new Annotator.Plugin.Filter(element[0]);
return plugin.annotator = annotator;
});
afterEach(function() {
return plugin.element.remove();
});
describe("events", function() {
var filterElement;
filterElement = null;
beforeEach(function() {
filterElement = $(plugin.html.filter);
return plugin.element.append(filterElement);
});
afterEach(function() {
return filterElement.remove();
});
it("should call Filter#_onFilterFocus when a filter input is focussed", function() {
sinon.spy(plugin, '_onFilterFocus');
filterElement.find('input').focus();
return assert(plugin._onFilterFocus.calledOnce);
});
it("should call Filter#_onFilterBlur when a filter input is blurred", function() {
sinon.spy(plugin, '_onFilterBlur');
filterElement.find('input').blur();
return assert(plugin._onFilterBlur.calledOnce);
});
return it("should call Filter#_onFilterKeyup when a key is pressed in an input", function() {
sinon.spy(plugin, '_onFilterKeyup');
filterElement.find('input').keyup();
return assert(plugin._onFilterKeyup.calledOnce);
});
});
describe("constructor", function() {
it("should have an empty filters array", function() {
return assert.deepEqual(plugin.filters, []);
});
it("should have an filter element wrapped in jQuery", function() {
assert.isTrue(plugin.filter instanceof jQuery);
return assert.lengthOf(plugin.filter, 1);
});
return it("should append the toolbar to the @options.appendTo selector", function() {
var parent;
assert.isTrue(plugin.element instanceof jQuery);
assert.lengthOf(plugin.element, 1);
parent = $(plugin.options.appendTo);
return assert.equal(plugin.element.parent()[0], parent[0]);
});
});
describe("pluginInit", function() {
beforeEach(function() {
sinon.stub(plugin, 'updateHighlights');
sinon.stub(plugin, '_setupListeners').returns(plugin);
sinon.stub(plugin, '_insertSpacer').returns(plugin);
return sinon.stub(plugin, 'addFilter');
});
it("should call Filter#updateHighlights()", function() {
plugin.pluginInit();
return assert(plugin.updateHighlights.calledOnce);
});
it("should call Filter#_setupListeners()", function() {
plugin.pluginInit();
return assert(plugin._setupListeners.calledOnce);
});
it("should call Filter#_insertSpacer()", function() {
plugin.pluginInit();
return assert(plugin._insertSpacer.calledOnce);
});
return it("should load any filters in the Filter#options.filters array", function() {
var filter, filters, _i, _len, _results;
filters = [
{
label: 'filter1'
}, {
label: 'filter2'
}, {
label: 'filter3'
}
];
plugin.options.filters = filters;
plugin.pluginInit();
_results = [];
for (_i = 0, _len = filters.length; _i < _len; _i++) {
filter = filters[_i];
_results.push(assert.isTrue(plugin.addFilter.calledWith(filter)));
}
return _results;
});
});
describe("_setupListeners", function() {
return it("should subscribe to all relevant events on the annotator", function() {
var event, events, _i, _len, _results;
plugin._setupListeners();
events = ['annotationsLoaded', 'annotationCreated', 'annotationUpdated', 'annotationDeleted'];
_results = [];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
_results.push(assert.isTrue(plugin.annotator.subscribe.calledWith(event, plugin.updateHighlights)));
}
return _results;
});
});
describe("addFilter", function() {
var filter;
filter = null;
beforeEach(function() {
filter = {
label: 'Tag',
property: 'tags'
};
return plugin.addFilter(filter);
});
it("should add a filter object to Filter#plugins", function() {
return assert.ok(plugin.filters[0]);
});
it("should append the html to Filter#toolbar", function() {
filter = plugin.filters[0];
return assert.equal(filter.element[0], plugin.element.find('#annotator-filter-tags').parent()[0]);
});
it("should store the filter in the elements data store under 'filter'", function() {
filter = plugin.filters[0];
return assert.equal(filter.element.data('filter'), filter);
});
return it("should not add a filter for a property that has already been loaded", function() {
plugin.addFilter({
label: 'Tag',
property: 'tags'
});
return assert.lengthOf(plugin.filters, 1);
});
});
describe("updateFilter", function() {
var annotations, filter;
filter = null;
annotations = null;
beforeEach(function() {
filter = {
id: 'text',
label: 'Annotation',
property: 'text',
element: $('<span><input value="ca" /></span>'),
annotations: [],
isFiltered: function(value, text) {
return text.indexOf('ca') !== -1;
}
};
annotations = [
{
text: 'cat'
}, {
text: 'dog'
}, {
text: 'car'
}
];
plugin.filters = {
'text': filter
};
plugin.highlights = {
map: function() {
return annotations;
}
};
sinon.stub(plugin, 'updateHighlights');
sinon.stub(plugin, 'resetHighlights');
return sinon.stub(plugin, 'filterHighlights');
});
it("should call Filter#updateHighlights()", function() {
plugin.updateFilter(filter);
return assert(plugin.updateHighlights.calledOnce);
});
it("should call Filter#resetHighlights()", function() {
plugin.updateFilter(filter);
return assert(plugin.resetHighlights.calledOnce);
});
it("should filter the cat and car annotations", function() {
plugin.updateFilter(filter);
return assert.deepEqual(filter.annotations, [annotations[0], annotations[2]]);
});
it("should call Filter#filterHighlights()", function() {
plugin.updateFilter(filter);
return assert(plugin.filterHighlights.calledOnce);
});
return it("should NOT call Filter#filterHighlights() if there is no input", function() {
filter.element.find('input').val('');
plugin.updateFilter(filter);
return assert.isFalse(plugin.filterHighlights.called);
});
});
describe("updateHighlights", function() {
beforeEach(function() {
plugin.highlights = null;
return plugin.updateHighlights();
});
it("should fetch the visible highlights from the Annotator#element", function() {
return assert.isTrue(plugin.annotator.element.find.calledWith('.annotator-hl:visible'));
});
return it("should set the Filter#highlights property", function() {
return assert.ok(plugin.highlights);
});
});
describe("filterHighlights", function() {
var div;
div = null;
beforeEach(function() {
var match;
plugin.highlights = $('<span /><span /><span /><span /><span />');
match = {
highlights: [plugin.highlights[1]]
};
plugin.filters = [
{
annotations: [
{
highlights: [plugin.highlights[0]]
}, match
]
}, {
annotations: [
{
highlights: [plugin.highlights[4]]
}, match, {
highlights: [plugin.highlights[2]]
}
]
}
];
return div = $('<div>').append(plugin.highlights);
});
it("should hide all highlights not whitelisted by _every_ filter", function() {
plugin.filterHighlights();
return assert.lengthOf(div.find('.' + plugin.classes.hl.hide), 4);
});
it("should hide all highlights not whitelisted by _every_ filter if every filter is active", function() {
plugin.filters[1].annotations = [];
plugin.filterHighlights();
return assert.lengthOf(div.find('.' + plugin.classes.hl.hide), 3);
});
return it("should hide all highlights not whitelisted if only one filter", function() {
plugin.filters = plugin.filters.slice(0, 1);
plugin.filterHighlights();
return assert.lengthOf(div.find('.' + plugin.classes.hl.hide), 3);
});
});
describe("resetHighlights", function() {
return it("should remove the filter-hide class from all highlights", function() {
plugin.highlights = $('<span /><span /><span />').addClass(plugin.classes.hl.hide);
plugin.resetHighlights();
return assert.lengthOf(plugin.highlights.filter('.' + plugin.classes.hl.hide), 0);
});
});
return describe("group: filter input actions", function() {
var filterElement;
filterElement = null;
beforeEach(function() {
filterElement = $(plugin.html.filter);
return plugin.element.append(filterElement);
});
describe("_onFilterFocus", function() {
return it("should add an active class to the element", function() {
plugin._onFilterFocus({
target: filterElement.find('input')[0]
});
return assert.isTrue(filterElement.hasClass(plugin.classes.active));
});
});
describe("_onFilterBlur", function() {
it("should remove the active class from the element", function() {
filterElement.addClass(plugin.classes.active);
plugin._onFilterBlur({
target: filterElement.find('input')[0]
});
return assert.isFalse(filterElement.hasClass(plugin.classes.active));
});
return it("should NOT remove the active class from the element if it has a value", function() {
filterElement.addClass(plugin.classes.active);
plugin._onFilterBlur({
target: filterElement.find('input').val('filtered')[0]
});
return assert.isTrue(filterElement.hasClass(plugin.classes.active));
});
});
describe("_onFilterKeyup", function() {
beforeEach(function() {
plugin.filters = [
{
label: 'My Filter'
}
];
return sinon.stub(plugin, 'updateFilter');
});
it("should call Filter#updateFilter() with the relevant filter", function() {
filterElement.data('filter', plugin.filters[0]);
plugin._onFilterKeyup({
target: filterElement.find('input')[0]
});
return assert.isTrue(plugin.updateFilter.calledWith(plugin.filters[0]));
});
return it("should NOT call Filter#updateFilter() if no filter is found", function() {
plugin._onFilterKeyup({
target: filterElement.find('input')[0]
});
return assert.isFalse(plugin.updateFilter.called);
});
});
describe("navigation", function() {
var annotation1, annotation2, annotation3, element1, element2, element3;
element1 = null;
element2 = null;
element3 = null;
annotation1 = null;
annotation2 = null;
annotation3 = null;
beforeEach(function() {
element1 = $('<span />');
annotation1 = {
text: 'annotation1',
highlights: [element1[0]]
};
element1.data('annotation', annotation1);
element2 = $('<span />');
annotation2 = {
text: 'annotation2',
highlights: [element2[0]]
};
element2.data('annotation', annotation2);
element3 = $('<span />');
annotation3 = {
text: 'annotation3',
highlights: [element3[0]]
};
element3.data('annotation', annotation3);
plugin.highlights = $([element1[0], element2[0], element3[0]]);
return sinon.spy(plugin, '_scrollToHighlight');
});
describe("_onNextClick", function() {
it("should advance to the next element", function() {
element2.addClass(plugin.classes.hl.active);
plugin._onNextClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element3[0]]));
});
it("should loop back to the start once it gets to the end", function() {
element3.addClass(plugin.classes.hl.active);
plugin._onNextClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element1[0]]));
});
it("should use the first element if there is no current element", function() {
plugin._onNextClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element1[0]]));
});
it("should only navigate through non hidden elements", function() {
element1.addClass(plugin.classes.hl.active);
element2.addClass(plugin.classes.hl.hide);
plugin._onNextClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element3[0]]));
});
return it("should do nothing if there are no annotations", function() {
plugin.highlights = $();
plugin._onNextClick();
return assert.isFalse(plugin._scrollToHighlight.called);
});
});
return describe("_onPreviousClick", function() {
it("should advance to the previous element", function() {
element3.addClass(plugin.classes.hl.active);
plugin._onPreviousClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element2[0]]));
});
it("should loop to the end once it gets to the beginning", function() {
element1.addClass(plugin.classes.hl.active);
plugin._onPreviousClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element3[0]]));
});
it("should use the last element if there is no current element", function() {
plugin._onPreviousClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element3[0]]));
});
it("should only navigate through non hidden elements", function() {
element3.addClass(plugin.classes.hl.active);
element2.addClass(plugin.classes.hl.hide);
plugin._onPreviousClick();
return assert.isTrue(plugin._scrollToHighlight.calledWith([element1[0]]));
});
return it("should do nothing if there are no annotations", function() {
plugin.highlights = $();
plugin._onPreviousClick();
return assert.isFalse(plugin._scrollToHighlight.called);
});
});
});
describe("_scrollToHighlight", function() {
var mockjQuery;
mockjQuery = null;
beforeEach(function() {
plugin.highlights = $();
mockjQuery = {
addClass: sinon.spy(),
animate: sinon.spy(),
offset: sinon.stub().returns({
top: 0
})
};
sinon.spy(plugin.highlights, 'removeClass');
return sinon.stub(jQuery.prototype, 'init').returns(mockjQuery);
});
afterEach(function() {
return jQuery.prototype.init.restore();
});
it("should remove active class from currently active element", function() {
plugin._scrollToHighlight({});
return assert.isTrue(plugin.highlights.removeClass.calledWith(plugin.classes.hl.active));
});
it("should add active class to provided elements", function() {
plugin._scrollToHighlight({});
return assert.isTrue(mockjQuery.addClass.calledWith(plugin.classes.hl.active));
});
return it("should animate the scrollbar to the highlight offset", function() {
plugin._scrollToHighlight({});
assert(mockjQuery.offset.calledOnce);
return assert(mockjQuery.animate.calledOnce);
});
});
return describe("_onClearClick", function() {
var mockjQuery;
mockjQuery = null;
beforeEach(function() {
mockjQuery = {};
mockjQuery.val = sinon.stub().returns(mockjQuery);
mockjQuery.prev = sinon.stub().returns(mockjQuery);
mockjQuery.keyup = sinon.stub().returns(mockjQuery);
mockjQuery.blur = sinon.stub().returns(mockjQuery);
sinon.stub(jQuery.prototype, 'init').returns(mockjQuery);
return plugin._onClearClick({
target: {}
});
});
afterEach(function() {
return jQuery.prototype.init.restore();
});
it("should clear the input", function() {
return assert.isTrue(mockjQuery.val.calledWith(''));
});
it("should trigger the blur event", function() {
return assert(mockjQuery.blur.calledOnce);
});
return it("should trigger the keyup event", function() {
return assert(mockjQuery.keyup.calledOnce);
});
});
});
});
/*
//@ sourceMappingURL=filter_spec.map
*/

File diff suppressed because one or more lines are too long

View file

@ -1,150 +0,0 @@
// Generated by CoffeeScript 1.6.3
var MockPlugin,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
MockPlugin = (function() {
function MockPlugin() {}
MockPlugin.prototype.pluginInit = function() {};
return MockPlugin;
})();
describe('Annotator::setupPlugins', function() {
var $fix, annotator;
annotator = null;
$fix = null;
beforeEach(function() {
var p, _i, _len, _ref;
_ref = ['AnnotateItPermissions', 'Auth', 'Markdown', 'Store', 'Tags', 'Unsupported'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
p = _ref[_i];
Annotator.Plugin[p] = MockPlugin;
}
addFixture('kitchensink');
return $fix = $(fix());
});
afterEach(function() {
return clearFixtures();
});
it('should added to the Annotator prototype', function() {
return assert.equal(typeof Annotator.prototype.setupPlugins, 'function');
});
it('should be callable via jQuery.fn.Annotator', function() {
sinon.spy(Annotator.prototype, 'setupPlugins');
$fix.annotator().annotator('setupPlugins', {}, {
Filter: {
appendTo: fix()
}
});
return assert(Annotator.prototype.setupPlugins.calledOnce);
});
describe('called with no parameters', function() {
var _Showdown;
_Showdown = null;
beforeEach(function() {
_Showdown = window.Showdown;
annotator = new Annotator(fix());
return annotator.setupPlugins({}, {
Filter: {
appendTo: fix()
}
});
});
afterEach(function() {
return window.Showdown = _Showdown;
});
describe('it includes the Unsupported plugin', function() {
return it('should add the Unsupported plugin by default', function() {
return assert.isDefined(annotator.plugins.Unsupported);
});
});
describe('it includes the Tags plugin', function() {
return it('should add the Tags plugin by default', function() {
return assert.isDefined(annotator.plugins.Tags);
});
});
describe('it includes the Filter plugin', function() {
var filterPlugin;
filterPlugin = null;
beforeEach(function() {
return filterPlugin = annotator.plugins.Filter;
});
it('should add the Filter plugin by default', function() {
return assert.isDefined(filterPlugin);
});
return it('should have filters for annotations, tags and users', function() {
var expectedFilters, f, filter, _i, _len, _results;
expectedFilters = ['text', 'user', 'tags'];
_results = [];
for (_i = 0, _len = expectedFilters.length; _i < _len; _i++) {
filter = expectedFilters[_i];
_results.push(assert.isTrue(__indexOf.call((function() {
var _j, _len1, _ref, _results1;
_ref = filterPlugin.filters;
_results1 = [];
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
f = _ref[_j];
_results1.push(f.property);
}
return _results1;
})(), filter) >= 0));
}
return _results;
});
});
return describe('and with Showdown loaded in the page', function() {
return it('should add the Markdown plugin', function() {
return assert.isDefined(annotator.plugins.Markdown);
});
});
});
describe('called with AnnotateIt config', function() {
beforeEach(function() {
sinon.stub(Annotator.Plugin.Store.prototype, 'pluginInit');
annotator = new Annotator(fix());
return annotator.setupPlugins();
});
afterEach(function() {
return Annotator.Plugin.Store.prototype.pluginInit.restore();
});
it('should add the Store plugin', function() {
return assert.isDefined(annotator.plugins.Store);
});
it('should add the AnnotateItPermissions plugin', function() {
return assert.isDefined(annotator.plugins.AnnotateItPermissions);
});
return it('should add the Auth plugin', function() {
return assert.isDefined(annotator.plugins.Auth);
});
});
return describe('called with plugin options', function() {
beforeEach(function() {
return annotator = new Annotator(fix());
});
it('should override default plugin options', function() {
annotator.setupPlugins(null, {
AnnotateItPermissions: false,
Filter: {
filters: null,
addAnnotationFilter: false,
appendTo: fix()
}
});
return assert.lengthOf(annotator.plugins.Filter.filters, 0);
});
return it('should NOT load a plugin if its key is set to null OR false', function() {
annotator.setupPlugins(null, {
Filter: false,
Tags: null
});
assert.isUndefined(annotator.plugins.Tags);
return assert.isUndefined(annotator.plugins.Filter);
});
});
});
/*
//@ sourceMappingURL=kitchensink_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "kitchensink_spec.js",
"sourceRoot": "../../..",
"sources": [
"test/spec/plugin/kitchensink_spec.coffee"
],
"names": [],
"mappings": ";AAAA,IAAA,MAAA;GAAA,kJAAA;;AAAM,CAAN;CACe,CAAA,CAAA,iBAAA;;CAAb,EACY,MAAA,CAAZ;;CADA;;CADF;;AAIA,CAJA,CAIoC,CAAA,KAApC,CAAoC,gBAApC;CACE,KAAA,SAAA;CAAA,CAAA,CAAY,CAAZ,KAAA;CAAA,CACA,CAAO,CAAP;CADA,CAGA,CAAW,MAAA,CAAX;CACE,OAAA,SAAA;CAAA;CAAA,QAAA,kCAAA;oBAAA;CACE,EAAsB,GAAtB,GAAS,CAAT;CADF,IAAA;CAAA,GAGA,MAAA,GAAA;CACO,EAAA,CAAP,OAAA;CALF,EAAW;CAHX,CAUA,CAAU,MAAV;CAAa,UAAA,EAAA;CAAb,EAAU;CAVV,CAYA,CAA8C,MAAA,gCAA9C;AACe,CAAN,CAAsC,GAA7C,CAAM,GAAuB,CAA7B,CAAA,CAAA;CADF,EAA8C;CAZ9C,CAeA,CAAiD,MAAA,mCAAjD;CACE,CAA+B,CAA/B,CAAA,CAAK,IAAc,KAAnB;CAAA,CAE2C,EAA3C,KAAA,KAAA;CAA+C,CAAS,IAAR;CAAQ,CAAW,CAAA,KAAV;QAAV;CAF/C,KAEA;CACO,KAAP,GAAgB,CAAhB,CAAA,CAA8B;CAJhC,EAAiD;CAfjD,CAqBA,CAAsC,KAAtC,CAAsC,kBAAtC;CACE,OAAA,CAAA;CAAA,EAAY,CAAZ,KAAA;CAAA,EAEW,CAAX,KAAW,CAAX;CACE,EAAY,GAAZ,EAAA,CAAA;CAAA,EACgB,CAAA,EAAhB,GAAA;CACU,CAAV,OAAS,GAAT,CAAA;CAA2B,CAAS,IAAR,EAAA;CAAQ,CAAW,CAAA,KAA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AA;CACU,QAAD,GAAT,CAAA;CALF,IAAW;CAAX,EAOU,CAAV,KAAA;CACY,IAAY,CAAN,CAAhB,EAAS,CAAkC,GAA3C;CADF,IAAU;CAPV,CAUA,CAAkC,CAAlC,KAAkC,oBAAlC;CACS,IAAP,CAAM,CAA4B,EAAlC,IAAA;CADF,IAAkC;CAVlC,CAaA,CAAkD,CAAlD,KAAkD,oCAAlD;CACS,KAAD,CAA4B,EAAlC,IAAA,QAAA;CADF,IAAkD;CAG/C,CAAH,CAAiC,MAAA,EAAjC,iBAAA;CACS,GAAP,EAAM,CAA4B,EAAlC,IAAA;CADF,IAAiC;CAjBnC,EAA0C;CAoBjC,CAA8B,CAAA,KAAvC,CAAA,mBAAA;CACE,EAAW,CAAX,KAAW,CAAX;CAAwC,EAAV,CAAA,KAAhB,IAAA;CAAd,IAAW;CAAX,CAEA,CAA6C,CAA7C,KAA6C,+BAA7C;CACE,CACE,EADF,EAAA,GAAS,GAAT;CACE,CAAuB,GAAvB,GAAA,aAAA;CAAA,CAEE,IADF,EAAA;CACE,CAAS,EAAT,GAAA,GAAA;CAAA,CACqB,GADrB,KACA,SAAA;CADA,CAEU,CAAA,KAAV,EAAA;UAJF;CADF,OAAA;CAOO,CAA2C,IAA5C,CAA2B,CAAjC,CAAyB,IAAzB;CARF,IAA6C;CAU1C,CAAH,CAAkE,MAAA,EAAlE,kDAAA;CACE,CAA6B,EAA7B,EAAA,GAAS,GAAT;CAA6B,CAAS,GAAT,CAAC,EAAA;CAAD,CAAsB,EAAN,IAAA;CAA7C,OAAA;CAAA,GACA,EAAA,CAAoC,EAAR,EAA5B;CACO,KAAD,CAA8B,EAAR,EAA5B,EAAA;CAHF,IAAkE;CAbpE,EAAuC;CA7EL"
}

View file

@ -1,72 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Annotator.Plugin.Markdown', function() {
var input, output, plugin;
input = 'Is **this** [Markdown](http://daringfireball.com)?';
output = '<p>Is <strong>this</strong> <a href="http://daringfireball.com">Markdown</a>?</p>';
plugin = null;
beforeEach(function() {
return plugin = new Annotator.Plugin.Markdown($('<div />')[0]);
});
describe("events", function() {
return it("should call Markdown#updateTextField() when annotationViewerTextField event is fired", function() {
var annotation, field;
field = $('<div />')[0];
annotation = {
text: 'test'
};
sinon.spy(plugin, 'updateTextField');
plugin.publish('annotationViewerTextField', [field, annotation]);
return assert.isTrue(plugin.updateTextField.calledWith(field, annotation));
});
});
describe("constructor", function() {
it("should create a new instance of Showdown", function() {
return assert.ok(plugin.converter);
});
return it("should log an error if Showdown is not loaded", function() {
var converter;
sinon.stub(console, 'error');
converter = Showdown.converter;
Showdown.converter = null;
plugin = new Annotator.Plugin.Markdown($('<div />')[0]);
assert(console.error.calledOnce);
Showdown.converter = converter;
return console.error.restore();
});
});
describe("updateTextField", function() {
var annotation, field;
field = null;
annotation = null;
beforeEach(function() {
field = $('<div />')[0];
annotation = {
text: input
};
sinon.stub(plugin, 'convert').returns(output);
sinon.stub(Annotator.Util, 'escape').returns(input);
return plugin.updateTextField(field, annotation);
});
afterEach(function() {
return Annotator.Util.escape.restore();
});
it('should process the annotation text as Markdown', function() {
return assert.isTrue(plugin.convert.calledWith(input));
});
it('should update the content in the field', function() {
return assert.equal($(field).html(), output);
});
return it("should escape any existing HTML to prevent XSS", function() {
return assert.isTrue(Annotator.Util.escape.calledWith(input));
});
});
return describe("convert", function() {
return it("should convert the provided text into markdown", function() {
return assert.equal(plugin.convert(input), output);
});
});
});
/*
//@ sourceMappingURL=markdown_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "markdown_spec.js",
"sourceRoot": "../../..",
"sources": [
"test/spec/plugin/markdown_spec.coffee"
],
"names": [],
"mappings": ";AAAA,CAAS,CAA6B,CAAA,KAAtC,CAAsC,kBAAtC;CACE,KAAA,eAAA;CAAA,CAAA,CAAS,EAAT,+CAAA;CAAA,CACA,CAAS,GAAT,6EADA;CAAA,CAEA,CAAS,CAFT,EAEA;CAFA,CAKA,CAAW,MAAA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HX,EAWU,CAAV,KAAA;CACY,GAAI,EAAO,CAArB,EAAS,IAAT;CADF,IAAU;CAXV,CAcA,CAAqD,CAArD,KAAqD,uCAArD;CACS,IAAO,CAAR,CAAsB,GAAd,GAAd;CADF,IAAqD;CAdrD,CAiBA,CAA6C,CAA7C,KAA6C,+BAA7C;CACS,CAAuB,EAAjB,CAAb,CAAM,OAAN;CADF,IAA6C;CAG1C,CAAH,CAAqD,MAAA,EAArD,qCAAA;CACS,GAAqB,CAAd,CAAR,GAAiB,CAAT,GAAd;CADF,IAAqD;CArBvD,EAA4B;CAwBnB,CAAW,CAAA,KAApB,CAAA;CACK,CAAH,CAAqD,MAAA,EAArD,qCAAA;CACS,CAA6B,GAApC,CAAM,CAAO,MAAb;CADF,IAAqD;CADvD,EAAoB;CA1DgB"
}

View file

@ -1,456 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
describe('Annotator.Plugin.Permissions', function() {
var el, permissions;
el = null;
permissions = null;
beforeEach(function() {
el = $("<div class='annotator-viewer'></div>").appendTo('body')[0];
return permissions = new Annotator.Plugin.Permissions(el);
});
afterEach(function() {
return $(el).remove();
});
it("it should add the current user object to newly created annotations on beforeAnnotationCreated", function() {
var ann;
ann = {};
$(el).trigger('beforeAnnotationCreated', [ann]);
assert.isUndefined(ann.user);
ann = {};
permissions.setUser('alice');
$(el).trigger('beforeAnnotationCreated', [ann]);
assert.equal(ann.user, 'alice');
ann = {};
permissions.setUser({
id: 'alice'
});
permissions.options.userId = function(user) {
return user.id;
};
$(el).trigger('beforeAnnotationCreated', [ann]);
return assert.deepEqual(ann.user, {
id: 'alice'
});
});
it("it should add permissions to newly created annotations on beforeAnnotationCreated", function() {
var ann;
ann = {};
$(el).trigger('beforeAnnotationCreated', [ann]);
assert.ok(ann.permissions);
ann = {};
permissions.options.permissions = {};
$(el).trigger('beforeAnnotationCreated', [ann]);
return assert.deepEqual(ann.permissions, {});
});
describe('pluginInit', function() {
beforeEach(function() {
return permissions.annotator = {
viewer: {
addField: sinon.spy()
},
editor: {
addField: sinon.spy()
},
plugins: {}
};
});
it("should register a field with the Viewer", function() {
permissions.pluginInit();
return assert(permissions.annotator.viewer.addField.calledOnce);
});
it("should register an two checkbox fields with the Editor", function() {
permissions.pluginInit();
return assert.equal(permissions.annotator.editor.addField.callCount, 2);
});
it("should register an 'anyone can view' field with the Editor if showEditPermissionsCheckbox is true", function() {
permissions.options.showViewPermissionsCheckbox = true;
permissions.options.showEditPermissionsCheckbox = false;
permissions.pluginInit();
return assert.equal(permissions.annotator.editor.addField.callCount, 1);
});
it("should register an 'anyone can edit' field with the Editor if showViewPermissionsCheckbox is true", function() {
permissions.options.showViewPermissionsCheckbox = false;
permissions.options.showEditPermissionsCheckbox = true;
permissions.pluginInit();
return assert.equal(permissions.annotator.editor.addField.callCount, 1);
});
return it("should register a filter if the Filter plugin is loaded", function() {
permissions.annotator.plugins.Filter = {
addFilter: sinon.spy()
};
permissions.pluginInit();
return assert(permissions.annotator.plugins.Filter.addFilter.calledOnce);
});
});
describe('authorize', function() {
var annotations;
annotations = null;
describe('Basic usage', function() {
beforeEach(function() {
return annotations = [
{}, {
user: 'alice'
}, {
permissions: {}
}, {
permissions: {
'update': []
}
}
];
});
it('should allow any action for an annotation with no authorisation info', function() {
var a;
a = annotations[0];
assert.isTrue(permissions.authorize(null, a));
assert.isTrue(permissions.authorize('foo', a));
permissions.setUser('alice');
assert.isTrue(permissions.authorize(null, a));
return assert.isTrue(permissions.authorize('foo', a));
});
it('should NOT allow any action if annotation.user and no @user is set', function() {
var a;
a = annotations[1];
assert.isFalse(permissions.authorize(null, a));
return assert.isFalse(permissions.authorize('foo', a));
});
it('should allow any action if @options.userId(@user) == annotation.user', function() {
var a;
a = annotations[1];
permissions.setUser('alice');
assert.isTrue(permissions.authorize(null, a));
return assert.isTrue(permissions.authorize('foo', a));
});
it('should NOT allow any action if @options.userId(@user) != annotation.user', function() {
var a;
a = annotations[1];
permissions.setUser('bob');
assert.isFalse(permissions.authorize(null, a));
return assert.isFalse(permissions.authorize('foo', a));
});
it('should allow any action if annotation.permissions == {}', function() {
var a;
a = annotations[2];
assert.isTrue(permissions.authorize(null, a));
assert.isTrue(permissions.authorize('foo', a));
permissions.setUser('alice');
assert.isTrue(permissions.authorize(null, a));
return assert.isTrue(permissions.authorize('foo', a));
});
return it('should allow an action if annotation.permissions[action] == []', function() {
var a;
a = annotations[3];
assert.isTrue(permissions.authorize('update', a));
permissions.setUser('bob');
return assert.isTrue(permissions.authorize('update', a));
});
});
return describe('Custom options.userAuthorize() callback', function() {
beforeEach(function() {
permissions.setUser(null);
permissions.options.userAuthorize = function(action, annotation, user) {
var token, tokenTest, tokens, userGroups, _i, _len;
userGroups = function(user) {
return (user != null ? user.groups : void 0) || ['public'];
};
tokenTest = function(token, user) {
var groups, key, value, values, _ref;
if (/^(?:group|user):/.test(token)) {
_ref = token.split(':'), key = _ref[0], values = 2 <= _ref.length ? __slice.call(_ref, 1) : [];
value = values.join(':');
if (key === 'group') {
groups = userGroups(user);
return __indexOf.call(groups, value) >= 0;
} else if (user && key === 'user') {
return value === user.id;
}
}
};
if (annotation.permissions) {
tokens = annotation.permissions[action] || [];
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
if (tokenTest(token, user)) {
return true;
}
}
}
return false;
};
return annotations = [
{
permissions: {
'update': ['group:public']
}
}, {
permissions: {
'update': ['user:alice']
}
}, {
permissions: {
'update': ['user:alice', 'user:bob']
}
}, {
permissions: {
'update': ['user:alice', 'user:bob', 'group:admin']
}
}
];
});
afterEach(function() {
return delete permissions.options.userAuthorize;
});
it('should (by default) allow an action if annotation.permissions[action] includes "group:public"', function() {
var a;
a = annotations[0];
assert.isTrue(permissions.authorize('update', a));
permissions.setUser({
id: 'bob'
});
return assert.isTrue(permissions.authorize('update', a));
});
it('should (by default) allow an action if annotation.permissions[action] includes "user:@user"', function() {
var a;
a = annotations[1];
assert.isFalse(permissions.authorize('update', a));
permissions.setUser({
id: 'bob'
});
assert.isFalse(permissions.authorize('update', a));
permissions.setUser({
id: 'alice'
});
assert.isTrue(permissions.authorize('update', a));
a = annotations[2];
permissions.setUser(null);
assert.isFalse(permissions.authorize('update', a));
permissions.setUser({
id: 'bob'
});
assert.isTrue(permissions.authorize('update', a));
permissions.setUser({
id: 'alice'
});
return assert.isTrue(permissions.authorize('update', a));
});
it('should allow an action if annotation.permissions[action] includes "user:@options.userId(@user)"', function() {
var a;
a = annotations[1];
permissions.options.userId = function(user) {
return (user != null ? user.id : void 0) || null;
};
assert.isFalse(permissions.authorize('update', a));
permissions.setUser({
id: 'alice'
});
return assert.isTrue(permissions.authorize('update', a));
});
return it('should allow an action if annotation.permissions[action] includes "user:@options.userId(@user)"', function() {
var a;
a = annotations[3];
assert.isFalse(permissions.authorize('update', a));
permissions.setUser({
id: 'foo',
groups: ['other']
});
assert.isFalse(permissions.authorize('update', a));
permissions.setUser({
id: 'charlie',
groups: ['admin']
});
return assert.isTrue(permissions.authorize('update', a));
});
});
});
describe('updateAnnotationPermissions', function() {
var annotation, checkbox, field;
field = null;
checkbox = null;
annotation = null;
beforeEach(function() {
checkbox = $('<input type="checkbox" />');
field = $('<li />').append(checkbox)[0];
return annotation = {
permissions: {
'update': ['Alice']
}
};
});
it("should NOT be world editable when 'Anyone can edit' checkbox is unchecked", function() {
checkbox.removeAttr('checked');
permissions.updateAnnotationPermissions('update', field, annotation);
return assert.isFalse(permissions.authorize('update', annotation, null));
});
it("should be world editable when 'Anyone can edit' checkbox is checked", function() {
checkbox.attr('checked', 'checked');
permissions.updateAnnotationPermissions('update', field, annotation);
return assert.isTrue(permissions.authorize('update', annotation, null));
});
return it("should NOT be world editable when 'Anyone can edit' checkbox is unchecked for a second time", function() {
checkbox.attr('checked', 'checked');
permissions.updateAnnotationPermissions('update', field, annotation);
assert.isTrue(permissions.authorize('update', annotation, null));
checkbox.removeAttr('checked');
permissions.updateAnnotationPermissions('update', field, annotation);
return assert.isFalse(permissions.authorize('update', annotation, null));
});
});
describe('updatePermissionsField', function() {
var annotations, checkbox, field;
field = null;
checkbox = null;
annotations = [
{}, {
permissions: {
'update': ['user:Alice']
}
}, {
permissions: {
'update': ['user:Alice']
}
}, {
permissions: {
'update': ['Alice'],
'admin': ['Alice']
}
}, {
permissions: {
'update': ['Alice'],
'admin': ['Bob']
}
}
];
beforeEach(function() {
checkbox = $('<input type="checkbox" />');
field = $('<li />').append(checkbox).appendTo(permissions.element);
permissions.setUser('Alice');
return permissions.updatePermissionsField('update', field, annotations.shift());
});
afterEach(function() {
return field.remove();
});
it("should have a checked checkbox when there are no permissions", function() {
return assert.isTrue(checkbox.is(':checked'));
});
it("should have an unchecked checkbox when there are permissions", function() {
return assert.isFalse(checkbox.is(':checked'));
});
it("should enable the checkbox by default", function() {
return assert.isTrue(checkbox.is(':enabled'));
});
it("should display the field if the current user has 'admin' permissions", function() {
return assert.isTrue(field.is(':visible'));
});
return it("should NOT display the field if the current user does not have 'admin' permissions", function() {
return assert.isFalse(field.is(':visible'));
});
});
return describe('updateViewer', function() {
var controls, field;
controls = null;
field = null;
beforeEach(function() {
field = $('<div />').appendTo('<div />')[0];
return controls = {
showEdit: sinon.spy(),
hideEdit: sinon.spy(),
showDelete: sinon.spy(),
hideDelete: sinon.spy()
};
});
describe('coarse grained updates based on user', function() {
var annotations;
annotations = null;
beforeEach(function() {
permissions.setUser('alice');
return annotations = [
{
user: 'alice'
}, {
user: 'bob'
}, {}
];
});
it("it should display annotations' users in the viewer element", function() {
permissions.updateViewer(field, annotations[0], controls);
assert.equal($(field).html(), 'alice');
return assert.lengthOf($(field).parent(), 1);
});
it("it should remove the field if annotation has no user", function() {
permissions.updateViewer(field, {}, controls);
return assert.lengthOf($(field).parent(), 0);
});
it("it should remove the field if annotation has no user string", function() {
permissions.options.userString = function() {
return null;
};
permissions.updateViewer(field, annotations[1], controls);
return assert.lengthOf($(field).parent(), 0);
});
it("it should remove the field if annotation has empty user string", function() {
permissions.options.userString = function() {
return '';
};
permissions.updateViewer(field, annotations[1], controls);
return assert.lengthOf($(field).parent(), 0);
});
it("should hide controls for users other than the current user", function() {
permissions.updateViewer(field, annotations[0], controls);
assert.isFalse(controls.hideEdit.called);
assert.isFalse(controls.hideDelete.called);
permissions.updateViewer(field, annotations[1], controls);
assert(controls.hideEdit.calledOnce);
return assert(controls.hideDelete.calledOnce);
});
return it("should show controls for annotations without a user", function() {
permissions.updateViewer(field, annotations[2], controls);
assert.isFalse(controls.hideEdit.called);
return assert.isFalse(controls.hideDelete.called);
});
});
return describe('fine-grained use (user and permissions)', function() {
var annotations;
annotations = null;
beforeEach(function() {
annotations = [
{
user: 'alice',
permissions: {
'update': ['alice'],
'delete': ['alice']
}
}, {
user: 'bob',
permissions: {
'update': ['bob'],
'delete': ['bob']
}
}
];
return permissions.setUser('bob');
});
it("it should should hide edit button if user cannot update", function() {
permissions.updateViewer(field, annotations[0], controls);
return assert(controls.hideEdit.calledOnce);
});
it("it should should show edit button if user can update", function() {
permissions.updateViewer(field, annotations[1], controls);
return assert.isFalse(controls.hideEdit.called);
});
it("it should should hide delete button if user cannot delete", function() {
permissions.updateViewer(field, annotations[0], controls);
return assert(controls.hideDelete.calledOnce);
});
return it("it should should show delete button if user can delete", function() {
permissions.updateViewer(field, annotations[1], controls);
return assert.isFalse(controls.hideDelete.called);
});
});
});
});
/*
//@ sourceMappingURL=permissions_spec.map
*/

File diff suppressed because one or more lines are too long

View file

@ -1,640 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe("Annotator.Plugin.Store", function() {
var store;
store = null;
beforeEach(function() {
var element;
element = $('<div></div>')[0];
store = new Annotator.Plugin.Store(element, {
autoFetch: false
});
return store.annotator = {
plugins: {},
loadAnnotations: sinon.spy()
};
});
describe("events", function() {
it("should call Store#annotationCreated when the annotationCreated is fired", function() {
sinon.stub(store, 'annotationCreated');
store.element.trigger('annotationCreated', ['annotation1']);
return assert.isTrue(store.annotationCreated.calledWith('annotation1'));
});
it("should call Store#annotationUpdated when the annotationUpdated is fired", function() {
sinon.stub(store, 'annotationUpdated');
store.element.trigger('annotationUpdated', ['annotation1']);
return assert.isTrue(store.annotationUpdated.calledWith('annotation1'));
});
return it("should call Store#annotationDeleted when the annotationDeleted is fired", function() {
sinon.stub(store, 'annotationDeleted');
store.element.trigger('annotationDeleted', ['annotation1']);
return assert.isTrue(store.annotationDeleted.calledWith('annotation1'));
});
});
describe("pluginInit", function() {
it("should call Store#_getAnnotations() if no Auth plugin is loaded", function() {
sinon.stub(store, '_getAnnotations');
store.pluginInit();
return assert(store._getAnnotations.calledOnce);
});
return it("should call Auth#withToken() if Auth plugin is loaded", function() {
var authMock;
authMock = {
withToken: sinon.spy()
};
store.annotator.plugins.Auth = authMock;
store.pluginInit();
return assert.isTrue(authMock.withToken.calledWith(store._getAnnotations));
});
});
describe("_getAnnotations", function() {
it("should call Store#loadAnnotations() if @options.loadFromSearch is not present", function() {
sinon.stub(store, 'loadAnnotations');
store._getAnnotations();
return assert(store.loadAnnotations.calledOnce);
});
return it("should call Store#loadAnnotationsFromSearch() if @options.loadFromSearch is present", function() {
sinon.stub(store, 'loadAnnotationsFromSearch');
store.options.loadFromSearch = {};
store._getAnnotations();
return assert.isTrue(store.loadAnnotationsFromSearch.calledWith(store.options.loadFromSearch));
});
});
describe("annotationCreated", function() {
var annotation;
annotation = null;
beforeEach(function() {
annotation = {};
sinon.stub(store, 'registerAnnotation');
sinon.stub(store, 'updateAnnotation');
return sinon.stub(store, '_apiRequest');
});
it("should call Store#registerAnnotation() with the new annotation", function() {
store.annotationCreated(annotation);
return assert.isTrue(store.registerAnnotation.calledWith(annotation));
});
it("should call Store#_apiRequest('create') with the new annotation", function() {
var args;
store.annotationCreated(annotation);
args = store._apiRequest.lastCall.args;
assert(store._apiRequest.calledOnce);
assert.equal(args[0], 'create');
return assert.equal(args[1], annotation);
});
return it("should call Store#updateAnnotation() if the annotation already exists in @annotations", function() {
store.annotations = [annotation];
store.annotationCreated(annotation);
assert(store.updateAnnotation.calledOnce);
return assert.equal(store.updateAnnotation.lastCall.args[0], annotation);
});
});
describe("annotationUpdated", function() {
var annotation;
annotation = null;
beforeEach(function() {
annotation = {};
return sinon.stub(store, '_apiRequest');
});
it("should call Store#_apiRequest('update') with the annotation and data", function() {
var args, data;
store.annotations = [annotation];
store.annotationUpdated(annotation);
args = store._apiRequest.lastCall.args;
assert(store._apiRequest.calledOnce);
assert.equal(args[0], 'update');
assert.equal(args[1], annotation);
assert.equal(typeof args[2], 'function');
sinon.stub(store, 'updateAnnotation');
data = {
text: "Dummy response data"
};
args[2](data);
return assert.isTrue(store.updateAnnotation.calledWith(annotation, data));
});
return it("should NOT call Store#_apiRequest() if the annotation is unregistered", function() {
store.annotations = [];
store.annotationUpdated(annotation);
return assert.isFalse(store._apiRequest.called);
});
});
describe("annotationDeleted", function() {
var annotation;
annotation = null;
beforeEach(function() {
annotation = {};
return sinon.stub(store, '_apiRequest');
});
it("should call Store#_apiRequest('destroy') with the annotation and data", function() {
var args;
store.annotations = [annotation];
store.annotationDeleted(annotation);
args = store._apiRequest.lastCall.args;
assert(store._apiRequest.calledOnce);
assert.equal(args[0], 'destroy');
return assert.equal(args[1], annotation);
});
return it("should NOT call Store#_apiRequest() if the annotation is unregistered", function() {
store.annotations = [];
store.annotationDeleted(annotation);
return assert.isFalse(store._apiRequest.called);
});
});
describe("registerAnnotation", function() {
return it("should add the annotation to the @annotations array", function() {
var annotation;
annotation = {};
store.annotations = [];
store.registerAnnotation(annotation);
return assert.equal($.inArray(annotation, store.annotations), 0);
});
});
describe("unregisterAnnotation", function() {
return it("should remove the annotation from the @annotations array", function() {
var annotation;
annotation = {};
store.annotations = [annotation];
store.unregisterAnnotation(annotation);
return assert.equal($.inArray(annotation, store.annotations), -1);
});
});
describe("updateAnnotation", function() {
var annotation;
annotation = {};
beforeEach(function() {
sinon.stub(console, 'error');
annotation = {
text: "my annotation text",
range: []
};
return store.annotations = [annotation];
});
afterEach(function() {
return console.error.restore();
});
it("should extend the annotation with the data provided", function() {
store.updateAnnotation(annotation, {
id: "myid",
text: "new text"
});
return assert.deepEqual(annotation, {
id: "myid",
text: "new text",
range: []
});
});
it("should NOT extend the annotation if it is not registered with the Store", function() {
store.annotations = [];
store.updateAnnotation(annotation, {
id: "myid",
text: "new text"
});
return assert.equal(annotation, annotation);
});
return it("should update the data stored on the annotation highlight", function() {
var data;
data = {};
annotation.highlight = $('<span />').data('annotation', annotation);
store.updateAnnotation(annotation, data);
return assert.equal(annotation.highlight.data('annotation'), annotation);
});
});
describe("loadAnnotations", function() {
return it("should call Store#_apiRequest()", function() {
sinon.stub(store, '_apiRequest');
store.loadAnnotations();
return assert.isTrue(store._apiRequest.calledWith('read', null, store._onLoadAnnotations));
});
});
describe("loadAnnotationsFromSearch", function() {
return it("should call Store#_apiRequest()", function() {
var options;
options = {};
sinon.stub(store, '_apiRequest');
store.loadAnnotationsFromSearch(options);
return assert.isTrue(store._apiRequest.calledWith('search', options, store._onLoadAnnotationsFromSearch));
});
});
describe("_onLoadAnnotations", function() {
it("should set the Store#annotations property with received annotations", function() {
var data;
data = [1, 2, 3];
store._onLoadAnnotations(data);
return assert.deepEqual(store.annotations, data);
});
it("should default to an empty array if no data is provided", function() {
store._onLoadAnnotations();
return assert.deepEqual(store.annotations, []);
});
it("should call Annotator#loadAnnotations()", function() {
store._onLoadAnnotations();
return assert(store.annotator.loadAnnotations.calledOnce);
});
it("should call Annotator#loadAnnotations() with clone of provided data", function() {
var data;
data = [];
store._onLoadAnnotations(data);
assert.notStrictEqual(store.annotator.loadAnnotations.lastCall.args[0], data);
return assert.deepEqual(store.annotator.loadAnnotations.lastCall.args[0], data);
});
return it("should add, dedupe and update annotations when called for the 2nd time", function() {
var data1, data2, dataAll;
data1 = [
{
id: 1
}, {
id: 2
}
];
data2 = [
{
id: 1,
foo: "bar"
}, {
id: 3
}
];
dataAll = [
{
id: 1,
foo: "bar"
}, {
id: 2
}, {
id: 3
}
];
store._onLoadAnnotations(data1);
store._onLoadAnnotations(data2);
return assert.deepEqual(store.annotations, dataAll);
});
});
describe("_onLoadAnnotationsFromSearch", function() {
it("should call Store#_onLoadAnnotations() with data.rows", function() {
var data;
sinon.stub(store, '_onLoadAnnotations');
data = {
rows: [{}, {}, {}]
};
store._onLoadAnnotationsFromSearch(data);
return assert.deepEqual(store._onLoadAnnotations.lastCall.args[0], data.rows);
});
return it("should default to an empty array if no data.rows are provided", function() {
sinon.stub(store, '_onLoadAnnotations');
store._onLoadAnnotationsFromSearch();
return assert.deepEqual(store._onLoadAnnotations.lastCall.args[0], []);
});
});
describe("dumpAnnotations", function() {
it("returns a list of its annotations", function() {
store.annotations = [
{
text: "Foobar"
}, {
user: "Bob"
}
];
return assert.deepEqual(store.dumpAnnotations(), [
{
text: "Foobar"
}, {
user: "Bob"
}
]);
});
return it("removes the highlights properties from the annotations", function() {
store.annotations = [
{
highlights: "abc"
}, {
highlights: [1, 2, 3]
}
];
return assert.deepEqual(store.dumpAnnotations(), [{}, {}]);
});
});
describe("_apiRequest", function() {
var mockOptions, mockUri;
mockUri = 'http://mock.com';
mockOptions = {};
beforeEach(function() {
sinon.stub(store, '_urlFor').returns(mockUri);
sinon.stub(store, '_apiRequestOptions').returns(mockOptions);
return sinon.stub($, 'ajax').returns({});
});
afterEach(function() {
return $.ajax.restore();
});
it("should call Store#_urlFor() with the action", function() {
var action;
action = 'read';
store._apiRequest(action);
return assert.isTrue(store._urlFor.calledWith(action, void 0));
});
it("should call Store#_urlFor() with the action and id extracted from the data", function() {
var action, data;
data = {
id: 'myId'
};
action = 'read';
store._apiRequest(action, data);
return assert.isTrue(store._urlFor.calledWith(action, data.id));
});
it("should call Store#_apiRequestOptions() with the action, data and callback", function() {
var action, callback, data;
data = {
id: 'myId'
};
action = 'read';
callback = function() {};
store._apiRequest(action, data, callback);
return assert.isTrue(store._apiRequestOptions.calledWith(action, data, callback));
});
it("should call jQuery#ajax()", function() {
store._apiRequest();
return assert.isTrue($.ajax.calledWith(mockUri, mockOptions));
});
return it("should return the jQuery XHR object with action and id appended", function() {
var action, data, request;
data = {
id: 'myId'
};
action = 'read';
request = store._apiRequest(action, data);
assert.equal(request._id, data.id);
return assert.equal(request._action, action);
});
});
describe("_apiRequestOptions", function() {
beforeEach(function() {
return sinon.stub(store, '_dataFor').returns('{}');
});
it("should call Store#_methodFor() with the action", function() {
var action;
sinon.stub(store, '_methodFor').returns('GET');
action = 'read';
store._apiRequestOptions(action);
return assert.isTrue(store._methodFor.calledWith(action));
});
it("should return options for jQuery.ajax()", function() {
var action, callback, data, options;
sinon.stub(store, '_methodFor').returns('GET');
action = 'read';
data = {};
callback = function() {};
options = store._apiRequestOptions(action, data, callback);
return assert.deepEqual(options, {
type: 'GET',
headers: void 0,
dataType: "json",
success: callback,
error: store._onError,
data: '{}',
contentType: "application/json; charset=utf-8"
});
});
it("should set custom headers from the data property 'annotator:headers'", function() {
var action, data, options;
sinon.stub(store, '_methodFor').returns('GET');
sinon.stub(store.element, 'data').returns({
'x-custom-header-one': 'mycustomheader',
'x-custom-header-two': 'mycustomheadertwo',
'x-custom-header-three': 'mycustomheaderthree'
});
action = 'read';
data = {};
options = store._apiRequestOptions(action, data);
return assert.deepEqual(options.headers, {
'x-custom-header-one': 'mycustomheader',
'x-custom-header-two': 'mycustomheadertwo',
'x-custom-header-three': 'mycustomheaderthree'
});
});
it("should call Store#_dataFor() with the data if action is NOT search", function() {
var action, data;
sinon.stub(store, '_methodFor').returns('GET');
action = 'read';
data = {};
store._apiRequestOptions(action, data);
return assert.isTrue(store._dataFor.calledWith(data));
});
it("should NOT call Store#_dataFor() if action is search", function() {
var action, data;
sinon.stub(store, '_methodFor').returns('GET');
action = 'search';
data = {};
store._apiRequestOptions(action, data);
return assert.isFalse(store._dataFor.called);
});
it("should NOT add the contentType property if the action is search", function() {
var action, data, options;
sinon.stub(store, '_methodFor').returns('GET');
action = 'search';
data = {};
options = store._apiRequestOptions(action, data);
assert.isUndefined(options.contentType);
return assert.equal(options.data, data);
});
it("should emulate new-fangled HTTP if emulateHTTP is true", function() {
var options;
sinon.stub(store, '_methodFor').returns('DELETE');
store.options.emulateHTTP = true;
options = store._apiRequestOptions('destroy', {
id: 4
});
assert.equal(options.type, 'POST');
return assert.deepEqual(options.headers, {
'X-HTTP-Method-Override': 'DELETE'
});
});
it("should emulate proper JSON handling if emulateJSON is true", function() {
var options;
sinon.stub(store, '_methodFor').returns('DELETE');
store.options.emulateJSON = true;
options = store._apiRequestOptions('destroy', {});
assert.deepEqual(options.data, {
json: '{}'
});
return assert.isUndefined(options.contentType);
});
return it("should append _method to the form data if emulateHTTP and emulateJSON are both true", function() {
var options;
sinon.stub(store, '_methodFor').returns('DELETE');
store.options.emulateHTTP = true;
store.options.emulateJSON = true;
options = store._apiRequestOptions('destroy', {});
return assert.deepEqual(options.data, {
_method: 'DELETE',
json: '{}'
});
});
});
describe("_urlFor", function() {
it("should generate RESTful URLs by default", function() {
assert.equal(store._urlFor('create'), '/store/annotations');
assert.equal(store._urlFor('read'), '/store/annotations');
assert.equal(store._urlFor('read', 'foo'), '/store/annotations/foo');
assert.equal(store._urlFor('update', 'bar'), '/store/annotations/bar');
return assert.equal(store._urlFor('destroy', 'baz'), '/store/annotations/baz');
});
it("should generate URLs as specified by its options otherwise", function() {
store.options.prefix = '/some/prefix';
store.options.urls.create = '/createMe';
store.options.urls.read = '/:id/readMe';
store.options.urls.update = '/:id/updateMe';
store.options.urls.destroy = '/:id/destroyMe';
assert.equal(store._urlFor('create'), '/some/prefix/createMe');
assert.equal(store._urlFor('read'), '/some/prefix/readMe');
assert.equal(store._urlFor('read', 'foo'), '/some/prefix/foo/readMe');
assert.equal(store._urlFor('update', 'bar'), '/some/prefix/bar/updateMe');
return assert.equal(store._urlFor('destroy', 'baz'), '/some/prefix/baz/destroyMe');
});
it("should generate URLs correctly with an empty prefix", function() {
store.options.prefix = '';
store.options.urls.create = '/createMe';
store.options.urls.read = '/:id/readMe';
store.options.urls.update = '/:id/updateMe';
store.options.urls.destroy = '/:id/destroyMe';
assert.equal(store._urlFor('create'), '/createMe');
assert.equal(store._urlFor('read'), '/readMe');
assert.equal(store._urlFor('read', 'foo'), '/foo/readMe');
assert.equal(store._urlFor('update', 'bar'), '/bar/updateMe');
return assert.equal(store._urlFor('destroy', 'baz'), '/baz/destroyMe');
});
return it("should generate URLs with substitution markers in query strings", function() {
store.options.prefix = '/some/prefix';
store.options.urls.read = '/read?id=:id';
store.options.urls.update = '/update?foo&id=:id';
store.options.urls.destroy = '/delete?id=:id&foo';
assert.equal(store._urlFor('read'), '/some/prefix/read?id=');
assert.equal(store._urlFor('read', 'foo'), '/some/prefix/read?id=foo');
assert.equal(store._urlFor('update', 'bar'), '/some/prefix/update?foo&id=bar');
return assert.equal(store._urlFor('destroy', 'baz'), '/some/prefix/delete?id=baz&foo');
});
});
describe("_methodFor", function() {
return it("should return the appropriate method for the action", function() {
var action, method, table, _i, _len, _results;
table = {
'create': 'POST',
'read': 'GET',
'update': 'PUT',
'destroy': 'DELETE',
'search': 'GET'
};
_results = [];
for (method = _i = 0, _len = table.length; _i < _len; method = ++_i) {
action = table[method];
_results.push(assert.equal(store._methodFor(action, method)));
}
return _results;
});
});
describe("_dataFor", function() {
it("should stringify the annotation into JSON", function() {
var annotation, data;
annotation = {
id: 'bill'
};
data = store._dataFor(annotation);
return assert.equal(data, '{"id":"bill"}');
});
it("should NOT stringify the highlights property", function() {
var annotation, data;
annotation = {
id: 'bill',
highlights: {}
};
data = store._dataFor(annotation);
return assert.equal(data, '{"id":"bill"}');
});
it("should NOT append a highlights property if the annotation does not have one", function() {
var annotation;
annotation = {
id: 'bill'
};
store._dataFor(annotation);
return assert.isFalse(annotation.hasOwnProperty('highlights'));
});
return it("should extend the annotation with @options.annotationData", function() {
var annotation, data;
annotation = {
id: "cat"
};
store.options.annotationData = {
custom: 'value',
customArray: []
};
data = store._dataFor(annotation);
assert.equal(data, '{"id":"cat","custom":"value","customArray":[]}');
return assert.deepEqual(annotation, {
"id": "cat",
"custom": "value",
"customArray": []
});
});
});
return describe("_onError", function() {
var message, requests;
message = null;
requests = [
{}, {}, {
_action: 'read',
_id: 'jim'
}, {
_action: 'search'
}, {
_action: 'read'
}, {
status: 401,
_action: 'delete',
'_id': 'cake'
}, {
status: 404,
_action: 'delete',
'_id': 'cake'
}, {
status: 500,
_action: 'delete',
'_id': 'cake'
}
];
beforeEach(function() {
sinon.stub(Annotator, 'showNotification');
sinon.stub(console, 'error');
store._onError(requests.shift());
return message = Annotator.showNotification.lastCall.args[0];
});
afterEach(function() {
Annotator.showNotification.restore();
return console.error.restore();
});
it("should call call Annotator.showNotification() with a message and error style", function() {
assert(Annotator.showNotification.calledOnce);
return assert.equal(Annotator.showNotification.lastCall.args[1], Annotator.Notification.ERROR);
});
it("should call console.error with a message", function() {
return assert(console.error.calledOnce);
});
it("should give a default message if xhr.status id not provided", function() {
return assert.equal(message, "Sorry we could not read this annotation");
});
it("should give a default specific message if xhr._action is 'search'", function() {
return assert.equal(message, "Sorry we could not search the store for annotations");
});
it("should give a default specific message if xhr._action is 'read' and there is no xhr._id", function() {
return assert.equal(message, "Sorry we could not read the annotations from the store");
});
it("should give a specific message if xhr.status == 401", function() {
return assert.equal(message, "Sorry you are not allowed to delete this annotation");
});
it("should give a specific message if xhr.status == 404", function() {
return assert.equal(message, "Sorry we could not connect to the annotations store");
});
return it("should give a specific message if xhr.status == 500", function() {
return assert.equal(message, "Sorry something went wrong with the annotation store");
});
});
});
/*
//@ sourceMappingURL=store_spec.map
*/

File diff suppressed because one or more lines are too long

View file

@ -1,108 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Annotator.Plugin.Tags', function() {
var annotator, plugin;
annotator = null;
plugin = null;
beforeEach(function() {
var el;
el = $("<div><div class='annotator-editor-controls'></div></div>")[0];
annotator = new Annotator($('<div/>')[0]);
plugin = new Annotator.Plugin.Tags(el);
plugin.annotator = annotator;
return plugin.pluginInit();
});
it("should parse whitespace-delimited tags into an array", function() {
var str;
str = 'one two three\tfourFive';
return assert.deepEqual(plugin.parseTags(str), ['one', 'two', 'three', 'fourFive']);
});
it("should stringify a tags array into a space-delimited string", function() {
var ary;
ary = ['one', 'two', 'three'];
return assert.equal(plugin.stringifyTags(ary), "one two three");
});
describe("pluginInit", function() {
it("should add a field to the editor", function() {
sinon.spy(annotator.editor, 'addField');
plugin.pluginInit();
return assert(annotator.editor.addField.calledOnce);
});
return it("should register a filter if the Filter plugin is loaded", function() {
plugin.annotator.plugins.Filter = {
addFilter: sinon.spy()
};
plugin.pluginInit();
return assert(plugin.annotator.plugins.Filter.addFilter.calledOnce);
});
});
describe("updateField", function() {
it("should set the value of the input", function() {
var annotation;
annotation = {
tags: ['apples', 'oranges', 'pears']
};
plugin.updateField(plugin.field, annotation);
return assert.equal(plugin.input.val(), 'apples oranges pears');
});
return it("should set the clear the value of the input if there are no tags", function() {
var annotation;
annotation = {};
plugin.input.val('apples pears oranges');
plugin.updateField(plugin.field, annotation);
return assert.equal(plugin.input.val(), '');
});
});
describe("setAnnotationTags", function() {
return it("should set the annotation's tags", function() {
var annotation;
annotation = {};
plugin.input.val('apples oranges pears');
plugin.setAnnotationTags(plugin.field, annotation);
return assert.deepEqual(annotation.tags, ['apples', 'oranges', 'pears']);
});
});
return describe("updateViewer", function() {
it("should insert the tags into the field", function() {
var annotation, field;
annotation = {
tags: ['foo', 'bar', 'baz']
};
field = $('<div />')[0];
plugin.updateViewer(field, annotation);
return assert.deepEqual($(field).html(), ['<span class="annotator-tag">foo</span>', '<span class="annotator-tag">bar</span>', '<span class="annotator-tag">baz</span>'].join(' '));
});
return it("should remove the field if there are no tags", function() {
var annotation, field;
annotation = {
tags: []
};
field = $('<div />')[0];
plugin.updateViewer(field, annotation);
assert.lengthOf($(field).parent(), 0);
annotation = {};
field = $('<div />')[0];
plugin.updateViewer(field, annotation);
return assert.lengthOf($(field).parent(), 0);
});
});
});
describe('Annotator.Plugin.Tags.filterCallback', function() {
var filter;
filter = null;
beforeEach(function() {
return filter = Annotator.Plugin.Tags.filterCallback;
});
it('should return true if all tags are matched by keywords', function() {
assert.isTrue(filter('cat dog mouse', ['cat', 'dog', 'mouse']));
return assert.isTrue(filter('cat dog', ['cat', 'dog', 'mouse']));
});
return it('should NOT return true if all tags are NOT matched by keywords', function() {
assert.isFalse(filter('cat dog', ['cat']));
return assert.isFalse(filter('cat dog', []));
});
});
/*
//@ sourceMappingURL=tags_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "tags_spec.js",
"sourceRoot": "../../..",
"sources": [
"test/spec/plugin/tags_spec.coffee"
],
"names": [],
"mappings": ";AAAA,CAAS,CAAyB,CAAA,KAAlC,CAAkC,cAAlC;CACE,KAAA,WAAA;CAAA,CAAA,CAAY,CAAZ,KAAA;CAAA,CACA,CAAS,CADT,EACA;CADA,CAGA,CAAW,MAAA,CAAX;CACE,CAAA,MAAA;CAAA,CAAA,CAAK,CAAL,sDAAK;CAAL,EACgB,CAAhB,IAA0B,CAA1B;CADA,CAEa,CAAA,CAAb,EAAA,GAAsB;CAFtB,EAGmB,CAAnB,EAAM,GAAN;CACO,KAAD,IAAN,CAAA;CALF,EAAW;CAHX,CAUA,CAA2D,MAAA,6CAA3D;CACE,EAAA,KAAA;CAAA,EAAA,CAAA,sBAAA;CACO,CAAiC,CAAvB,EAAuB,CAAlC,CAAkC,EAAxC,CAAwC,CAAxC;CAFF,EAA2D;CAV3D,CAcA,CAAkE,MAAA,oDAAlE;CACE,EAAA,KAAA;CAAA,CAAc,CAAd,CAAA,CAAM,EAAA;CACC,CAAiC,CAA3B,EAAb,CAAM,KAAN,EAAa,EAAb;CAFF,EAAkE;CAdlE,CAkBA,CAAuB,KAAvB,CAAuB,GAAvB;CACE,CAAA,CAAuC,CAAvC,KAAuC,yBAAvC;CACE,CAA4B,CAA5B,EAAK,CAAL,GAAmB,CAAnB;CAAA,KACA,IAAA;CACO,KAAP,EAAgC,CAAhB,CAAhB,GAAA;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,CAAA,CAAX,GAAN,IAAA,2BAAkC;CALpC,IAA4C;CAWzC,CAAH,CAAmD,MAAA,EAAnD,mCAAA;CACE,SAAA,OAAA;CAAA,EAAa,GAAb,IAAA;CAAa,CAAQ,EAAN,IAAA;CAAf,OAAA;CAAA,EACQ,EAAR,CAAA,GAAQ;CADR,CAG2B,GAA3B,CAAA,IAAA,EAAA;CAHA,CAImC,GAAnB,CAAhB,EAAA;CAJA,CAAA,CAMa,GAAb,IAAA;CANA,EAOQ,EAAR,CAAA,GAAQ;CAPR,CAS2B,GAA3B,CAAA,IAAA,EAAA;CACO,CAA4B,GAAnB,CAAV,EAAN,KAAA;CAXF,IAAmD;CAZrD,EAAyB;CApDO;;AA8ElC,CA9EA,CA8EiD,CAAA,KAAjD,CAAiD,6BAAjD;CACE,KAAA;CAAA,CAAA,CAAS,CAAT,EAAA;CAAA,CACA,CAAW,MAAA,CAAX;CAAiC,EAAV,CAAqB,EAA9B,GAAkB,EAAlB;CAAd,EAAW;CADX,CAGA,CAA6D,MAAA,+CAA7D;CACE,CAAsC,EAAtC,CAAsC,CAAhC,CAAgC,QAAxB;CACP,CAAyB,GAAA,CAA1B,CAA0B,EAAlB,EAAd;CAFF,EAA6D;CAI1D,CAAH,CAAqE,MAArE,uDAAA;CACE,CAAiC,EAAjC,CAAiC,CAA3B,CAAN,EAAe;CACR,CAA0B,IAA3B,CAAN,EAAe,EAAf;CAFF,EAAqE;CARtB"
}

View file

@ -1,6 +0,0 @@
// Generated by CoffeeScript 1.6.3
/*
//@ sourceMappingURL=unsupported_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "unsupported_spec.js",
"sourceRoot": "../../..",
"sources": [
"test/spec/plugin/unsupported_spec.coffee"
],
"names": [],
"mappings": ";AAwFyC"
}

View file

@ -1,206 +0,0 @@
// Generated by CoffeeScript 1.6.3
var testData;
testData = [[0, 13, 0, 27, "habitant morbi", "Partial node contents."], [0, 0, 0, 37, "Pellentesque habitant morbi tristique", "Full node contents, textNode refs."], ['/p/strong', 0, '/p/strong', 1, "Pellentesque habitant morbi tristique", "Full node contents, elementNode refs."], [0, 22, 1, 12, "morbi tristique senectus et", "Spanning 2 nodes."], ['/p/strong', 0, 1, 12, "Pellentesque habitant morbi tristique senectus et", "Spanning 2 nodes, elementNode start ref."], [1, 165, '/p/em', 1, "egestas semper. Aenean ultricies mi vitae est.", "Spanning 2 nodes, elementNode end ref."], [9, 7, 12, 11, "Level 2\n\n\n Lorem ipsum", "Spanning multiple nodes, textNode refs."], ['/p', 0, '/p', 8, "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.", "Spanning multiple nodes, elementNode refs."], ['/p[2]', 0, '/p[2]', 1, "Lorem sed do eiusmod tempor.", "Full node contents with empty node at end."], ["/div/text()[2]", 0, "/div/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, textNode refs"], ["/div/text()[2]", 0, "/div", 4, "Lorem sed do eiusmod tempor.", "Text between br tags, elementNode ref at end"], ["/div/text()[2]", 0, "/div", 5, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/> at end"], ["/div/text()[2]", 0, "/div", 6, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/><br/> at end"], ["/div/text()[2]", 0, "/div", 7, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/><br/><br/> at end"], ["/div", 3, "/div/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, elementNode ref at start"], ["/div", 2, "/div/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/> at start"], ["/div", 1, "/div/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/><br/> at start"], ["/div[2]/text()[2]", 0, "/div[2]/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, textNode refs"], ["/div[2]/text()[2]", 0, "/div[2]", 4, "Lorem sed do eiusmod tempor.", "Text between br tags, elementNode ref at end"], ["/div[2]/text()[2]", 0, "/div[2]", 5, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/> at end"], ["/div[2]/text()[2]", 0, "/div[2]", 6, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/><p><br/></p> at end"], ["/div[2]/text()[2]", 0, "/div[2]", 7, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/><p><br/></p><br/> at end"], ["/div[2]", 3, "/div[2]/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, elementNode ref at start"], ["/div[2]", 2, "/div[2]/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, with <p><br/></p> at the start"], ["/div[2]", 1, "/div[2]/text()[2]", 28, "Lorem sed do eiusmod tempor.", "Text between br tags, with <br/><p><br/></p> at the start"]];
describe('Range', function() {
var mockSelection, r;
r = null;
mockSelection = null;
beforeEach(function() {
addFixture('range');
return mockSelection = function(ii) {
return new MockSelection(fix(), testData[ii]);
};
});
afterEach(function() {
delete a;
return clearFixtures();
});
describe(".nodeFromXPath()", function() {
var xpath;
xpath = window.require ? "/html/body/p/strong" : "/html/body/div/p/strong";
it("should parse a standard xpath string", function() {
var node;
node = Range.nodeFromXPath(xpath);
return assert.equal(node, $('strong')[0]);
});
return it("should parse an standard xpath string for an xml document", function() {
var node;
Annotator.$.isXMLDoc = function() {
return true;
};
node = Range.nodeFromXPath(xpath);
return assert.equal(node, $('strong')[0]);
});
});
describe("SerializedRange", function() {
beforeEach(function() {
return r = new Range.SerializedRange({
start: "/p/strong",
startOffset: 13,
end: "/p/strong",
endOffset: 27
});
});
describe("normalize", function() {
it("should return a normalized range", function() {
var norm;
norm = r.normalize(fix());
assert.isTrue(norm instanceof Range.NormalizedRange);
return assert.equal(norm.text(), "habitant morbi");
});
it("should return a normalized range with 0 offsets", function() {
var norm;
r.startOffset = 0;
norm = r.normalize(fix());
assert.isTrue(norm instanceof Range.NormalizedRange);
return assert.equal(norm.text(), "Pellentesque habitant morbi");
});
return it("should raise Range.RangeError if it cannot normalize the range", function() {
var check, e;
check = false;
try {
r.normalize($('<div/>')[0]);
} catch (_error) {
e = _error;
if (e instanceof Range.RangeError) {
check = true;
}
}
return assert.isTrue(check);
});
});
it("serialize() returns a serialized range", function() {
var seri;
seri = r.serialize(fix());
assert.equal(seri.start, "/p[1]/strong[1]");
assert.equal(seri.startOffset, 13);
assert.equal(seri.end, "/p[1]/strong[1]");
assert.equal(seri.endOffset, 27);
return assert.isTrue(seri instanceof Range.SerializedRange);
});
return it("toObject() returns a simple object", function() {
var obj;
obj = r.toObject();
assert.equal(obj.start, "/p/strong");
assert.equal(obj.startOffset, 13);
assert.equal(obj.end, "/p/strong");
assert.equal(obj.endOffset, 27);
return assert.equal(JSON.stringify(obj), '{"start":"/p/strong","startOffset":13,"end":"/p/strong","endOffset":27}');
});
});
describe("BrowserRange", function() {
var i, testBrowserRange, _i, _ref, _results;
beforeEach(function() {
var sel;
sel = mockSelection(0);
return r = new Range.BrowserRange(sel.getRangeAt(0));
});
it("normalize() returns a normalized range", function() {
var norm;
norm = r.normalize();
assert.equal(norm.start, norm.end);
return assert.equal(textInNormedRange(norm), 'habitant morbi');
});
testBrowserRange = function(i) {
return function() {
var norm, range, sel;
sel = mockSelection(i);
range = new Range.BrowserRange(sel.getRangeAt(0));
norm = range.normalize(fix());
return assert.equal(textInNormedRange(norm), sel.expectation);
};
};
_results = [];
for (i = _i = 0, _ref = testData.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
_results.push(it("should parse test range " + i + " (" + testData[i][5] + ")", testBrowserRange(i)));
}
return _results;
});
return describe("NormalizedRange", function() {
var sel;
sel = null;
beforeEach(function() {
var browserRange;
sel = mockSelection(7);
browserRange = new Range.BrowserRange(sel.getRangeAt(0));
return r = browserRange.normalize();
});
it("textNodes() returns an array of textNodes", function() {
var textNodes;
textNodes = r.textNodes();
assert.equal($.type(textNodes), 'array');
assert.lengthOf(textNodes, sel.endOffset);
return assert.equal(textNodes[0].nodeValue, 'Pellentesque habitant morbi tristique');
});
it("text() returns the textual contents of the range", function() {
return assert.equal(r.text(), sel.expectation);
});
describe("limit", function() {
var headText, para, paraText, paraText2, root;
headText = null;
paraText = null;
paraText2 = null;
para = null;
root = null;
beforeEach(function() {
var head;
headText = document.createTextNode("My Heading");
paraText = document.createTextNode("My paragraph");
paraText2 = document.createTextNode(" continues");
head = document.createElement('h1');
head.appendChild(headText);
para = document.createElement('p');
para.appendChild(paraText);
para.appendChild(paraText2);
root = document.createElement('div');
root.appendChild(head);
return root.appendChild(para);
});
it("should exclude any nodes not within the bounding element.", function() {
var range;
range = new Range.NormalizedRange({
commonAncestor: root,
start: headText,
end: paraText2
});
range = range.limit(para);
assert.equal(range.commonAncestor, para);
assert.equal(range.start, paraText);
return assert.equal(range.end, paraText2);
});
return it("should return null if no nodes fall within the bounds", function() {
var otherDiv, range;
otherDiv = document.createElement('div');
range = new Range.NormalizedRange({
commonAncestor: root,
start: headText,
end: paraText2
});
return assert.equal(range.limit(otherDiv), null);
});
});
return describe("toRange", function() {
return it("should return a new Range object", function() {
var mockRange;
mockRange = {
setStartBefore: sinon.spy(),
setEndAfter: sinon.spy()
};
sinon.stub(document, 'createRange').returns(mockRange);
r.toRange();
assert(document.createRange.calledOnce);
assert(mockRange.setStartBefore.calledOnce);
assert.isTrue(mockRange.setStartBefore.calledWith(r.start));
assert(mockRange.setEndAfter.calledOnce);
assert.isTrue(mockRange.setEndAfter.calledWith(r.end));
return document.createRange.restore();
});
});
});
});
/*
//@ sourceMappingURL=range_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3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AAA,CAAM,GAAN,MAAA;CAVF,MAAgE;CAY7D,CAAH,CAA4D,MAAA,IAA5D,0CAAA;CACE,WAAA,GAAA;CAAA,EAAW,EAAA,GAAX,KAAW;CAAX,EACY,CAAA,CAAZ,GAAA,OAAY;CAAsB,CAChB,EADgB,MAChC,IAAA;CADgC,CAEzB,GAAP,GAFgC,EAEhC;CAFgC,CAG3B,CAAL,MAHgC,CAGhC;CAJF,SACY;CAKL,CAA6B,EAApC,CAAA,CAAM,EAAO,OAAb;CAPF,MAA4D;CAlC9D,IAAkB;CA2CT,CAAW,CAAA,KAApB,CAAA,EAAA;CACK,CAAH,CAAuC,MAAA,IAAvC,qBAAA;CACE,QAAA,GAAA;CAAA,EACE,KADF,CAAA;CACE,CAAgB,CAAA,EAAK,KAArB,IAAA;CAAA,CACa,CAAA,EAAK,KAAlB,CAAA;CAFF,SAAA;CAAA,CAIqB,EAArB,CAAK,EAAL,CAAA,CAAA,IAAA;CAJA,MAKA,CAAA;CALA,KAOA,EAAA,EAAA,CAA2B;CAP3B,KAQA,EAAA,CAAgB,CAAhB,IAA+B;CAR/B,IASc,CAAR,EAAN,CAAuB,CAAT,IAAwB;CATtC,KAUA,EAAA,CAAgB,CAAhB,CAA4B;CAV5B,EAWc,GAAR,EAAN,CAAuB,CAAT,CAAqB;CAE1B,MAAT,CAAQ,GAAY,IAApB;CAdF,MAAuC;CADzC,IAAoB;CA/DtB,EAA4B;CA1FZ"
}

View file

@ -1,127 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Util.flatten()', function() {
return it("flattens the contents of an Array", function() {
var flattened;
flattened = Util.flatten([[1, 2], 'lorem ipsum', [{}]]);
return assert.deepEqual(flattened, [1, 2, 'lorem ipsum', {}]);
});
});
describe('Util.getTextNodes()', function() {
var $fix;
$fix = null;
beforeEach(function() {
addFixture('textnodes');
return $fix = $(fix());
});
afterEach(function() {
return clearFixtures();
});
it("returns an element's textNode descendants", function() {
var expectation, node, nodes, text;
nodes = Util.getTextNodes($fix);
text = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
node = nodes[_i];
_results.push(node.nodeValue);
}
return _results;
})();
expectation = ['\n ', 'lorem ipsum', '\n ', 'dolor sit', '\n', '\n', 'dolor sit ', 'amet', '. humpty dumpty. etc.'];
return assert.deepEqual(text, expectation);
});
it("returns an empty jQuery collection when called in undefined node", function() {
var result;
result = Util.getTextNodes($(void 0));
assert.instanceOf(result, jQuery);
return assert.lengthOf(result, 0);
});
return it("returns an element's TextNodes after Text.splitText() text has been called", function() {
var first, fixture, para, text;
fixture = document.getElementById('fixtures') || $('body')[0];
fixture.innerHTML = '';
para = document.createElement('p');
text = document.createTextNode('this is a paragraph of text');
para.appendChild(text);
fixture.appendChild(para);
assert.lengthOf(para.childNodes, 1);
first = text.splitText(14);
assert.equal(first.nodeValue, 'graph of text');
assert.equal(text.nodeValue, 'this is a para');
assert.equal(para.firstChild.nodeValue, 'this is a para');
assert.equal(para.lastChild.nodeValue, 'graph of text');
return assert.lengthOf(Util.getTextNodes($(para)), 2);
});
});
describe('Util.xpathFromNode', function() {
var $fix;
$fix = null;
beforeEach(function() {
addFixture('xpath');
return $fix = $(fix());
});
afterEach(function() {
return clearFixtures();
});
it("generates an XPath string for an element's position in the document", function() {
var pathToFixHTML;
pathToFixHTML = '/html[1]/body[1]/div[1]';
assert.deepEqual(Util.xpathFromNode($fix.find('p')), [pathToFixHTML + '/p[1]', pathToFixHTML + '/p[2]']);
assert.deepEqual(Util.xpathFromNode($fix.find('span')), [pathToFixHTML + '/ol[1]/li[2]/span[1]']);
return assert.deepEqual(Util.xpathFromNode($fix.find('strong')), [pathToFixHTML + '/p[2]/strong[1]']);
});
return it("takes an optional parameter determining the element from which XPaths should be calculated", function() {
var ol;
ol = $fix.find('ol').get(0);
assert.deepEqual(Util.xpathFromNode($fix.find('li'), ol), ['/li[1]', '/li[2]', '/li[3]']);
return assert.deepEqual(Util.xpathFromNode($fix.find('span'), ol), ['/li[2]/span[1]']);
});
});
describe('Util.escape()', function() {
return it("should escape any HTML special characters into entities", function() {
return assert.equal(Util.escape('<>"&'), '&lt;&gt;&quot;&amp;');
});
});
describe('Util.uuid()', function() {
return it("should return a unique id on each call", function() {
var counter, current, results, _results;
counter = 100;
results = [];
_results = [];
while (counter--) {
current = Util.uuid();
assert.equal(results.indexOf(current), -1);
_results.push(results.push(current));
}
return _results;
});
});
describe('Util.preventEventDefault()', function() {
return it("should call prevent default if the method exists", function() {
var event;
event = {
preventDefault: sinon.spy()
};
Util.preventEventDefault(event);
assert(event.preventDefault.calledOnce);
assert.doesNotThrow((function() {
return Util.preventEventDefault(1);
}), Error);
assert.doesNotThrow((function() {
return Util.preventEventDefault(null);
}), Error);
return assert.doesNotThrow((function() {
return Util.preventEventDefault(void 0);
}), Error);
});
});
/*
//@ sourceMappingURL=util_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "util_spec.js",
"sourceRoot": "../..",
"sources": [
"test/spec/util_spec.coffee"
],
"names": [],
"mappings": ";AAAA,CAAS,CAAkB,CAAA,KAA3B,CAA2B,OAA3B;CACK,CAAH,CAAwC,MAAxC,0BAAA;CACE,OAAA,CAAA;CAAA,CAA6B,CAAjB,CAAZ,GAAY,EAAZ,IAAyB;CAClB,CAAqB,IAAtB,GAAN,EAAA,EAA4B;CAF9B,EAAwC;CADf;;AAK3B,CALA,CAKgC,CAAA,KAAhC,CAAgC,YAAhC;CACE,GAAA,EAAA;CAAA,CAAA,CAAO,CAAP;CAAA,CAEA,CAAW,MAAA,CAAX;CACE,GAAA,MAAA,CAAA;CACO,EAAA,CAAP,OAAA;CAFF,EAAW;CAFX,CAMA,CAAU,MAAV;CAAa,UAAA,EAAA;CAAb,EAAU;CANV,CAQA,CAAgD,MAAA,kCAAhD;CACE,OAAA,sBAAA;CAAA,EAAQ,CAAR,CAAA,OAAQ;CAAR,GACA;;AAAQ,CAAA;YAAA,gCAAA;0BAAA;CAAA,GAAI;CAAJ;;C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CAA6B,GAAD,EAAJ,OAAA,MAAA;CAAJ,CAA0C,GAAzC;CAPvB,EAAuD;CADlB"
}

View file

@ -1,196 +0,0 @@
// Generated by CoffeeScript 1.6.3
describe('Annotator.Viewer', function() {
var viewer;
viewer = null;
beforeEach(function() {
return viewer = new Annotator.Viewer();
});
afterEach(function() {
return viewer.element.remove();
});
it("should have an element property", function() {
assert.ok(viewer.element);
return assert.isTrue(viewer.element.hasClass('annotator-viewer'));
});
describe("an annotation element", function() {
it("should contain some controls", function() {
viewer.load([
{
text: "Hello there"
}
]);
return assert.operator(viewer.element.find('.annotator-controls:first button').length, '>', 0);
});
it("should NOT contain any controls if options.readOnly is true", function() {
viewer = new Annotator.Viewer({
readOnly: true
});
viewer.load([
{
text: "Hello there"
}
]);
return assert.lengthOf(viewer.element.find('.annotator-controls:first button'), 0);
});
it("should contain an external link to the annotation if the annotation provides one", function() {
viewer.load([
{
links: [
{
rel: "alternate",
href: "http://example.com/foo",
type: "text/html"
}
]
}
]);
return assert.equal(viewer.element.find('.annotator-controls:first a.annotator-link').attr('href'), 'http://example.com/foo');
});
return it("should NOT contain an external link to the annotation if the annotation doesn't provide one", function() {
viewer.load([
{
text: "Hello there"
}
]);
return assert.lengthOf(viewer.element.find('.annotator-controls:first a.annotator-link'), 0);
});
});
describe("events", function() {
beforeEach(function() {
return viewer.element.find('ul').append(viewer.html.item);
});
it("should call Viewer#onEditClick() when the edit button is clicked", function() {
sinon.spy(viewer, 'onEditClick');
viewer.element.find('.annotator-edit').click();
return assert(viewer.onEditClick.calledOnce);
});
return it("should call Viewer#onDeleteClick() when the delete button is clicked", function() {
sinon.spy(viewer, 'onDeleteClick');
viewer.element.find('.annotator-delete').click();
return assert(viewer.onDeleteClick.calledOnce);
});
});
describe("show", function() {
return it("should make the viewer visible", function() {
viewer.show();
return assert.isFalse(viewer.element.hasClass(viewer.classes.hide));
});
});
describe("isShown", function() {
it("should return true if the viewer is visible", function() {
viewer.show();
return assert.isTrue(viewer.isShown());
});
return it("should return false if the viewer is not visible", function() {
viewer.hide();
return assert.isFalse(viewer.isShown());
});
});
describe("hide", function() {
return it("should hide the viewer from view", function() {
viewer.hide();
return assert.isTrue(viewer.element.hasClass(viewer.classes.hide));
});
});
describe("load", function() {
beforeEach(function() {
viewer.annotations = [
{
text: 'test'
}
];
viewer.fields = [
{
element: $('<div />')[0],
load: sinon.spy()
}, {
element: $('<div />')[0],
load: sinon.spy()
}
];
return viewer.load([
{
text: 'Hello there'
}
]);
});
it("should call #show()", function() {
sinon.spy(viewer, 'show');
viewer.load();
return assert(viewer.show.calledOnce);
});
it("should set the current annotation", function() {
return assert.equal(viewer.annotations[0].text, 'Hello there');
});
it("should call the load callback on each field in the group", function() {
assert(viewer.fields[0].load.calledOnce);
return assert(viewer.fields[1].load.calledOnce);
});
return it("should pass the cloned field element and an annotation to the callback", function() {
var args;
args = viewer.fields[0].load.lastCall.args;
assert.equal(args[0], viewer.element.find('div:first')[0]);
assert.equal(args[1], viewer.annotations[0]);
assert.ok(args[2].showEdit);
assert.ok(args[2].hideEdit);
assert.ok(args[2].showDelete);
return assert.ok(args[2].hideDelete);
});
});
describe("addField", function() {
return it("should append a new field to the @fields property", function() {
var length;
length = viewer.fields.length;
viewer.addField();
assert.lengthOf(viewer.fields, length + 1);
viewer.addField();
return assert.lengthOf(viewer.fields, length + 2);
});
});
describe("onEditClick", function() {
return it("should call onButtonClick and provide an event to trigger", function() {
var event;
sinon.spy(viewer, 'onButtonClick');
event = {};
viewer.onEditClick(event);
assert(viewer.onButtonClick.calledOnce);
return assert.isTrue(viewer.onButtonClick.calledWith(event, 'edit'));
});
});
describe("onDeleteClick", function() {
return it("should call onButtonClick and provide an event to trigger", function() {
var event;
sinon.spy(viewer, 'onButtonClick');
event = {};
viewer.onDeleteClick(event);
assert(viewer.onButtonClick.calledOnce);
return assert.isTrue(viewer.onButtonClick.calledWith(event, 'delete'));
});
});
return describe("onButtonClick", function() {
var listener;
listener = null;
beforeEach(function() {
listener = sinon.spy();
return viewer.element.bind('edit', listener);
});
it("should trigger an 'edit' event", function() {
viewer.onButtonClick({}, 'edit');
return assert(listener.calledOnce);
});
return it("should pass in the annotation object associated with the item", function() {
var annotation, button, item;
annotation = {};
item = $('<div class="annotator-annotation" />').data('annotation', annotation);
button = $('<button />').appendTo(item)[0];
viewer.onButtonClick({
target: button
}, 'edit');
return assert.equal(listener.lastCall.args[1], annotation);
});
});
});
/*
//@ sourceMappingURL=viewer_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "viewer_spec.js",
"sourceRoot": "../..",
"sources": [
"test/spec/viewer_spec.coffee"
],
"names": [],
"mappings": ";AAAA,CAAS,CAAoB,CAAA,KAA7B,CAA6B,SAA7B;CACE,KAAA;CAAA,CAAA,CAAS,CAAT,EAAA;CAAA,CAEA,CAAW,MAAA,CAAX;CACyB,EAAV,CAAA,EAAb,GAAsB,EAAtB;CADF,EAAW;CAFX,CAKA,CAAU,MAAV;CACS,KAAD,CAAQ,IAAd;CADF,EAAU;CALV,CAQA,CAAsC,MAAA,wBAAtC;CACE,CAAA,EAAA,EAAM,CAAN;CACO,KAAD,CAAsB,CAAd,GAAd,OAAc;CAFhB,EAAsC;CARtC,CAYA,CAAkC,KAAlC,CAAkC,cAAlC;CACE,CAAA,CAAmC,CAAnC,KAAmC,qBAAnC;CACE,GAAA,EAAA;SAAa;CAAA,CAAO,EAAN,MAAA,GAAD;UAAD;CAAZ,OAAA;CACO,CAAyE,CAAhF,CAAgB,EAAV,CAAwB,CAA9B,KAAA,qBAAgB;CAFlB,IAAmC;CAAnC,CAIA,CAAkE,CAAlE,KAAkE,oDAAlE;CACE,EAAa,CAAA,EAAb,GAAsB;CAAQ,CAAU,EAAV,IAAA;CAA9B,OAAa;CAAb,GACA,EAAA;SAAa;CAAA,CAAO,EAAN,MAAA,GAAD;UAAD;CADZ,OACA;CACO,CAAkE,EAAzD,EAAV,CAAwB,CAA9B,KAAA,qBAAgB;CAHlB,IAAkE;CAJlE,CAS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qC;CAIlC,CAAH,CAAoE,MAAA,EAApE,oDAAA;CACE,SAAA,cAAA;CAAA,CAAA,CAAa,GAAb,IAAA;CAAA,CACsE,CAA7D,CAAT,EAAA,IAAS,EAAA,0BAAA;CADT,EAES,CAAA,EAAT,EAAS,IAAA;CAFT,KAIA,OAAA;CAAqB,CAAS,IAAR,EAAA;CAJtB,CAIuC,IAAvC,EAAA;CAIO,CAAiC,EAAJ,CAApC,CAAM,EAAe,EAArB,GAAA;CATF,IAAoE;CAXtE,EAA0B;CArIC"
}

View file

@ -1,213 +0,0 @@
// Generated by CoffeeScript 1.6.3
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
describe("Annotator.Widget", function() {
var widget;
widget = null;
beforeEach(function() {
var element;
element = $('<div />')[0];
return widget = new Annotator.Widget(element);
});
describe("constructor", function() {
return it("should extend the Widget#classes object with child classes", function() {
var ChildWidget, child, _ref;
ChildWidget = (function(_super) {
__extends(ChildWidget, _super);
function ChildWidget() {
_ref = ChildWidget.__super__.constructor.apply(this, arguments);
return _ref;
}
ChildWidget.prototype.classes = {
customClass: 'my-custom-class',
anotherClass: 'another-class'
};
return ChildWidget;
})(Annotator.Widget);
child = new ChildWidget();
return assert.deepEqual(child.classes, {
hide: 'annotator-hide',
invert: {
x: 'annotator-invert-x',
y: 'annotator-invert-y'
},
customClass: 'my-custom-class',
anotherClass: 'another-class'
});
});
});
describe("invertX", function() {
return it("should add the Widget#classes.invert.x class to the Widget#element", function() {
widget.element.removeClass(widget.classes.invert.x);
widget.invertX();
return assert.isTrue(widget.element.hasClass(widget.classes.invert.x));
});
});
describe("invertY", function() {
return it("should add the Widget#classes.invert.y class to the Widget#element", function() {
widget.element.removeClass(widget.classes.invert.y);
widget.invertY();
return assert.isTrue(widget.element.hasClass(widget.classes.invert.y));
});
});
describe("isInvertedY", function() {
return it("should return the vertical inverted status of the Widget", function() {
assert.isFalse(widget.isInvertedY());
widget.invertY();
return assert.isTrue(widget.isInvertedY());
});
});
describe("isInvertedX", function() {
return it("should return the horizontal inverted status of the Widget", function() {
assert.isFalse(widget.isInvertedX());
widget.invertX();
return assert.isTrue(widget.isInvertedX());
});
});
describe("resetOrientation", function() {
return it("should remove the Widget#classes.invert classes from the Widget#element", function() {
widget.element.addClass(widget.classes.invert.x).addClass(widget.classes.invert.y);
widget.resetOrientation();
assert.isFalse(widget.element.hasClass(widget.classes.invert.x));
return assert.isFalse(widget.element.hasClass(widget.classes.invert.y));
});
});
return describe("checkOrientation", function() {
var mocks;
mocks = [
{
window: {
width: 920,
scrollTop: 0,
scrollLeft: 0
},
element: {
offset: {
top: 300,
left: 0
},
width: 250
}
}, {
window: {
width: 920,
scrollTop: 0,
scrollLeft: 0
},
element: {
offset: {
top: 200,
left: 900
},
width: 250
}
}, {
window: {
width: 920,
scrollTop: 0,
scrollLeft: 0
},
element: {
offset: {
top: -100,
left: 0
},
width: 250
}
}, {
window: {
width: 920,
scrollTop: 0,
scrollLeft: 0
},
element: {
offset: {
top: -100,
left: 900
},
width: 250
}
}, {
window: {
width: 920,
scrollTop: 300,
scrollLeft: 0
},
element: {
offset: {
top: 200,
left: 0
},
width: 250
}
}, {
window: {
width: 750,
scrollTop: 0,
scrollLeft: 300
},
element: {
offset: {
top: 200,
left: 750
},
width: 250
}
}
];
beforeEach(function() {
var element, window, _ref;
_ref = mocks.shift(), window = _ref.window, element = _ref.element;
sinon.stub(jQuery.fn, 'init').returns({
width: sinon.stub().returns(window.width),
scrollTop: sinon.stub().returns(window.scrollTop),
scrollLeft: sinon.stub().returns(window.scrollLeft)
});
sinon.stub(widget.element, 'children').returns({
offset: sinon.stub().returns(element.offset),
width: sinon.stub().returns(element.width)
});
sinon.spy(widget, 'invertX');
sinon.spy(widget, 'invertY');
sinon.spy(widget, 'resetOrientation');
return widget.checkOrientation();
});
afterEach(function() {
return jQuery.fn.init.restore();
});
it("should reset the widget each time", function() {
assert(widget.resetOrientation.calledOnce);
assert.isFalse(widget.invertX.called);
return assert.isFalse(widget.invertY.called);
});
it("should invert the widget if it does not fit horizontally", function() {
assert(widget.invertX.calledOnce);
return assert.isFalse(widget.invertY.called);
});
it("should invert the widget if it does not fit vertically", function() {
assert.isFalse(widget.invertX.called);
return assert(widget.invertY.calledOnce);
});
it("should invert the widget if it does not fit horizontally or vertically", function() {
assert(widget.invertX.calledOnce);
return assert(widget.invertY.calledOnce);
});
it("should invert the widget if it does not fit vertically and the window is scrolled", function() {
assert.isFalse(widget.invertX.called);
return assert(widget.invertY.calledOnce);
});
return it("should invert the widget if it fits horizontally due to the window scrolled", function() {
assert.isFalse(widget.invertX.called);
return assert.isFalse(widget.invertY.called);
});
});
});
/*
//@ sourceMappingURL=widget_spec.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "widget_spec.js",
"sourceRoot": "../..",
"sources": [
"test/spec/widget_spec.coffee"
],
"names": [],
"mappings": ";AAAA,IAAA;kSAAA;;AAAA,CAAA,CAA6B,CAAA,KAA7B,CAA6B,SAA7B;CACE,KAAA;CAAA,CAAA,CAAS,CAAT,EAAA;CAAA,CAEA,CAAW,MAAA,CAAX;CACE,MAAA,CAAA;CAAA,EAAU,CAAV,GAAA,EAAU;CACc,EAAV,CAAA,EAAd,CAAc,EAAS,EAAvB;CAFF,EAAW;CAFX,CAMA,CAAwB,KAAxB,CAAwB,IAAxB;CACK,CAAH,CAAiE,MAAA,EAAjE,iDAAA;CACE,SAAA,cAAA;CAAA,KAAM;CACJ;;;;;CAAA;;CAAA,EACE,IADF;CACE,CAAa,QAAb,CAAA,MAAA;CAAA,CACc,QAAd,EAAA,GADA;CADF,SAAA;;CAAA;;CADwB,QAAS;CAAnC,EAKY,CAAA,CAAZ,CAAA,KAAY;CACL,CAAyB,GAAV,CAAhB,CAAN,EAAA,IAAA;CAAgC,CACxB,EAAN,IAAA,Q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,KAA6D,+CAA7D;CACE,KAAA,CAAA;CACO,KAAP,CAAqB,GAArB,GAAA;CAFF,IAA6D;CAjE7D,CAqEA,CAA6E,CAA7E,KAA6E,+DAA7E;CACE,KAAA,CAAqB,GAArB;CACO,KAAP,CAAqB,GAArB,GAAA;CAFF,IAA6E;CArE7E,CAyEA,CAAwF,CAAxF,KAAwF,0EAAxF;CACE,KAAA,CAAA;CACO,KAAP,CAAqB,GAArB,GAAA;CAFF,IAAwF;CAIrF,CAAH,CAAkF,MAAA,EAAlF,kEAAA;CACE,KAAA,CAAA;CACO,KAAD,CAAN,MAAA;CAFF,IAAkF;CA9EpF,EAA6B;CA1DF"
}

View file

@ -1,160 +0,0 @@
// Generated by CoffeeScript 1.6.3
var $, Util, gettext, _gettext, _ref, _t;
gettext = null;
if (typeof Gettext !== "undefined" && Gettext !== null) {
_gettext = new Gettext({
domain: "annotator"
});
gettext = function(msgid) {
return _gettext.gettext(msgid);
};
} else {
gettext = function(msgid) {
return msgid;
};
}
_t = function(msgid) {
return gettext(msgid);
};
if (!(typeof jQuery !== "undefined" && jQuery !== null ? (_ref = jQuery.fn) != null ? _ref.jquery : void 0 : void 0)) {
console.error(_t("Annotator requires jQuery: have you included lib/vendor/jquery.js?"));
}
if (!(JSON && JSON.parse && JSON.stringify)) {
console.error(_t("Annotator requires a JSON implementation: have you included lib/vendor/json2.js?"));
}
$ = jQuery;
Util = {};
Util.flatten = function(array) {
var flatten;
flatten = function(ary) {
var el, flat, _i, _len;
flat = [];
for (_i = 0, _len = ary.length; _i < _len; _i++) {
el = ary[_i];
flat = flat.concat(el && $.isArray(el) ? flatten(el) : el);
}
return flat;
};
return flatten(array);
};
Util.contains = function(parent, child) {
var node;
node = child;
while (node != null) {
if (node === parent) {
return true;
}
node = node.parentNode;
}
return false;
};
Util.getTextNodes = function(jq) {
var getTextNodes;
getTextNodes = function(node) {
var nodes;
if (node && node.nodeType !== Node.TEXT_NODE) {
nodes = [];
if (node.nodeType !== Node.COMMENT_NODE) {
node = node.lastChild;
while (node) {
nodes.push(getTextNodes(node));
node = node.previousSibling;
}
}
return nodes.reverse();
} else {
return node;
}
};
return jq.map(function() {
return Util.flatten(getTextNodes(this));
});
};
Util.xpathFromNode = function(el, relativeRoot) {
var exception, result;
try {
result = simpleXPathJQuery.call(el, relativeRoot);
} catch (_error) {
exception = _error;
console.log("jQuery-based XPath construction failed! Falling back to manual.");
result = simpleXPathPure.call(el, relativeRoot);
}
return result;
};
Util.nodeFromXPath = function(xp, root) {
var idx, name, node, step, steps, _i, _len, _ref1;
steps = xp.substring(1).split("/");
node = root;
for (_i = 0, _len = steps.length; _i < _len; _i++) {
step = steps[_i];
_ref1 = step.split("["), name = _ref1[0], idx = _ref1[1];
idx = idx != null ? parseInt((idx != null ? idx.split("]") : void 0)[0]) : 1;
node = findChild(node, name.toLowerCase(), idx);
}
return node;
};
Util.escape = function(html) {
return html.replace(/&(?!\w+;)/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
};
Util.uuid = (function() {
var counter;
counter = 0;
return function() {
return counter++;
};
})();
Util.getGlobal = function() {
return (function() {
return this;
})();
};
Util.maxZIndex = function($elements) {
var all, el;
all = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = $elements.length; _i < _len; _i++) {
el = $elements[_i];
if ($(el).css('position') === 'static') {
_results.push(-1);
} else {
_results.push(parseInt($(el).css('z-index'), 10) || -1);
}
}
return _results;
})();
return Math.max.apply(Math, all);
};
Util.mousePosition = function(e, offsetEl) {
var offset;
offset = $(offsetEl).position();
return {
top: e.pageY - offset.top,
left: e.pageX - offset.left
};
};
Util.preventEventDefault = function(event) {
return event != null ? typeof event.preventDefault === "function" ? event.preventDefault() : void 0 : void 0;
};
/*
//@ sourceMappingURL=util.map
*/

View file

@ -1,10 +0,0 @@
{
"version": 3,
"file": "util.js",
"sourceRoot": "..",
"sources": [
"src/util.coffee"
],
"names": [],
"mappings": ";AACA,IAAA,gCAAA;;AAA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AJ;CACE,KAAA,CAAA;CAAA,CAAA,CAAA;;AAAM,CAAA;UAAA,sCAAA;0BAAA;CACE,CAAG,CAAA,CAAA,CAAyB,CAA5B,EAAA,EAAG;AACA,CAAD;MADF,EAAA;AAGyC,CAAvC,CAAS,CAAA,CAA6B,IAAtC,CAAS;QAJb;CAAA;;CAAN;CAKK,CAAgB,CAAb,CAAJ,CAAJ,IAAA;CANe;;AAQjB,CA5GA,CA4GyB,CAAJ,CAAjB,IAAiB,CAAC,IAAtB;CACE,KAAA;CAAA,CAAA,CAAS,GAAT,EAAS;SACT;CAAA,CACQ,CAAN,CAAA,CAAM,CAAgB;CADxB,CAEQ,CAAU,CAAhB,CAAM,CAAgB;CAJL;CAAA;;AAYrB,CAxHA,EAwH2B,CAAvB,CAAuB,IAAC,UAA5B;CACS,EAAP,EAAK;CADoB"
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more