<commit_before>var $ = require('jquery');
var m = require('mithril');
var mime = require('js/mime');
var bootbox = require('bootbox');
var $osf = require('js/osfHelpers');
var waterbutler = require('js/waterbutler');

// Local requires
var utils = require('./util.js');
var FileEditor = require('./editor.js');
var makeClient = require('js/clipboard');
var FileRevisionsTable = require('./revisions.js');
var storageAddons = require('json!storageAddons.json');

// Sanity
var Panel = utils.Panel;


var EDITORS = {'text': FileEditor};

var SharePopover =  {
    view: function(ctrl, params) {
        var copyButtonHeight = '34px';
        var popoverWidth = '450px';
        var link = params.link.substring(0, params.link.indexOf('download') + 8) + '%26mode=render';
        var url = link.substring(0, link.indexOf('render'));
        return m('button.btn.btn-sm.btn-primary.file-share', {onclick: function () {
                m.render(document.getElementById('popOver'), [
                    m('ul.nav.nav-tabs.nav-justified', [
                        m('li.active', m('a[href="#share"][data-toggle="tab"]', 'Share')),
                        m('li', m('a[href="#embed"][data-toggle="tab"]', 'Embed'))
                    ]), m('br'),
                    m('.tab-content', [
                        m('.tab-pane.fade.in.active#share', m('.input-group', [
                            m('span.input-group-btn', m('button#copyBtn.btn.btn-default.btn-md[type="button"][style="height:' + copyButtonHeight + '"][data-clipboard-text="' + link + '"]', m('.fa.fa-copy'))),
                            m('input.form-control[readonly][type="text"][value="'+ link +'"]')
                        ])),
                        m('.tab-pane.fade#embed', [
                            m('p', 'Dynamically Render iFrame with JavaScript'),
                            m('textarea.form-control[readonly][type="text"][value="' +
                                '<script>window.jQuery || document.write(\'<script src="//code.jquery.com/jquery-1.11.2.min.js">\\x3C/script>\') </script>'+
                                '<link href="' + url + 'static/css/mfr.css" media="all" rel="stylesheet">' +
                                '<div id="mfrIframe" class="mfr mfr-file"></div>' +
                                '<script src="' + url + 'static/js/mfr.js">' +
                                '</script> <script>' +
                                    'var mfrRender = new mfr.Render("mfrIframe", "' + link + '");' +
                                '</script>' + '"]'
                            ), m('br'),
                            m('p', 'Direct iFrame with Fixed Height and Width'),
                            m('textarea.form-control[readonly][value="' +
                                '<iframe src="' + link + '" width="100%" scrolling="yes" height="' + params.height + '" marginheight="0" frameborder="0" allowfullscreen webkitallowfullscreen>"]'
                            )<commit_msg>Moved copyButton out, still has some issues<commit_after>var $ = require('jquery');
var m = require('mithril');
var mime = require('js/mime');
var bootbox = require('bootbox');
var $osf = require('js/osfHelpers');
var waterbutler = require('js/waterbutler');

// Local requires
var utils = require('./util.js');
var FileEditor = require('./editor.js');
var makeClient = require('js/clipboard');
var FileRevisionsTable = require('./revisions.js');
var storageAddons = require('json!storageAddons.json');

// Sanity
var Panel = utils.Panel;


var EDITORS = {'text': FileEditor};

var MakeClient = function(element) {
    makeClient(element);
};

var CopyButton = {
    view: function(ctrl, params) {
        return m('span.input-group-btn', m('button#copyBtn.btn.btn-default.btn-md[type="button"][style="height:' + params.copyButtonHeight + '"][data-clipboard-text="' + params.link + '"]',
            {config: MakeClient},
            m('.fa.fa-copy')));
    }
};

var SharePopover =  {
    view: function(ctrl, params) {
        var copyButtonHeight = '34px';
        var popoverWidth = '450px';
        var link = params.link.substring(0, params.link.indexOf('download') + 8) + '%26mode=render';
        var url = link.substring(0, link.indexOf('render'));
        return m('button.btn.btn-sm.btn-primary.file-share', {onclick: function () {
                m.render(document.getElementById('popOver'), [
                    m('ul.nav.nav-tabs.nav-justified', [
                        m('li.active', m('a[href="#share"][data-toggle="tab"]', 'Share')),
                        m('li', m('a[href="#embed"][data-toggle="tab"]', 'Embed'))
                    ]), m('br'),
                    m('.tab-content', [
                        m('.tab-pane.fade.in.active#share', m('.input-group', [
                            m.component(CopyButton, {link: link, copyButtonHeight: copyButtonHeight}),
                            m('input.form-control[readonly][type="text"][value="'+ link +'"]')
                        ])),
                        m('.tab-pane.fade#embed', [
                            m('p', 'Dynamically Render iFrame with JavaScript'),
                            m('textarea.form-control[readonly][type="text"][value="' +
                                '<script>window.jQuery || document.write(\'<script src="//code.jquery.com/jquery-1.11.2.min.js">\\x3C/script>\') </script>'+
                                '<link href="' + url + 'static/css/mfr.css" media="all" rel="stylesheet">' +
                                '<div id="mfrIframe" class="mfr mfr-file"></div>' +
                                '<script src="' + url + 'static/js/mfr.js">' +
                                '</script> <script>' +
                                    'var mfrRender = new mfr.Render("mfrIframe", "' + link + '");' +
                                '</script>' + '"]'
                            ), m('br'),
                            m('p', 'Direct iFrame with Fixed Height and Width'),
                            m('textarea.form-control[readonly][value="' +
                                '<iframe src="' + link + '" width="100%" scrolling="yes" height="' + params.height + '" marginheight="0" frameborder="0" allowfullscreen webkitallowfullscreen>"]'
                            )
{'fraction_non_alphanumeric': 0.18361491871214536, 'fraction_numerical': 0.006375518010838381, 'mean_word_length': 1.9010633379565418, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4536419', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1762, 'n_words': 307}