Gergő Tisza has uploaded a new change for review.
https://gerrit.wikimedia.org/r/123109
Change subject: Make survey open in popup window instead of normal one
......................................................................
Make survey open in popup window instead of normal one
Change-Id: If971f7607bd3fc33080b903e07bd53ae3d3407cf
---
M resources/mmv/ui/mmv.ui.stripeButtons.js
M resources/mmv/ui/mmv.ui.stripeButtons.less
2 files changed, 57 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer
refs/changes/09/123109/1
diff --git a/resources/mmv/ui/mmv.ui.stripeButtons.js
b/resources/mmv/ui/mmv.ui.stripeButtons.js
index 370392d..4c395e7 100644
--- a/resources/mmv/ui/mmv.ui.stripeButtons.js
+++ b/resources/mmv/ui/mmv.ui.stripeButtons.js
@@ -76,16 +76,66 @@
* Creates the feedback button.
*/
SBP.initFeedbackButton = function() {
+ var buttons = this;
+
this.buttons.$feedback = this.createButton(
'mw-mmv-stripe-button-feedback',
mw.message( 'multimediaviewer-feedback-button-text'
).plain(),
mw.message( 'multimediaviewer-feedback-popup-text'
).plain()
).prop( {
target: '_blank',
- href:
'https://www.surveymonkey.com/s/media-viewer-1?c=mediaviewer'
+ href: this.getFeedbackSurveyUrl()
+ } ).click( function ( e ) {
+ buttons.openSurveyInNewWindow();
+ e.preventDefault();
} );
};
+ SBP.getFeedbackSurveyUrl = function () {
+ return
'https://www.surveymonkey.com/s/media-viewer-1?c=mediaviewer';
+ };
+
+ /**
+ * Opens the survey in a new window, or brings it up if it is already
opened.
+ */
+ SBP.openSurveyInNewWindow = function () {
+ var surveyWindowWidth = screen.width / 2,
+ surveyWindowHeight = screen.height / 2,
+ feedbackSurveyWindowProperties = {
+ left: ( screen.width - surveyWindowWidth ) / 2,
+ top: ( screen.height - surveyWindowHeight ) / 2,
+ width: surveyWindowWidth,
+ height: surveyWindowHeight,
+ menubar: 0,
+ toolbar: 0,
+ location: 0,
+ personalbar: 0,
+ status: 0
+ };
+
+ if ( !this.surveyWindow || this.surveyWindow.closed ) {
+ this.surveyWindow = window.open(
this.getFeedbackSurveyUrl(), 'mmv-survey',
+ this.createWindowOpenPropertyString(
feedbackSurveyWindowProperties ) );
+ } else {
+ this.surveyWindow.focus();
+ }
+ };
+
+ /**
+ * @protected
+ * Takes a property object and turns it into a string suitable for the
last parameter
+ * of window.open.
+ * @param {Object} properties
+ * @return {string}
+ */
+ SBP.createWindowOpenPropertyString = function ( properties ) {
+ var propertyArray = [];
+ $.each( properties, function ( key, value ) {
+ propertyArray.push( key + '=' + value );
+ } );
+ return propertyArray.join( ',' );
+ };
+
/**
* @protected
* Runs code for each button, similarly to $.each.
diff --git a/resources/mmv/ui/mmv.ui.stripeButtons.less
b/resources/mmv/ui/mmv.ui.stripeButtons.less
index aa25444..5f7c309 100644
--- a/resources/mmv/ui/mmv.ui.stripeButtons.less
+++ b/resources/mmv/ui/mmv.ui.stripeButtons.less
@@ -42,7 +42,7 @@
position: relative;
top: 0.1em;
- background-size: 1em 1em;
+ background-size: 100% 100%;
margin-right: 0.25em;
content: ' ';
vertical-align: baseline;
@@ -57,4 +57,9 @@
.mw-mmv-stripe-button-feedback:before {
/* @embed */
background-image: url(img/horn_grey.svg);
+ width: 1.2em;
+ height: 1.2em;
+
+ // these icons have annoying empty bottom areas so it is hard to
position them properly
+ background-position: center 3px;
}
--
To view, visit https://gerrit.wikimedia.org/r/123109
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If971f7607bd3fc33080b903e07bd53ae3d3407cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits