Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
blank.html; IE does not allow data URL to be loaded directly
  • Loading branch information
timdream committed Jun 16, 2013
1 parent 0dd9a9a commit a2c4c89
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
3 changes: 3 additions & 0 deletions assets/first-screen.css
Expand Up @@ -105,3 +105,6 @@ https://gist.github.com/2945570
height: 51.11px;
top: -24.44089px;
right: 13.33px; }

#popup-image {
width: 100%; }
6 changes: 5 additions & 1 deletion assets/first-screen.scss
@@ -1,5 +1,5 @@
// This file should only contains CSS style rules critical to
// render the first screen (i.e. the shaking cloud animation.)
// render the first screen and blank.html (i.e. the shaking cloud animation.)

html {
min-height: 100%;
Expand Down Expand Up @@ -131,3 +131,7 @@ $shadow-length: $icon-width * 0.05;
right: $icon-width * .1333;
}
}

#popup-image {
width: 100%;
}
44 changes: 37 additions & 7 deletions assets/wordcloud-app.js
Expand Up @@ -861,7 +861,27 @@ DashboardView.prototype.handleEvent = function dv_handleEvent(evt) {
} else {
evt.preventDefault();
alert(_('right-click-to-save'));
window.open(url, '_blank', 'width=500,height=300,menubar=yes');
var win = window.open('blank.html', '_blank',
'width=500,height=300,resizable=yes,menubar=yes');

// XXX IE won't attach the standard addEventListener interface
// until the dead code below is evaluated.
win.attachEvent;

win.addEventListener('load', function dv_popupLoaded() {
win.removeEventListener('load', dv_popupLoaded);
var doc = win.document;

while (doc.body.firstElementChild) {
doc.body.removeChild(doc.body.firstElementChild);
}
var img = doc.createElement('img');
img.id = 'popup-image';
img.src = url;
doc.getElementsByTagName('title')[0].textContent =
_('image-popup-title');
doc.body.appendChild(img);
});
}

break;
Expand Down Expand Up @@ -1297,12 +1317,20 @@ SharerDialogView.prototype.sendImage = function sdv_sendImage() {
// once the image is uploaded.
// Obviously this is not the optimal user experience.

var facebookWin =
window.open('data:text/html,' +
encodeURIComponent(_(
this.stringIds[this.LABEL_FACEBOOK_WINDOW_LOADING])
)
);
var facebookWin = window.open('blank.html');
var loadingLabel = _(this.stringIds[this.LABEL_FACEBOOK_WINDOW_LOADING]);
var insertLoadingLabel = function sdv_insertLoadingLabel() {
facebookWin.removeEventListener('load', insertLoadingLabel);

var doc = facebookWin.document;
doc.getElementsByTagName('title')[0].textContent = loadingLabel;
};

// XXX IE won't attach the standard addEventListener interface
// until the dead code below is evaluated.
facebookWin.attachEvent;

facebookWin.addEventListener('load', insertLoadingLabel);

// XXX This is sad. We couldn't make a CORS XHR request
// to Facebook Graph API to send our image directly,
Expand All @@ -1312,6 +1340,8 @@ SharerDialogView.prototype.sendImage = function sdv_sendImage() {
message: this.getCloudTitle() + '\n\n' +
this.getCloudList() + '\n\n' + url
}, (function sdv_facebookImageUploaded(res) {
facebookWin.removeEventListener('load', insertLoadingLabel);

if (!res || !res.id) {
facebookWin.close();

Expand Down
17 changes: 17 additions & 0 deletions blank.html
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset=UTF-8>
<title></title>
<link rel="stylesheet" type="text/css" href="./assets/first-screen.css">
</head>
<body>

<div id="wc-loading">
<div class="wc-icon" lang="en">
<span class="wc-icon-cloud"></span>
</div>
</div>

</body>
</html>
1 change: 1 addition & 0 deletions locales/wordcloud.en-US.properties
Expand Up @@ -118,6 +118,7 @@ no_data=No data retrived. Please try again.
no_list_output=No text generated. Please try other sources.
right-click-to-save=Please right click and choose "Save As..."\n to save the generated image.
image-popup-title=Image (right click to save)
frquent-terms=most frequent terms: {{terms}}
frquent-terms-more=most frequent terms: {{terms}}...
Expand Down
1 change: 1 addition & 0 deletions locales/wordcloud.zh-TW.properties
Expand Up @@ -118,6 +118,7 @@ no_data=讀取失敗,請稍候再試。
no_list_output=取得詞彙數量太少,請選其他內容。

right-click-to-save=請點選滑鼠右鍵→「另存圖片」以儲存圖片。
image-popup-title=圖片(按右鍵另存新檔案)

frquent-terms=最常出現的詞彙:{{terms}}
frquent-terms-more=最常出現的詞彙:{{terms}}…
Expand Down

0 comments on commit a2c4c89

Please sign in to comment.