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

3
<%namespace name='static' file='static_content.html'/>
4 5 6 7
${static.css(group='style-vendor-tinymce-content', raw=True)}
${static.css(group='style-vendor-tinymce-skin', raw=True)}
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js', raw=True)}"></script>
 <script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', raw=True)}" ></script>
8
<%inherit file="main.html" />
9 10 11
<%!
    from django.core.urlresolvers import reverse
%>
12 13

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

Arthur Barrett committed
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 54
<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>

55 56 57 58 59 60 61 62 63 64 65
</%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">
66 67
        <h1>${_('My Notes')}</h1>
        <div id="notesHolder"></div>
daniel cebrian committed
68
        <section id="catchDIV">
69
            <div class="annotationListContainer">${_('You do not have any notes.')}</div>
daniel cebrian committed
70
        </section>
71 72 73 74 75 76
        <script>

        //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
77
        var pagination = 100,
78 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
            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){
109
                                  return true;
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
                              }
                              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: {
135
                        token: "${token}"
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
                    },
                    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
156
                        }
157 158 159 160 161 162 163 164
                    },
                },
                optionsVideoJS: {techOrder: ["html5","flash","youtube"]},
                optionsRS: {},
                optionsOVA: {posBigNew:'none'},
                optionsRichText: {
                    tinymce:{
                        selector: "li.annotator-item textarea",
165
                        plugins: "media image codemirror",
166 167 168
                        menubar: false,
                        toolbar_items_size: 'small',
                        extended_valid_elements : "iframe[src|frameborder|style|scrolling|class|width|height|name|align|id]",
169
                        toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | image rubric | code ",
daniel cebrian committed
170 171
                    }
                },
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
                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'
                    },
                }
190
            };
daniel cebrian committed
191

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
        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);


        //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,
211 212
                flags:is_staff,
                default_tab: "${default_tab}",
daniel cebrian committed
213
            },
214
            Catch = new CatchAnnotation($('#catchDIV'),catchOptions);
daniel cebrian committed
215
        </script>
216 217 218
    </div>
</section>