notes.html 8.04 KB
Newer Older
1 2
<%! from django.utils.translation import ugettext as _ %>

3
<%namespace name='static' file='static_content.html'/>
4 5
${static.css(group='style-vendor-tinymce-content', raw=True)}
${static.css(group='style-vendor-tinymce-skin', raw=True)}
6
${static.css(group='style-xmodule-annotations', raw=True)}
7
<%inherit file="main.html" />
8 9 10
<%!
    from django.core.urlresolvers import reverse
%>
11 12

<%block name="headextra">
13 14 15 16
<%static:css group='style-course-vendor'/>
<%static:css group='style-course'/>
<%static:js group='courseware'/>

Arthur Barrett committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<style type="text/css">
    blockquote {
        background:#f9f9f9;
        border-left:10px solid #ccc;
        margin:1.5em 10px;
        padding:.5em 10px;
    }
    blockquote:before {
        color:#ccc;
        content:'“';
        font-size:4em;
        line-height:.1em;
        margin-right:.25em;
        vertical-align:-.4em;
    }
    blockquote p {
        display:inline;
    }
    .notes-wrapper {
        padding: 32px 40px;
    }
    .note {
        border-bottom: 1px solid #ccc;
        padding: 0 0 1em 0;
    }
    .note .text {
        margin-bottom: 1em;
    }
    .note ul.meta {
        margin: .5em 0;
    }
    .note ul.meta li {
        font-size: .9em;
        margin-bottom: .5em;
    }
</style>

54 55 56 57 58 59 60 61 62 63 64
</%block>

<%block name="js_extra">
  <script type="text/javascript">
  </script>
</%block>

<%include file="/courseware/course_navigation.html" args="active_page='notes'" />

<section class="container">
    <div class="notes-wrapper">
65 66
        <h1>${_('My Notes')}</h1>
        <div id="notesHolder"></div>
daniel cebrian committed
67
        <section id="catchDIV">
68
            <div class="annotationListContainer">${_('You do not have any notes.')}</div>
daniel cebrian committed
69
        </section>
70
        <script>
71 72 73
    // TODO: Fix indentation in the following block
    (function (require) {
        var init = function() {
74 75 76 77
        //Grab uri of the course
        var parts = window.location.href.split("/"),
            uri = '';
        for (var index = 0; index <= 6; index += 1) uri += parts[index]+"/"; //Get the unit url
daniel cebrian committed
78
        var pagination = 100,
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
            is_staff = false,
            options = {
                optionsAnnotator: {
                    permissions:{
                        user: {
                            id:"${student.email}",
                            name:"${student.username}"
                        },
                        userString: function (user) {
                            if (user && user.name)
                                return user.name;
                            return user;
                        },
                        userId: function (user) {
                            if (user && user.id)
                                return user.id;
                            return user;
                        },
                        permissions: {
                                'read':   [],
                                'update': ["${student.email}"],
                                'delete': ["${student.email}"],
                                'admin':  ["${student.email}"]
                        },
                        showViewPermissionsCheckbox: true,
                        showEditPermissionsCheckbox: false,
                        userAuthorize: function(action, annotation, user) {
                            var token, tokens, _i, _len;
                            if (annotation.permissions) {
                              tokens = annotation.permissions[action] || [];
                              if (is_staff){
110
                                  return true;
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
                              }
                              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;
                          },
                    },
                    auth: {
136
                        token: "${token}"
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
                    },
                    store: {
                        // The endpoint of the store on your server.
                        prefix: "${storage}",

                        annotationData: {},

                        urls: {
                            // These are the default URLs.
                            create:  '/create',
                            read:    '/read/:id',
                            update:  '/update/:id',
                            destroy: '/delete/:id',
                            search:  '/search'
                        },

                        loadFromSearch:{
                            limit:pagination,
                            offset:0,
                            uri:uri
daniel cebrian committed
157
                        }
158 159 160 161 162 163 164 165
                    },
                },
                optionsVideoJS: {techOrder: ["html5","flash","youtube"]},
                optionsRS: {},
                optionsOVA: {posBigNew:'none'},
                optionsRichText: {
                    tinymce:{
                        selector: "li.annotator-item textarea",
166
                        plugins: "media image codemirror",
167 168 169
                        menubar: false,
                        toolbar_items_size: 'small',
                        extended_valid_elements : "iframe[src|frameborder|style|scrolling|class|width|height|name|align|id]",
170
                        toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | image rubric | code ",
daniel cebrian committed
171 172
                    }
                },
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
                auth: {
                    token: "${token}"
                },
                store: {
                    // The endpoint of the store on your server.
                    prefix: "${storage}",

                    annotationData: {},

                    urls: {
                        // These are the default URLs.
                        create:  '/create',
                        read:    '/read/:id',
                        update:  '/update/:id',
                        destroy: '/delete/:id',
                        search:  '/search'
                    },
                }
191
            };
daniel cebrian committed
192

193 194 195 196 197 198 199 200 201
        var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/";
        //remove old instances
        if (Annotator._instances.length !== 0) {
            $('#notesHolder').annotator("destroy");
        }
        delete ova;
        //Load the plugin Video/Text Annotation
        var ova = new OpenVideoAnnotation.Annotator($('#notesHolder'),options);

202 203 204 205
        // TODO: Fix to avoid using global scope!
        window.options = options;
        window.ova = ova;
        // END TODO
206 207 208 209 210 211 212 213 214 215

        //Catch
        var annotator = ova.annotator,
            catchOptions = {
                media:'text',
                externalLink:true,
                imageUrlRoot:imgURLRoot,
                showMediaSelector: true,
                showPublicPrivate: true,
                pagination:pagination,//Number of Annotations per load in the pagination,
216 217
                flags:is_staff,
                default_tab: "${default_tab}",
daniel cebrian committed
218
            },
219
            Catch = new CatchAnnotation($('#catchDIV'),catchOptions);
220 221 222 223 224 225 226 227 228 229
            // TODO: Fix to avoid using global scope!
            window.Catch = Catch;
            // END TODO
        };
        try {
            require(["ova"], init);
        } catch(error) {
            console.log("Error: " + error.message + " - Annotator not loaded in LMS.");
        }
    }).call(this, require || RequireJS.require);
daniel cebrian committed
230
        </script>
231 232 233
    </div>
</section>