3
* @fileoverview Contains the code for the Screenshot Builder class. Handles event listeners for the screenshot button and
6
/*jslint browser: true, white: true, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: true,
7
bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxlen: 120, sub: true */
8
/*global document, $, Class, window */
10
var ScreenshotBuilder = Class.extend(
11
/** @lends ScreenshotBuilder.prototype */
16
* @description Loads default options, grabs mediaSettings, sets up event listener for the screenshot button
17
* @param {Object} controller -- the helioviewer class
19
init: function (controller) {
21
this.button = $("#screenshot-button");
22
this.building = false;
23
this.viewport = controller.viewport;
24
this.controller = controller;
26
this.mediaSettings = this.controller.mediaSettings;
28
var self = this, visibleCoords;
29
this.button.click(function () {
31
self.messageConsole.info("A link to your screenshot will be available shortly.");
34
visibleCoords = self.viewport.getHCViewportPixelCoords();
35
self.takeScreenshot(visibleCoords);
41
* @description Gathers all necessary information to generate a screenshot, and then displays the
42
* image when it is ready.
43
* @param {Object} visibleCoords -- array containing the heliocentric top, left, bottom, and right
44
* coordinates of the visible region
46
takeScreenshot: function (visibleCoords) {
47
var self, callback, params, imgWidth, imgHeight, url, mediaSettings, download, options, filename,
48
helioviewer = this.controller;
50
// Refresh the settings in case something has changed.
51
mediaSettings = this.mediaSettings;
52
mediaSettings.getSettings(visibleCoords);
56
imgWidth = mediaSettings.width;
57
imgHeight = mediaSettings.height;
62
action : "takeScreenshot",
63
layers : (mediaSettings.layerNames).join("/"),
64
obsDate : mediaSettings.startTime,
65
zoomLevel : mediaSettings.zoomLevel,
66
edges : mediaSettings.edgeEnhance,
67
sharpen : mediaSettings.sharpen,
68
imageSize : imgWidth + "," + imgHeight,
69
filename : mediaSettings.filename,
70
quality : mediaSettings.quality
73
callback = function (url) {
74
self.building = false;
76
// If the response is an error message instead of a url, show the message
78
//mediaSettings.shadowboxWarn(transport.responseText);
82
// Options for the jGrowl notification. Clicking on the notification will
83
// let the user download the file.
86
header: "Your screenshot is ready!",
87
open: function (e, m) {
88
download = $('#screenshot-' + filename);
90
download.click(function () {
91
window.open('api/index.php?action=downloadFile&url=' + url, '_parent');
96
// Create the jGrowl notification.
97
helioviewer.messageConsole.info("<div id='screenshot-" + filename +
98
"' style='cursor: pointer'>Click here to download. </div>", options);
102
$.post('api/index.php', params, callback, 'json');
b'\\ No newline at end of file'