{"size": 995, "ext": "js", "max_stars_repo_path": "plugins-available/ep_media_upload_button/static/js/index.js", "max_stars_repo_name": "Ghostthinker/etherpad-lite", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plugins-available/ep_media_upload_button/static/js/index.js", "max_issues_repo_name": "Ghostthinker/etherpad-lite", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plugins-available/ep_media_upload_button/static/js/index.js", "max_forks_repo_name": "Ghostthinker/etherpad-lite", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.4285714286, "max_line_length": 73, "alphanum_fraction": 0.632160804}
var _, $, jQuery;
var $ = require('ep_etherpad-lite/static/js/rjquery').$;
/**
 * Initialize the button after load
 */
exports.postAceInit = function (hook, context) {
    /* Event: User clicks upload media button */
    $('#media-upload-button').on('click', function ($event) {
            window.top.postMessage('showUploadModal', clientVars.baseUrl)
            // Storing cursor line number in clientVars
            context.ace.callWithAce(function (ace) {
                clientVars.cursorLine = _handleNewLines(ace);
            }, 'img', true);
        }
    );
}

var _handleNewLines = function (ace) {
    var rep = ace.ace_getRep();
    var lineNumber = rep.selStart[0];
    var curLine = rep.lines.atIndex(lineNumber);
    if (curLine.text) {
        return lineNumber + 1;
    }
    return lineNumber;
};

/**
 * Embed the css file
 */
exports.aceEditorCSS = function () {
    return ['ep_media_upload_button/static/css/uploadMediaButton.css'];
}
//# sourceURL=mediaUploadButton.js
