Exemplo n.º 1
0
    controller: function(context) {
        var self = this;
        self.context = context;
        self.file = self.context.file;
        self.node = self.context.node;
        self.editorMeta = self.context.editor;
        self.isLatestVersion = false;

        self.selectLatest = function() {
            self.isLatestVersion = true;
        };
        if (self.file.provider === 'osfstorage') {
            self.canEdit = function() {
                return ((!self.file.checkoutUser) || (self.file.checkoutUser === self.context.currentUser.id)) ? self.context.currentUser.canEdit : false;
            };
            if (self.file.isPreregCheckout){
                m.render(document.getElementById('alertBar'), m('.alert.alert-warning[role="alert"]', m('span', [
                    m('strong', 'File is checked out.'),
                    ' This file has been checked out by a COS Preregistration Challenge Reviewer and will become available when review is complete.',
                ])));
            } else if ((self.file.checkoutUser) && (self.file.checkoutUser !== self.context.currentUser.id)) {
                m.render(document.getElementById('alertBar'), m('.alert.alert-warning[role="alert"]', m('span', [
                    m('strong', 'File is checked out.'),
                    ' This file has been checked out by a ',
                    m('a[href="/' + self.file.checkoutUser + '"]', 'collaborator'),
                    '. It needs to be checked in before any changes can be made.'
                ])));
            }
        } else if (self.file.provider === 'bitbucket' || self.file.provider === 'gitlab' || self.file.provider === 'onedrive') {
            self.canEdit = function() { return false; };  // Bitbucket, OneDrive, and GitLab are read-only
        } else {
            self.canEdit = function() {
                return self.context.currentUser.canEdit;
            };
        }

        $.extend(self.file.urls, {
            delete: waterbutler.buildDeleteUrl(self.file.path, self.file.provider, self.node.id, {waterbutlerURL: self.node.urls.waterbutler}),
            metadata: waterbutler.buildMetadataUrl(self.file.path, self.file.provider, self.node.id, {waterbutlerURL: self.node.urls.waterbutler}),
            revisions: waterbutler.buildRevisionsUrl(self.file.path, self.file.provider, self.node.id, {waterbutlerURL: self.node.urls.waterbutler}),
            content: waterbutler.buildDownloadUrl(self.file.path, self.file.provider, self.node.id, {waterbutlerURL: self.node.urls.waterbutler, direct: true, mode: 'render'})
        });

        if ($osf.urlParams().branch) {
            var fileWebViewUrl = waterbutler.buildMetadataUrl(self.file.path, self.file.provider, self.node.id, {waterbutlerURL: self.node.urls.waterbutler, branch: $osf.urlParams().branch});
            $.ajax({
                dataType: 'json',
                async: true,
                url: fileWebViewUrl,
                beforeSend: $osf.setXHRAuthorization
            }).done(function(response) {
                window.contextVars.file.urls.external = response.data.attributes.extra.webView;
            });

            if (self.file.provider === 'github') {
                self.file.urls.revisions = waterbutler.buildRevisionsUrl(
                    self.file.path, self.file.provider, self.node.id,
                    {sha: $osf.urlParams().branch}
                );
            }
            else if (self.file.provider === 'bitbucket' || self.file.provider === 'gitlab') {
                self.file.urls.revisions = waterbutler.buildRevisionsUrl(
                    self.file.path, self.file.provider, self.node.id,
                    {branch: $osf.urlParams().branch}
                );
            }
            self.file.urls.content = waterbutler.buildDownloadUrl(self.file.path, self.file.provider, self.node.id, {direct: true, mode: 'render', branch: $osf.urlParams().branch, waterbutlerURL: self.node.urls.waterbutler});
        }

        $(document).on('fileviewpage:delete', function() {
            var title = 'Delete file?';
            var message = '<p class="overflow">' +
                    'Are you sure you want to delete <strong>' +
                    self.file.safeName + '</strong>?' + '</p>';


            bootbox.confirm({
                title: title,
                message: message,
                callback: function(confirm) {
                    if (!confirm) {
                        return;
                    }
                    $.ajax({
                        type: 'DELETE',
                        url: self.file.urls.delete,
                        beforeSend: $osf.setXHRAuthorization
                    }).done(function() {
                        window.location = self.node.urls.files;
                    }).fail(function() {
                        $osf.growl('Error', 'Could not delete file.');
                    });
                },
                buttons:{
                    confirm:{
                        label:'Delete',
                        className:'btn-danger'
                    }
                }
            });
        });
        $(document).on('fileviewpage:checkout', function() {
            bootbox.confirm({
                title: 'Confirm file check out?',
                message: 'This would mean ' +
                    'other contributors cannot edit, delete or upload new versions of this file ' +
                    'as long as it is checked out. You can check it back in at anytime.',
                callback: function(confirm) {
                    if (!confirm) {
                        return;
                    }
                    var url = window.contextVars.apiV2Prefix + 'files' + self.file.path + '/';
                    $osf.ajaxJSON('PUT', url, {
                        data: {
                            data: {
                                id: self.file.path.replace('/', ''),
                                type: 'files',
                                attributes: {
                                    checkout: self.context.currentUser.id
                                }
                            }
                        },
                        isCors: true
                    }).done(function(resp) {
                        window.location.reload();
                    }).fail(function(resp) {
                        $osf.growl('Error', 'Unable to check out file');
                    });
                },
                buttons:{
                    confirm:{
                        label: 'Check out file',
                        className: 'btn-warning'
                    }
                }
            });
        });
        $(document).on('fileviewpage:checkin', function() {
            var url = window.contextVars.apiV2Prefix + 'files' + self.file.path + '/';
            $osf.ajaxJSON('PUT', url, {
                data: {
                    data: {
                        id: self.file.path.replace('/', ''),
                        type: 'files',
                        attributes: {
                            checkout: null
                        }
                    }
                },
                isCors: true
            }).done(function(resp) {
                window.location.reload();
            }).fail(function(resp) {
                $osf.growl('Error', 'Unable to check in file');
            });
        });
        $(document).on('fileviewpage:force_checkin', function() {
            bootbox.confirm({
                title: 'Force check in file?',
                message: 'This will check in the file for all users, allowing it to be edited. Are you sure?',
                buttons: {
                    confirm:{
                        label: 'Force check in',
                        className: 'btn-danger'
                    }
                },
                callback: function(confirm) {
                    if (!confirm) {
                        return;
                    }
                    var url = window.contextVars.apiV2Prefix + 'files' + self.file.path + '/';
                    $.ajaxJSON('PUT', url, {
                        data: {
                            data: {
                                id: self.file.path.replace('/', ''),
                                type: 'files',
                                attributes: {
                                    checkout: null
                                }
                            }
                        },
                        isCors: true
                    }).done(function(resp) {
                        window.location.reload();
                    }).fail(function(resp) {
                        $osf.growl('Error', 'Unable to force check in file. Make sure you have admin privileges.');
                    });
                }

            });
        });

        self.shareJSObservables = {
            activeUsers: m.prop([]),
            status: m.prop('connecting'),
            userId: self.context.currentUser.id
        };

        self.editHeader = function() {
            return m('.row', [
                m('.col-sm-12', m('span[style=display:block;]', [
                    m('h3.panel-title',[m('i.fa.fa-pencil-square-o'), '   Edit ']),
                    m('.pull-right', [
                        m('.progress.no-margin.pointer', {
                            'data-toggle': 'modal',
                            'data-target': '#' + self.shareJSObservables.status() + 'Modal'
                        }, [
                            m('.progress-bar.p-h-sm.progress-bar-success', {
                                connected: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-success'
                                },
                                connecting: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-warning progress-bar-striped active'
                                },
                                saving: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-info progress-bar-striped active'
                                }
                            }[self.shareJSObservables.status()] || {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-danger'
                                }, [
                                    m('span.progress-bar-content', [
                                        {
                                            connected: 'Live editing mode ',
                                            connecting: 'Attempting to connect ',
                                            unsupported: 'Unsupported browser ',
                                            saving: 'Saving... '
                                        }[self.shareJSObservables.status()] || 'Unavailable: Live editing ',
                                        m('i.fa.fa-question-circle.fa-large')
                                    ])
                                ])
                            ])
                        ])
                    ]))
                ]);
        };


        // Hack to delay creation of the editor
        // until we know this is the current file revision
        self.enableEditing = function() {
            // Sometimes we can get here twice, check just in case
            if (self.editor || !self.canEdit()) {
                m.redraw(true);
                return;
            }
            var fileType = mime.lookup(self.file.name.toLowerCase());
            // Only allow files < 200kb to be editable (should sync with MFR limit)
            // No files on figshare are editable.
            if (self.file.size < 204800 && fileType && self.file.provider !== 'figshare') { //May return false
                var editor = EDITORS[fileType.split('/')[0]];
                if (editor) {
                    self.editor = new Panel('Edit', self.editHeader, editor, [self.file.urls.content, self.file.urls.sharejs, self.editorMeta, self.shareJSObservables], false);
                }
            }
            m.redraw(true);
        };

        //Hack to polyfill the Panel interface
        //Ran into problems with mithrils caching messing up with multiple "Panels"
        self.revisions = m.component(FileRevisionsTable, self.file, self.node, self.enableEditing, self.canEdit, self.selectLatest);
        self.revisions.selected = false;
        self.revisions.title = 'Revisions';

        // inform the mfr of a change in display size performed via javascript,
        // otherwise the mfr iframe will not update unless the document windows is changed.
        self.triggerResize = $osf.throttle(function () {
            $(document).trigger('fileviewpage:resize');
        }, 1000);

        self.mfrIframeParent = $('#mfrIframeParent');
        function toggleRevisions(e){
            if(self.editor){
                self.editor.selected = false;
            }
            var viewable = self.mfrIframeParent.is(':visible');
            var url = '';
            if (viewable){
                self.mfrIframeParent.toggle();
                self.revisions.selected = true;
                url = formatUrl(self.urlParams, 'revision');
            } else {
                self.mfrIframeParent.toggle();
                self.revisions.selected = false;
                url = formatUrl(self.urlParams, 'view');
            }
            var state = {
                scrollTop: $(window).scrollTop(),
            };
            History.pushState(state, 'OSF | ' + window.contextVars.file.name, url);
        }

        function changeVersionHeader(){
            document.getElementById('versionLink').style.display = 'inline';
            m.render(document.getElementById('versionLink'), m('a', {onclick: toggleRevisions}, document.getElementById('versionLink').innerHTML));
        }

        self.urlParams = $osf.urlParams();
        // The parser found a query so lets check what we need to do
        if ('show' in self.urlParams){
            if(self.urlParams.show === 'revision'){
                self.mfrIframeParent.toggle();
                self.revisions.selected = true;
            } else if (self.urlParams.show === 'view' || self.urlParams.show === 'edit'){
               self.revisions.selected = false;
           }
        }

        if(self.file.provider === 'osfstorage'){
            changeVersionHeader();
        }

        self.enableEditing();
    },
Exemplo n.º 2
0
    controller: function(context) {
        var self = this;
        self.context = context;
        self.file = self.context.file;
        self.node = self.context.node;
        self.editorMeta = self.context.editor;
        self.file.checkoutUser = null;
        self.requestDone = false;
        self.isCheckoutUser = function() {
            $.ajax({
                method: 'get',
                url: window.contextVars.apiV2Prefix + 'files' + self.file.path + '/',
                beforeSend: $osf.setXHRAuthorization
            }).done(function(resp) {
                self.requestDone = true;
                self.file.checkoutUser = resp.data.relationships.checkout ? ((resp.data.relationships.checkout.links.related.href).split('users/')[1]).replace('/', ''): null;
                if ((self.file.checkoutUser) && (self.file.checkoutUser !== self.context.currentUser.id)) {
                    m.render(document.getElementById('alertBar'), m('.alert.alert-warning[role="alert"]', m('span', [
                        m('strong', 'File is checked out.'),
                        ' This file has been checked out by a ',
                        m('a[href="/' + self.file.checkoutUser + '"]', 'collaborator'),
                        '. It needs to be checked in before any changes can be made.'
                    ])));
                }
            });
        };
        if (self.file.provider === 'osfstorage'){
            self.canEdit = function() {
                return ((!self.file.checkoutUser) || (self.file.checkoutUser === self.context.currentUser.id)) ? self.context.currentUser.canEdit : false;
            };
            self.isCheckoutUser();
        } else {
            self.requestDone = true;
            self.canEdit = function() {
                return self.context.currentUser.canEdit;
            };
        }

        $.extend(self.file.urls, {
            delete: waterbutler.buildDeleteUrl(self.file.path, self.file.provider, self.node.id),
            metadata: waterbutler.buildMetadataUrl(self.file.path, self.file.provider, self.node.id),
            revisions: waterbutler.buildRevisionsUrl(self.file.path, self.file.provider, self.node.id),
            content: waterbutler.buildDownloadUrl(self.file.path, self.file.provider, self.node.id, {accept_url: false, mode: 'render'})
        });

        if ($osf.urlParams().branch) {
            var fileWebViewUrl = waterbutler.buildMetadataUrl(self.file.path, self.file.provider, self.node.id, {branch : $osf.urlParams().branch});
            $.ajax({
                dataType: 'json',
                async: true,
                url: fileWebViewUrl,
                beforeSend: $osf.setXHRAuthorization 
            }).done(function(response) {
                window.contextVars.file.urls.external = response.data.extra.webView;
            });
            self.file.urls.revisions = waterbutler.buildRevisionsUrl(self.file.path, self.file.provider, self.node.id, {sha: $osf.urlParams().branch});
            self.file.urls.content = waterbutler.buildDownloadUrl(self.file.path, self.file.provider, self.node.id, {accept_url: false, mode: 'render', branch: $osf.urlParams().branch});
        }

        $(document).on('fileviewpage:delete', function() {
            bootbox.confirm({
                title: 'Delete file?',
                message: '<p class="overflow">' +
                        'Are you sure you want to delete <strong>' +
                        self.file.safeName + '</strong>?' +
                    '</p>',
                callback: function(confirm) {
                    if (!confirm) {
                        return;
                    }
                    $.ajax({
                        type: 'DELETE',
                        url: self.file.urls.delete,
                        beforeSend: $osf.setXHRAuthorization
                    }).done(function() {
                        window.location = self.node.urls.files;
                    }).fail(function() {
                        $osf.growl('Error', 'Could not delete file.');
                    });
                },
                buttons:{
                    confirm:{
                        label:'Delete',
                        className:'btn-danger'
                    }
                }
            });
        });
        $(document).on('fileviewpage:checkout', function() {
            bootbox.confirm({
                title: 'Confirm file check out?',
                message: 'This would mean ' +
                    'other contributors cannot edit, delete or upload new versions of this file ' +
                    'as long as it is checked out. You can check it back in at anytime.',
                callback: function(confirm) {
                    if (!confirm) {
                        return;
                    }
                    $.ajax({
                        method: 'put',
                        url: window.contextVars.apiV2Prefix + 'files' + self.file.path + '/',
                        beforeSend: $osf.setXHRAuthorization,
                        contentType: 'application/json',
                        dataType: 'json',
                        data: JSON.stringify({
                            data: {
                                id: self.file.path.replace('/', ''),
                                type: 'files',
                                attributes: {
                                    checkout: self.context.currentUser.id
                                }
                            }
                        })
                    }).done(function(resp) {
                        window.location.reload();
                    }).fail(function(resp) {
                        $osf.growl('Error', 'Unable to check out file');
                    });
                },
                buttons:{
                    confirm:{
                        label: 'Check out file',
                        className: 'btn-warning'
                    }
                }
            });
        });
        $(document).on('fileviewpage:checkin', function() {
            $.ajax({
                method: 'put',
                url: window.contextVars.apiV2Prefix + 'files' + self.file.path + '/',
                beforeSend: $osf.setXHRAuthorization,
                contentType: 'application/json',
                dataType: 'json',
                data: JSON.stringify({
                    data: {
                        id: self.file.path.replace('/', ''),
                        type: 'files',
                        attributes: {
                            checkout: null
                        }
                    }
                })
            }).done(function(resp) {
                window.location.reload();
            }).fail(function(resp) {
                $osf.growl('Error', 'Unable to check in file');
            });
        });
        $(document).on('fileviewpage:force_checkin', function() {
            bootbox.confirm({
                title: 'Force check in file?',
                message: 'This will check in the file for all users, allowing it to be edited. Are you sure?',
                buttons: {
                    confirm:{
                        label: 'Force check in',
                        className: 'btn-danger'
                    }
                },
                callback: function(confirm) {
                    if (!confirm) {
                        return;
                    }
                    $.ajax({
                        method: 'put',
                        url: window.contextVars.apiV2Prefix + 'files' + self.file.path + '/',
                        beforeSend: $osf.setXHRAuthorization,
                        contentType: 'application/json',
                        dataType: 'json',
                        data: JSON.stringify({
                            data: {
                                id: self.file.path.replace('/', ''),
                                type: 'files',
                                attributes: {
                                    checkout: null
                                }
                            }
                        })
                    }).done(function(resp) {
                        window.location.reload();
                    }).fail(function(resp) {
                        $osf.growl('Error', 'Unable to force check in file. Make sure you have admin privileges.');
                    });
                }

            });
        });
        $(document).on('fileviewpage:download', function() {
            //replace mode=render with action=download for download count incrementation
            window.location = self.file.urls.content.replace('mode=render', 'action=download');
            return false;
        });

        self.shareJSObservables = {
            activeUsers: m.prop([]),
            status: m.prop('connecting'),
            userId: self.context.currentUser.id
        };

        self.editHeader = function() {
            return m('.row', [
                m('.col-sm-12', m('span[style=display:block;]', [
                    m('h3.panel-title',[m('i.fa.fa-pencil-square-o'), '   Edit ']),
                    m('.pull-right', [
                        m('.progress.no-margin.pointer', {
                            'data-toggle': 'modal',
                            'data-target': '#' + self.shareJSObservables.status() + 'Modal'
                        }, [
                            m('.progress-bar.p-h-sm.progress-bar-success', {
                                connected: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-success'
                                },
                                connecting: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-warning progress-bar-striped active'
                                },
                                saving: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-info progress-bar-striped active'
                                }
                            }[self.shareJSObservables.status()] || {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-danger'
                                }, [
                                    m('span.progress-bar-content', [
                                        {
                                            connected: 'Live editing mode ',
                                            connecting: 'Attempting to connect ',
                                            unsupported: 'Unsupported browser ',
                                            saving: 'Saving... '
                                        }[self.shareJSObservables.status()] || 'Unavailable: Live editing ',
                                        m('i.fa.fa-question-circle.fa-large')
                                    ])
                                ])
                            ])
                        ])
                    ]))
                ]);
        };


        // Hack to delay creation of the editor
        // until we know this is the current file revision
        self.enableEditing = function() {
            // Sometimes we can get here twice, check just in case
            if (self.editor || !self.canEdit()) {
                m.redraw(true);
                return;
            }
            var fileType = mime.lookup(self.file.name.toLowerCase());
            // Only allow files < 1MB to be editable
            if (self.file.size < 1048576 && fileType) { //May return false
                var editor = EDITORS[fileType.split('/')[0]];
                if (editor) {
                    self.editor = new Panel('Edit', self.editHeader, editor, [self.file.urls.content, self.file.urls.sharejs, self.editorMeta, self.shareJSObservables], false);
                }
            }
            m.redraw(true);
        };

        //Hack to polyfill the Panel interface
        //Ran into problems with mithrils caching messing up with multiple "Panels"
        self.revisions = m.component(FileRevisionsTable, self.file, self.node, self.enableEditing, self.canEdit);
        self.revisions.selected = false;
        self.revisions.title = 'Revisions';

        // inform the mfr of a change in display size performed via javascript,
        // otherwise the mfr iframe will not update unless the document windows is changed.
        self.triggerResize = $osf.throttle(function () {
            $(document).trigger('fileviewpage:resize');
        }, 1000);

        self.mfrIframeParent = $('#mfrIframeParent');
    },
Exemplo n.º 3
0
    controller: function(context) {
        var self = this;
        self.context = context;
        self.file = self.context.file;
        self.node = self.context.node;
        self.editorMeta = self.context.editor;
        //Force canEdit into a bool
        self.canEdit = m.prop(!!self.context.currentUser.canEdit);

        $.extend(self.file.urls, {
            delete: waterbutler.buildDeleteUrl(self.file.path, self.file.provider, self.node.id),
            metadata: waterbutler.buildMetadataUrl(self.file.path, self.file.provider, self.node.id),
            revisions: waterbutler.buildRevisionsUrl(self.file.path, self.file.provider, self.node.id),
            content: waterbutler.buildDownloadUrl(self.file.path, self.file.provider, self.node.id, {accept_url: false, mode: 'render'})
        });

        if ($osf.urlParams().branch) {
            self.file.urls.revisions = waterbutler.buildRevisionsUrl(self.file.path, self.file.provider, self.node.id, {sha: $osf.urlParams().branch});
            self.file.urls.content = waterbutler.buildDownloadUrl(self.file.path, self.file.provider, self.node.id, {accept_url: false, mode: 'render', branch: $osf.urlParams().branch});
        }

        $(document).on('fileviewpage:delete', function() {
            bootbox.confirm({
                title: 'Delete file?',
                message: '<p class="overflow">' +
                        'Are you sure you want to delete <strong>' +
                        self.file.safeName + '</strong>?' +
                    '</p>',
                callback: function(confirm) {
                    if (!confirm) {
                        return;
                    }
                    $.ajax({
                        type: 'DELETE',
                        url: self.file.urls.delete,
                        beforeSend: $osf.setXHRAuthorization
                    }).done(function() {
                        window.location = self.node.urls.files;
                    }).fail(function() {
                        $osf.growl('Error', 'Could not delete file.');
                    });
                },
                buttons:{
                    confirm:{
                        label:'Delete',
                        className:'btn-danger'
                    }
                }
            });
        });

        $(document).on('fileviewpage:download', function() {
            //replace mode=render with action=download for download count incrementation
            window.location = self.file.urls.content.replace('mode=render', 'action=download');
            return false;
        });

        self.shareJSObservables = {
            activeUsers: m.prop([]),
            status: m.prop('connecting'),
            userId: self.context.currentUser.id
        };

        self.editHeader = function() {
            return m('.row', [
                m('.col-sm-12', m('span[style=display:block;]', [
                    m('h3.panel-title',[m('i.fa.fa-pencil-square-o'), '   Edit ']),
                    m('.pull-right', [
                        m('.progress.no-margin.pointer', {
                            'data-toggle': 'modal',
                            'data-target': '#' + self.shareJSObservables.status() + 'Modal'
                        }, [
                            m('.progress-bar.p-h-sm.progress-bar-success', {
                                connected: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-success'
                                },
                                connecting: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-warning progress-bar-striped active'
                                },
                                saving: {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-info progress-bar-striped active'
                                }
                            }[self.shareJSObservables.status()] || {
                                    style: 'width: 100%',
                                    class: 'progress-bar progress-bar-danger'
                                }, [
                                    m('span.progress-bar-content', [
                                        {
                                            connected: 'Live editing mode ',
                                            connecting: 'Attempting to connect ',
                                            unsupported: 'Unsupported browser ',
                                            saving: 'Saving... '
                                        }[self.shareJSObservables.status()] || 'Unavailable: Live editing ',
                                        m('i.fa.fa-question-circle.fa-large')
                                    ])
                                ])
                            ])
                        ])
                    ]))
                ]);
        };


        // Hack to delay creation of the editor
        // until we know this is the current file revsion
        self.enableEditing = function() {
            // Sometimes we can get here twice, check just in case
            if (self.editor || !self.canEdit()) {
                m.redraw(true);
                return;
            }
            var fileType = mime.lookup(self.file.name.toLowerCase());
            // Only allow files < 1MB to be editable
            if (self.file.size < 1048576 && fileType) { //May return false
                var editor = EDITORS[fileType.split('/')[0]];
                if (editor) {
                    self.editor = new Panel('Edit', self.editHeader, editor, [self.file.urls.content, self.file.urls.sharejs, self.editorMeta, self.shareJSObservables], false);
                }
            }
            m.redraw(true);
        };

        //Hack to polyfill the Panel interface
        //Ran into problems with mithrils caching messing up with multiple "Panels"
        self.revisions = m.component(FileRevisionsTable, self.file, self.node, self.enableEditing, self.canEdit);
        self.revisions.selected = false;
        self.revisions.title = 'Revisions';

        // inform the mfr of a change in display size performed via javascript,
        // otherwise the mfr iframe will not update unless the document windows is changed.
        self.triggerResize = $osf.throttle(function () {
            $(document).trigger('fileviewpage:resize');
        }, 1000);

        self.mfrIframeParent = $('#mfrIframeParent');
    },