2015-08-11 4 views
-1

Как использовать скрипт аннотатора? простой пример создавать, обновлять, удалять, извлекать.Мне нужен пример о Annotator.js

$('#content').annotator('addPlugin', 'Store', { 
    urls: { 
    // These are the default URLs. 
    create: '/annotations', 
    update: '/annotations/:id', 
    destroy: '/annotations/:id', 
    search: '/search' 
    } 
}): 
+1

Привет, этот сайт не для того, чтобы приводить примеры. Это потому, что вы пытались что-то сделать и застряли. Пройдите экскурсию по [секции помощи] (http://stackoverflow.com/help), чтобы узнать, какие вопросы вы можете задать – Pete

ответ

2

Этот пример показывает, как использовать Annotator.js и как связать с ней два плагина, «в автономном режиме» и «потрогать», для постоянного хранения в автономном режиме аннотаций и заставить его работать на сенсорных устройствах:

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset=utf-8 /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title>Annotator Touch Plugin</title> 
    <link rel="stylesheet" href="annotator.min.css" /> 
    <link rel="stylesheet" href="annotator.touch.css" /> 
    <style>body { font-size: 1.6em }</style> 
</head> 
<body> 
<p>Current Connectivity: <span id="status"></span></p> 
    <p><button id="clear-storage">Clear LocalStorage</button></p> 
    <div id="content"> 
    <p>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked.</p> 

    <p>"What's happened to me?" he thought. It wasn't a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.</p> 

    <p>Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was. He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before.</p> 
    </div> 
    <script src="jquery.js"></script> 
    <script src="highlighter.js"></script> 
    <script src="annotator-full.min.js"></script> 
    <script src="annotator.touch.min.js"></script> 
    <script src="annotator.offline.min.js"></script> 
    <script> 
    jQuery("#content").annotator().annotator('addPlugin', 'Touch', { 
     force: location.search.indexOf('force') > -1, 
     useHighlighter: location.search.indexOf('highlighter') > -1 
    }); 

    jQuery("#content").annotator().annotator('addPlugin', 'Offline', { 
     online: function() { 
     jQuery("#status").text("Online"); 
     }, 
     offline: function() { 
     jQuery("#status").text("Offline"); 
     } }); 

    jQuery("#clear-storage").click(function() { 
     if (annotator) { 
     annotator.plugins.Offline.store.clear() 
     } 
    }); 

    if (!Annotator.Plugin.Touch.isTouchDevice()) { 
     if (location.search.indexOf('force') > -1) { 
     jQuery("body").prepend('<p><a href="./index.html">Disable Plugin in Desktop Browser</a></p>'); 
     } else { 
     jQuery("body").prepend('<p><a href="./index.html?force">Enable Plugin in Desktop Browser</a></p>'); 
     } 
    } 

    var annotator = jQuery("#content").data('annotator'); 
    </script> 
</body> 
</html> 

Пожалуйста, обратите внимание, что все эти файлы должны находиться в одной папке:

CSS:

  • апп otator.min.css
  • annotator.touch.css

JS:

  • jquery.js
  • highlighter.js
  • Annotator-full.min.js
  • Annotator .touch.min.js
  • annotator.offline.min.js

(highlighter.js находится в папке VENDOR плагина annotator.touch)

Смежные вопросы