diff --git a/extension.json b/extension.json index 40a2c08..6d4634b 100644 --- a/extension.json +++ b/extension.json @@ -1,150 +1,146 @@ { "name": "EUCopyrightCampaign", "author": [ "Robert Vogel", "Dejan Savuljesku", "Hallo Welt! GmbH" ], "url": "https://www.wikimedia.org", "descriptionmsg": "eucopyrightcampaign-desc", "license-name": "GPL-2.0-or-later", "type": "other", "requires": { "MediaWiki": ">= 1.29.0" }, "attributes": { "EventLogging": { "Schemas": { "EUCCStats": 18341891 } } }, "SpecialPages": { "ContactYourMEP": "\\EUCopyrightCampaign\\Special\\ContactYourMEP" }, "MessagesDirs": { "EUCopyrightCampaign": "i18n" }, "ExtensionMessagesFiles": { "EUCopyrightCampaignAlias": "i18n/EUCopyrightCampaign.i18n.alias.php" }, "APIModules": { "eucc-get-representatives": "\\EUCopyrightCampaign\\Api\\GetRepresentatives" }, "ResourceModules": { "ext.euCopyrightCampaign": { "scripts": [ "ext.euCopyrightCampaign.util.js", "ui/dialog/Mail.js", "ui/dialog/Call.js", "ui/dialog/Twitter.js", "ui/widget/CheckboxMultioptionText.js", "ui/widget/Contact.js", "ui/widget/CountryPicker.js", "ui/widget/RepresentativePicker.js", "ui/ThankYouLayout.js", "ext.euCopyrightCampaign.js" ], "styles": [ "ext.euCopyrightCampaign.less", "ext.euCopyrightCampaign.flagIcons.less" ], "messages": [ "eucc-country-picker-layout-label", "eucc-country-picker-placeholder", "eucc-representative-picker-layout-label", "eucc-contact-layout-label", - "eucc-contact-button-copy-mail-label", - "eucc-contact-button-send-mail-label", "eucc-email-greeting", "eucc-email-user-info", "eucc-email-part-one-v1", "eucc-email-part-one-v2", "eucc-email-part-one-v3", "eucc-email-part-two", "eucc-email-complimentary-close", "eucc-email-first-name-input-placeholder", "eucc-email-last-name-input-placeholder", "eucc-email-custom-text-placeholder", "eucc-email-email-input-placeholder", "eucc-email-newsletter-label", "eucc-email-privacy-policy-label", "eucc-option-protect-public-domain-label", "eucc-option-protect-public-domain-text-v1", "eucc-option-protect-public-domain-text-v2", "eucc-option-protect-public-domain-text-v3", "eucc-option-freedom-of-panorama-label", "eucc-option-freedom-of-panorama-text-v1", "eucc-option-freedom-of-panorama-text-v2", "eucc-option-freedom-of-panorama-text-v3", "eucc-option-exception-for-ucg-label", "eucc-option-exception-for-ucg-text-v1", "eucc-option-exception-for-ucg-text-v2", "eucc-option-exception-for-ucg-text-v3", "eucc-option-exception-for-text-and-data-mining-label", "eucc-option-exception-for-text-and-data-mining-text-v1", "eucc-option-exception-for-text-and-data-mining-text-v2", "eucc-option-exception-for-text-and-data-mining-text-v3", "eucc-thank-you-header", "eucc-thank-you-text", "eucc-share-tweet-text", "eucc-share-tweet-label", "eucc-share-tweet-button-label", "eucc-copy-to-clipboard-success", "eucc-copy-to-clipboard-fail", "eucc-email-issues-intro", "eucc-email-outro-v1", "eucc-email-outro-v2", "eucc-email-outro-v3", "eucc-call-representative-phone-brussels", "eucc-call-representative-phone-strasbourg", "eucc-call-script-label", "eucc-call-script-text", - "eucc-restart-label", - "eucc-learn-more", "eucc-contact-button-call-short-label", "eucc-contact-button-tweet-short-label", "eucc-contact-button-call-label", "eucc-contact-button-tweet-label", "eucc-contact-top-alternatives-text", "eucc-contact-button-generate-mail-label", "eucc-dialog-mark-as-done-label", "eucc-mail-dialog-copy-text-label", "eucc-mail-dialog-send-mail-label", "eucc-mail-dialog-title", "eucc-mail-dialog-top-label", "eucc-mail-dialog-target-rep", "eucc-call-dialog-title", "eucc-tweet-at-rep-default-text", "eucc-twitter-dialog-title", "eucc-contact-top-alternatives-only-phone-text" ], "dependencies": [ "mediawiki.api", "mediawiki.jqueryMsg", "oojs", "oojs-ui" ] } }, "ResourceFileModulePaths": { "localBasePath": "resources", "remoteExtPath": "EUCopyrightCampaign/resources" }, "AutoloadClasses": { "EUCopyrightCampaign\\Special\\ContactYourMEP": "src/Special/ContactYourMEP.php", "EUCopyrightCampaign\\Api\\GetRepresentatives": "src/Api/GetRepresentatives.php" }, "config_prefix": "wgEUCopyrightCampaign", "config": { "NewsletterSubmitTarget": { "value": "https://www.pages04.net/wikimedia/20180828_fixcopyright/Form" }, "MailingListPrivacyPolicyURL": { "value": "https://www.ibm.com/privacy/details/us/en/privacy_shield.html" } }, "load_composer_autoloader": true, "manifest_version": 2 } diff --git a/i18n/en.json b/i18n/en.json index d715f6d..b96dd31 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -1,90 +1,86 @@ { "@metadata": { "authors": [ "Robert Vogel", "Dejan Savuljesku" ] }, "contactyourmep": "ContactYourMEP", "contactyourmep-desc": "Adds Contact Your MEP form", "eucopyrightcampaign-desc": "Extension that allows citizens of the EU to contact their representatives", "apihelp-eucc-get-representatives-summary": "Retrieves list of representatives for a given country", "apihelp-eucc-get-representatives-param-country": "Specifies the country to get a list of representatives for", "eucc-country-picker-layout-label": "1. Let's find your representative", "eucc-country-picker-placeholder": "Select your country", "eucc-representative-picker-layout-label": "Select your representative", "eucc-contact-layout-label": "2. Contact your representative", - "eucc-contact-button-copy-mail-label": "Copy email", - "eucc-contact-button-send-mail-label": "Send email", "eucc-email-greeting": "Dear $1,", "eucc-email-user-info": "My name is $1 $2 and I live in $3.", "eucc-email-part-one-v1": "I write to you to share with you my support for a forward-looking copyright framework that promotes everyone’s ability to freely communicate online and participate in the creation and collection of knowledge. I want to highlight the opportunity you have to make sure EU copyright law keeps up with the digital age.", "eucc-email-part-one-v2": "I am writing today to express my support for a European copyright framework which would ensure that every EU citizen can communicate freely online and collaborate to collect and share knowledge. This is a rare moment where your vote can ensure that Europe’s copyright law reflects the world that European citizens are already living in online.", "eucc-email-part-one-v3": "I write today to support a copyright framework for Europe that respects everyone’s right to to collect, create, and share knowledge with the world. This upcoming vote is an opportunity for you and your colleagues in Parliament to acknowledge the realities of the digital age and harmonize our copyright law to match those realities.", "eucc-email-issues-intro": "There are a few simple things that Wikimedia and I support to #fixcopyright:", "eucc-email-part-two": "Finally, I urge you consider these improvements to copyright without imposing additional restrictions. There should not be pre-filtering obligations for platform providers because they will fundamentally turn the internet into medium where people can only communicate after receiving a company’s permission. This will hurt the culture of sharing that is necessary for Wikipedia to grow and flourish.", "eucc-email-outro-v1": "Thank you for considering these important issues when you cast your vote on the copyright proposal. I hope you will promote your constituents’ access to knowledge and support rules that allow everyone to be a creator.", "eucc-email-outro-v2": "Thank you for your attention to all of these issues. I hope that you will consider my and my fellow constituent’s perspective when voting on amendments to the copyright proposal, and that you will support access to knowledge and creation online for everyone.", "eucc-email-outro-v3": "Thank you for taking the time to consider these issues in advance of the upcoming copyright vote. I hope that sharing my perspective has helped you to see how copyright rules affect your constituent’s access to knowledge and ability to participate in creation online.", "eucc-email-complimentary-close": "Sincerely,", "eucc-email-newsletter-label": "I want to receive email updates about how to support Wikimedia. (You can unsubscribe at any time. This list is operated by $1)", "eucc-email-privacy-policy-label": "IBM Watson", "eucc-email-first-name-input-placeholder": "First name", "eucc-email-last-name-input-placeholder": "Last name", "eucc-email-custom-text-placeholder": "Optional: share an online activity you do frequently (e.g., sending messages, posting photos, editing Wikipedia).", "eucc-email-email-input-placeholder": "Email address", "eucc-option-protect-public-domain-label": "Protect the Public Domain", "eucc-option-protect-public-domain-text-v1": "The EU needs to protect the public domain and ensure that all Europeans can enjoy it, online and in the real world. Wikipedia uses a lot of works that are in the public domain, such as impressionist paintings or early world maps, to illustrate articles.", "eucc-option-protect-public-domain-text-v2": "The European Parliament must ensure that everyone can enjoy public domain works online, just as they can in person. Public domain works enrich the world’s store of knowledge and culture, ultimately making educational projects like Wikipedia even more useful.", "eucc-option-protect-public-domain-text-v3": "A common-sense public domain exception for virtual copies of public domain works across the EU will allow people around the continent and the world to partake in Europe’s rich cultural history. Wikipedia articles about art, history, and even cartography are illustrated with public domain images which allow users not only to read about these subject, but see them", "eucc-option-freedom-of-panorama-label": "Freedom of Panorama", "eucc-option-freedom-of-panorama-text-v1": "Everybody who reads Wikipedia would also greatly benefit from wider availability of photographs of buildings and city landscapes that can be freely shared online. European copyright law should not include an exception for photographs of architecture and sculpted works in public spaces.", "eucc-option-freedom-of-panorama-text-v2": "The EU should also ensure that everyone, no matter where they live, can share photographs of public artwork and buildings online. Limiting Freedom of Panorama will only harm projects like Wikipedia which have a number of educational articles about architecture and public artwork.", "eucc-option-freedom-of-panorama-text-v3": "Citizens of and visitors to member states are free to enjoy Europe’s significant public works of art and beautiful architecture, but in many countries that freedom does not include the freedom to share pictures of those sights online. A copyright law which embraces the everyday activity of sharing photographs of public spaces online will help harmonize EU regulations with how people use the internet today.", "eucc-option-exception-for-ucg-label": "Exception for User-generated Content", "eucc-option-exception-for-ucg-text-v1": "Our law should also catch up with reality and make sure the ways in which we communicate online -- by sharing videos, creating memes, and linking to news articles -- is not outlawed or unduly restricted.", "eucc-option-exception-for-ucg-text-v2": "Additionally, EU citizens share and create user-generated content nearly everyday, and our new copyright law should reflect that. Everyone should be free to share videos, create memes, and link to news articles without undue restrictions.", "eucc-option-exception-for-ucg-text-v3": "EU copyright law should reflect the way people communicate online today and create exceptions to copyright for user-generated content like memes, videos, and links to news articles.", "eucc-option-exception-for-text-and-data-mining-label": "Text and Data Mining Exceptions", "eucc-option-exception-for-text-and-data-mining-text-v1": "Broad exceptions for text and data mining will allow everyone with a computer to gain new insights from data they have lawful access to, so everyone can contribute to the advancement of science and research.", "eucc-option-exception-for-text-and-data-mining-text-v2": "Text and data mining should not be limited to certain institutions or for certain purposes. Anyone should be able to use the data they have lawful access to to gain new insights about the world around us.", "eucc-option-exception-for-text-and-data-mining-text-v3": "The EU will miss an opportunity to empower its citizens to participate in science and research if it limits text and data mining only to certain institutions and for certain purposes. Everyone should have the ability to conduct research and contribute their insights to the sum of all knowledge.", "eucc-call-representative-phone-brussels": "Brussels", "eucc-call-representative-phone-strasbourg": "Strasbourg", "eucc-call-script-label": "Call script", "eucc-call-script-text": "# Introduce yourself and say where you live\n# Talk about how you use the internet everyday. For example, maybe you upload vacation photos, you write a blog, you share memes or news articles, or you search for information on or contribute to Wikipedia.\n# Tell them you are calling to talk about the EU Copyright Directive\n# A few things you can mention (feel free to pick 1-2 you are most passionate about):\n#* You oppose any type of pre-filtering of content. This means you don’t want your content scanned by an algorithm before it is posted.\n#* You support the public domain and want to see more public domain works available online.\n#* You want freedom of panorama so everyone can share photographs of public sculptures and architecture without restrictions.\n#* You want the law to match how you share things online, including videos, memes, news articles by including a user-generated content exception.\n#* You want everyone to be able to participate in science and research through text and data mining. \n# Thank them.", "eucc-thank-you-header": "Thank you!", "eucc-thank-you-text": "Your action has put Europe one step closer to an updated copyright framework which reflects the reality of how people create, find, and share information online today. By contacting your MEP, you have shown that this is an issue that affects real people, not just large companies. Wikimedia thrives when many diverse voices collaborate to share their knowledge on our projects, and we thank you for lending your voice today in support of an environment where these projects can continue to flourish.", "eucc-share-tweet-text": "I just contacted my MEP and told them to $1 in the EU! Contact your representative at $2", "eucc-share-tweet-label": "Ask your friends to contact their representative", "eucc-share-tweet-button-label": "Tweet", "eucc-copy-to-clipboard-success": "Email copied to clipboard", "eucc-copy-to-clipboard-fail": "Email could not be copied to clipboard", - "eucc-restart-label": "To contact another representative from your country, please click ##RELOAD_LINK##", - "eucc-learn-more": "To learn more about the Wikimedia movement, our stance on EU Copyright, and how else you can help, see our ##INFO PAGE##.", "eucc-contact-button-call-short-label": "Phone", "eucc-contact-button-tweet-short-label": "Tweet", "eucc-contact-button-call-label": "Call your rep", "eucc-contact-button-tweet-label": "Tweet $1", "eucc-contact-top-alternatives-text": "Please fill out the form and generate the email to send to your representative. You can also $1 or $2 your representative", "eucc-contact-button-generate-mail-label": "Generate Email", "eucc-dialog-mark-as-done-label": "Mark as done", "eucc-mail-dialog-copy-text-label": "Copy text", "eucc-mail-dialog-send-mail-label": "Send email", "eucc-mail-dialog-title": "Email your representative", "eucc-mail-dialog-top-label": "Your email is ready to be sent", "eucc-mail-dialog-target-rep": "$1 $2", "eucc-call-dialog-title": "Call your representative", "eucc-tweet-at-rep-default-text": "It’s time to #fixcopyright. I support a copyright framework for Europe that respects everyone's right to communicate effectively online as well as to collect, create, and share knowledge with the world. fixcopyright.wikimedia.org", "eucc-twitter-dialog-title": "Tweet @representative", "eucc-contact-top-alternatives-only-phone-text": "Please fill out the form and generate the email to send to your representative. You can also $1 your representative" } diff --git a/i18n/qqq.json b/i18n/qqq.json index 2174d74..218dd96 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -1,83 +1,79 @@ { "@metadata": { "authors": [ "Robert Vogel", "Dejan Savuljesku", "Nemo bis", "Umherirrender" ] }, "contactyourmep": "The name of the extension's entry in Special:SpecialPages", "contactyourmep-desc": "{{desc}}", "eucopyrightcampaign-desc": "{{desc|name=EUCopyrightCampaign|url=https://www.wikimedia.org}}", "apihelp-eucc-get-representatives-summary": "{{doc-apihelp-summary|eucc-get-representatives}}", "apihelp-eucc-get-representatives-param-country": "{{doc-apihelp-param|eucc-get-representatives|country}}", "eucc-country-picker-layout-label": "Label for first step of the process, selecting representative", "eucc-country-picker-placeholder": "Label for country selection dropdown", "eucc-representative-picker-layout-label": "Label for representative selection dropdown", "eucc-contact-layout-label": "Label for second step of the process, composing the mail", - "eucc-contact-button-copy-mail-label": "Label for button to copy the mail text to clipboard", - "eucc-contact-button-send-mail-label": "Label for button to compile mail and open local mail client", "eucc-email-greeting": "Greeting for the email. Paramter:\n* $1 - Name of the representative", "eucc-email-user-info": "Information on the sender in mail. Parameters:\n* $1 - First name of sender\n* $2 - Second name of sender\n* $3 - Country of residence of the sender", "eucc-email-part-one-v1": "First part of static email text, after custom text, but before issue (theme) selection - variation 1", "eucc-email-part-one-v2": "First part of static email text, after custom text, but before issue (theme) selection - variation 2", "eucc-email-part-one-v3": "First part of static email text, after custom text, but before issue (theme) selection - variation 3", "eucc-email-issues-intro": "Email text showing as an intro for issue selection", "eucc-email-part-two": "Seconds part of static email text, showing after issue selection.", "eucc-email-outro-v1": "Email text appearing at the end of the email, before complimentary close - variation 1", "eucc-email-outro-v2": "Email text appearing at the end of the email, before complimentary close - variation 2\n\nWith \"amendments to the copyright proposal\" we mean the amendments to the text of the directive proposed by the Commission. The [http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=A8-2018-0245&language=EN 244 amendments] were tabled on 2018-09-06 by MEPs, groups or committees and will be voted by the Plenary on 2018-09-12.", "eucc-email-outro-v3": "Email text appearing at the end of the email, before complimentary close - variation 3.\n\nFeel free to adapt \"your constituent\" to what makes sense for the electoral subdivisions or political landscape of the geography where your language is used the most.", "eucc-email-complimentary-close": "Complimentary close text in the email", "eucc-email-newsletter-label": "Label for the checkbox that subscribes the user to a Wikimedia mailing list. Parameter:\n* $1 - link to IBM Watson privacy policy", "eucc-email-privacy-policy-label": "Label for the link to the privacy policy for the IBM Watson mailing list.", "eucc-email-first-name-input-placeholder": "Placeholder for first name input", "eucc-email-last-name-input-placeholder": "Placeholder for last name input", "eucc-email-custom-text-placeholder": "Placeholder for optional field where user can write custom content for the mail", "eucc-email-email-input-placeholder": "Placeholder for email input", "eucc-option-protect-public-domain-label": "Issue selector - option Protect Public domain - title", "eucc-option-protect-public-domain-text-v1": "Issue selector - option Protect Public domain - text - variation 1", "eucc-option-protect-public-domain-text-v2": "Issue selector - option Protect Public domain - text - variation 2", "eucc-option-protect-public-domain-text-v3": "Issue selector - option Protect Public domain - text - variation 3", "eucc-option-freedom-of-panorama-label": "Issue selector - option Freedom of Panorama - title", "eucc-option-freedom-of-panorama-text-v1": "Issue selector - option Freedom of Panorama - text - variation 1", "eucc-option-freedom-of-panorama-text-v2": "Issue selector - option Freedom of Panorama - text - variation 2", "eucc-option-freedom-of-panorama-text-v3": "Issue selector - option Freedom of Panorama - text - variation 3", "eucc-option-exception-for-ucg-label": "Issue selector - option Exception for User-generated Content - title", "eucc-option-exception-for-ucg-text-v1": "Issue selector - option Exception for User-generated Content - text - variation 1", "eucc-option-exception-for-ucg-text-v2": "Issue selector - option Exception for User-generated Content - text - variation 2", "eucc-option-exception-for-ucg-text-v3": "Issue selector - option Exception for User-generated Content - text - variation 3", "eucc-option-exception-for-text-and-data-mining-label": "Issue selector - option Text and Data Mining Exceptions - title", "eucc-option-exception-for-text-and-data-mining-text-v1": "Issue selector - option Text and Data Mining Exceptions - text - variation 1", "eucc-option-exception-for-text-and-data-mining-text-v2": "Issue selector - option Text and Data Mining Exceptions - text - variation 2", "eucc-option-exception-for-text-and-data-mining-text-v3": "Issue selector - option Text and Data Mining Exceptions - text - variation 3", "eucc-call-representative-phone-brussels": "Phone number in Brussels", "eucc-call-representative-phone-strasbourg": "Phone number in Strasbourg", "eucc-call-script-label": "Label for the call script", "eucc-call-script-text": "Text of the call script", "eucc-thank-you-header": "Header for Thank you page", "eucc-thank-you-text": "Text for the main message on Thank you page", "eucc-share-tweet-text": "Text to be posted to Twitter. Parameters:\n* $1 - hashtag text/anchor in English (#FixCopyright)\n* $2 - URL to page to take action\nPlease translate the sentence in a grammatical way for your language and place $1 (the hashtag) at the end if you've not used it in the middle of the sentence.", "eucc-share-tweet-label": "Label text for Twitter text", "eucc-share-tweet-button-label": "Label for button that posts to Twitter", "eucc-copy-to-clipboard-success": "Message alerting the user that the email address has been copied to their clipboard.", "eucc-copy-to-clipboard-fail": "Message alerting the user that their email address could not be copied to their clipboard.", - "eucc-restart-label": "Label for the link restarting the contact process.\n\nDo not translate ##RELOAD_LINK##", - "eucc-learn-more": "Label for the link leading to a page where the user can learn more about the Wikimedia movement.\n\nDo not translate ##INFO PAGE##.", "eucc-contact-button-call-short-label": "Short label for the button \"call your representative\".", "eucc-contact-button-tweet-short-label": "Short label for the button \"tweet your representative\".", "eucc-contact-button-call-label": "Long label for the button \"call your representative\".", "eucc-contact-button-tweet-label": "Long label for the button \"tweet your representative\". Parameter:\n* $1 - Twitter username of the representative", "eucc-contact-top-alternatives-text": "Text appearing before the email form, to offer instructions and alternative ways to contact a representative.\n\nParameters:\n* $1 - a verb representing an alternative action, such as \"tweet\"\n* $2 - a verb representing an alternative action, such as \"call\"", "eucc-contact-button-generate-mail-label": "Button label to generate the text of an email from the form data and display it in a dialog.", "eucc-dialog-mark-as-done-label": "Label for button that marks the action as done", "eucc-mail-dialog-copy-text-label": "Label for the button to copy the text of the email.", "eucc-mail-dialog-send-mail-label": "Label for the button to send the email from a local email client.", "eucc-mail-dialog-title": "Title of the email dialog", "eucc-mail-dialog-top-label": "Label for the form to send the email content", "eucc-mail-dialog-target-rep": "Representative info when sending email. Parameters:\n* $1 - Representative name\n* $2 - Representative email address", "eucc-call-dialog-title": "Title of the call dialog", "eucc-tweet-at-rep-default-text": "Default text when tweeting at representatives", "eucc-twitter-dialog-title": "Title of tweet dialog", "eucc-contact-top-alternatives-only-phone-text": "Text appearing before the email form, offering instructions and alternative ways to contact a representative - without Twitter." } diff --git a/resources/ui/widget/Contact.js b/resources/ui/widget/Contact.js index b5f55cc..1adbc97 100644 --- a/resources/ui/widget/Contact.js +++ b/resources/ui/widget/Contact.js @@ -1,459 +1,470 @@ ( function( mw, $ ) { eucc.ui.ContactWidget = function( cfg ) { this.representative = cfg.representative; this.country = cfg.country; this.countryNameOfficial = this.getCountryNameOfficial(); eucc.ui.ContactWidget.parent.call( this, cfg ); this.compiledText = ''; this.dirty = false; this.windowManager = OO.ui.getWindowManager(); this.makeTopAlternatives(); this.makeTextComposition(); this.makeButtons(); this.$element.append( this.$textContainerOuter, this.buttonsLayout.$element ); this.$element.addClass( 'eucc-contact-widget' ); }; OO.inheritClass( eucc.ui.ContactWidget, OO.ui.Widget ); eucc.ui.ContactWidget.static.tagName = 'div'; eucc.ui.ContactWidget.prototype.getCountryNameOfficial = function() { var countryName = this.country.name; var countryNames = countryName.split( '/' ); if( countryNames.length > 1 ) { return countryNames[ 0 ].trim(); } return countryName; }; eucc.ui.ContactWidget.prototype.makeTopAlternatives = function() { this.$topAlternativesContainer = $( '
' ).addClass( 'eucc-contact-top-alternatives' ); var alternativeText = mw.message( 'eucc-contact-top-alternatives-only-phone-text' ).escaped(); var callButton = new OO.ui.ButtonWidget( { framed: false, label: mw.message( 'eucc-contact-button-call-short-label' ).text(), flags: [ 'progressive' ] } ); callButton.on( 'click', this.openCallDialog.bind( this ) ); var tweetButton = new OO.ui.ButtonWidget( { framed: false, label: mw.message( 'eucc-contact-button-tweet-short-label' ).text(), flags: [ 'progressive' ] } ); tweetButton.on( 'click', this.openTweetDialog.bind( this ) ); var alternativeText = mw.message( 'eucc-contact-top-alternatives-only-phone-text' ).escaped(); if( this.representative.twitter !== '' ) { alternativeText = mw.message( 'eucc-contact-top-alternatives-text' ).escaped(); alternativeText = alternativeText.replace( '$2', '' ); } alternativeText = alternativeText.replace( '$1', '' ); this.$topAlternativesContainer.append( $( '' ).html( alternativeText ) ); this.$topAlternativesContainer.find( 'a#top-alternative-call' ).replaceWith( callButton.$element ); if( this.representative.twitter !== '' ) { this.$topAlternativesContainer.find( 'a#top-alternative-tweet' ).replaceWith( tweetButton.$element ); } this.$element.append( this.$topAlternativesContainer ); } eucc.ui.ContactWidget.prototype.makeButtons = function() { var generateMailButton = new OO.ui.ButtonWidget( { label: mw.message( 'eucc-contact-button-generate-mail-label' ).text(), flags: [ "primary", "progressive" ] } ); generateMailButton.on( 'click', function() { this.validate().done( function() { this.openMailDialog(); }.bind( this ) ); }.bind( this ) ); var items = [ generateMailButton ]; if( this.representative.twitter !== '' ) { var tweetButton = new OO.ui.ButtonWidget( { label: mw.message( 'eucc-contact-button-tweet-label', this.representative.twitter ).text(), framed: false, flags: [ "progressive" ] } ); tweetButton.on( 'click', this.openTweetDialog.bind( this ) ); items.push( tweetButton ); } var callButton = new OO.ui.ButtonWidget( { label: mw.message( 'eucc-contact-button-call-label' ).text(), framed: false, flags: [ "progressive" ] } ); callButton.on( 'click', this.openCallDialog.bind( this ) ); items.push( callButton ); this.buttonsLayout = new OO.ui.HorizontalLayout( { items: items } ); }; eucc.ui.ContactWidget.prototype.makeTextComposition = function() { var greetingText, userInfo, firstPart, preIssueText, secondPart, outro, complimentaryClose; this.$textContainer = $( '
' ).addClass( 'eucc-contact-text-container' ); this.$textContainerOuter = $( '
' ).addClass( 'eucc-contact-text-container-outer' ); + // eucc-email-part-one-v1, eucc-email-part-one-v2, eucc-email-part-one-v3 this.firstPartMessageKey = this.pickVariation( 'eucc-email-part-one', 3 ); + // eucc-email-outro-v1, eucc-email-outro-v2, eucc-email-outro-v3 this.outroMessageKey = this.pickVariation( 'eucc-email-outro', 3 ); this.issues = [ { labelKey: 'eucc-option-protect-public-domain-label', + // eucc-option-protect-public-domain-text-v1, eucc-option-protect-public-domain-text-v2, + // eucc-option-protect-public-domain-text-v3 textKey: this.pickVariation( 'eucc-option-protect-public-domain-text', 3 ) },{ labelKey: 'eucc-option-freedom-of-panorama-label', + // eucc-option-freedom-of-panorama-text-v1, eucc-option-freedom-of-panorama-text-v2, + // eucc-option-freedom-of-panorama-text-v3 textKey: this.pickVariation( 'eucc-option-freedom-of-panorama-text', 3 ) },{ labelKey: 'eucc-option-exception-for-ucg-label', + // eucc-option-exception-for-ucg-text-v1, eucc-option-exception-for-ucg-text-v2, + // eucc-option-exception-for-ucg-text-v3 textKey: this.pickVariation( 'eucc-option-exception-for-ucg-text', 3 ) },{ labelKey: 'eucc-option-exception-for-text-and-data-mining-label', + // eucc-option-exception-for-text-and-data-mining-text-v1, + // eucc-option-exception-for-text-and-data-mining-text-v2, + // eucc-option-exception-for-text-and-data-mining-text-v3 textKey: this.pickVariation( 'eucc-option-exception-for-text-and-data-mining-text', 3 ) } ]; greetingText = mw.message( 'eucc-email-greeting', this.representative.fullName ).escaped(); userInfo = mw.message( 'eucc-email-user-info', '##FIRST_NAME##', '##LAST_NAME##', this.countryNameOfficial ).escaped(); // Not exactly the cleanest solution, doing double replacement, but i still think // its better than having complicated string operations userInfo = userInfo.replace( '##FIRST_NAME##', '' ); userInfo = userInfo.replace( '##LAST_NAME##', '' ); firstPart = mw.message( this.firstPartMessageKey ).escaped(); preIssueText = mw.message( 'eucc-email-issues-intro' ).escaped(); secondPart = mw.message( 'eucc-email-part-two' ).escaped(); outro = mw.message( this.outroMessageKey ).escaped(); complimentaryClose = mw.message( 'eucc-email-complimentary-close' ).escaped(); this.makeInputs(); this.makeNewsletterContainer(); this.$textContainer.append( new OO.ui.HtmlSnippet( '

' + greetingText + '

').toString(), new OO.ui.HtmlSnippet( '

' + userInfo + '

').toString(), this.customTextWidget.$element, new OO.ui.HtmlSnippet( '

' + firstPart + '

').toString(), new OO.ui.HtmlSnippet( '

' + preIssueText + '

').toString(), this.issueSelector.$element, new OO.ui.HtmlSnippet( '

' + secondPart + '

').toString(), new OO.ui.HtmlSnippet( '

' + outro + '

').toString(), new OO.ui.HtmlSnippet( '

' + complimentaryClose + '

').toString(), this.emailInput.$element, this.$newsletterContainer ); this.$textContainer.find( 'input[name="first_name"]' ).replaceWith( this.firstNameInput.$element ); this.$textContainer.find( 'input[name="last_name"]' ).replaceWith( this.lastNameInput.$element ); this.$textContainerOuter.append( this.$textContainer ); }; eucc.ui.ContactWidget.prototype.makeInputs = function() { this.firstNameInput = new OO.ui.TextInputWidget( { placeholder: mw.message( 'eucc-email-first-name-input-placeholder' ).text(), required: true, name: 'first_name' } ); this.firstNameInput.on( 'change', this.onInputChange.bind( this ) ); this.lastNameInput = new OO.ui.TextInputWidget( { placeholder: mw.message( 'eucc-email-last-name-input-placeholder' ).text(), required: true, name: 'last_name' } ); this.lastNameInput.on( 'change', this.onInputChange.bind( this ) ); this.customTextWidget = new OO.ui.MultilineTextInputWidget( { autosize: true, placeholder: mw.message( 'eucc-email-custom-text-placeholder' ).text(), } ); this.customTextWidget.$element.addClass( 'eucc-multiline-text-input' ); this.customTextWidget.on( 'change', this.onInputChange.bind( this ) ); var issueSelectorItems = []; var first = true; for( var idx in this.issues ) { var issue = this.issues[ idx ]; issueSelectorItems.push( new eucc.ui.CheckboxMultioptionTextWidget( { data: mw.message( issue.labelKey ).text(), label: mw.message( issue.labelKey ).text(), contentText: mw.message( issue.textKey ).text(), selected: first || false } ) ); first = false; } this.issueSelector = new OO.ui.CheckboxMultiselectWidget( { items: issueSelectorItems } ); this.issueSelector.on( 'change', this.onInputChange.bind( this ) ); this.emailInput = new OO.ui.TextInputWidget( { type: 'email', name: 'email', required: true, placeholder: mw.message( 'eucc-email-email-input-placeholder' ).text(), } ); this.emailInput.on( 'change', this.onInputChange.bind( this ) ); }; eucc.ui.ContactWidget.prototype.makeNewsletterContainer = function() { this.newsletterCheckbox = new OO.ui.CheckboxInputWidget( { selected: false, name: 'newsletter' } ); this.newsletterCheckbox.on( 'change', this.onInputChange.bind( this ) ); var ibmWatsonLink = "##IBM_WATSON_LABEL##"; ibmWatsonLink = ibmWatsonLink.replace( '##IBM_WATSON_URL##', mw.config.get( 'euccMailingListPrivacyPolicyURL' ) ); ibmWatsonLink = ibmWatsonLink.replace( '##IBM_WATSON_LABEL##', mw.message( 'eucc-email-privacy-policy-label' ).escaped() ); var label = mw.message( 'eucc-email-newsletter-label' ).escaped(); label = label.replace( '$1', ibmWatsonLink ); this.newsletterLabel = new OO.ui.LabelWidget( { label: new OO.ui.HtmlSnippet( '' + label + '' ), input: this.newsletterCheckbox } ); this.$newsletterContainer = $( '
' ) .addClass( 'eucc-email-newsletter-container' ) .append( this.newsletterCheckbox.$element, this.newsletterLabel.$element ); }; eucc.ui.ContactWidget.prototype.onInputChange = function() { this.dirty = true; }; eucc.ui.ContactWidget.prototype.isDirty = function() { return this.dirty; }; eucc.ui.ContactWidget.prototype.getSelectedIssues = function() { var selected = this.issueSelector.items.filter( function ( item ) { return item.isSelected(); } ); var selectedIssues = []; for( var idx in selected ) { selectedIssues.push( { header: selected[ idx ].data, text: selected[ idx ].getText() } ); } return selectedIssues; }; eucc.ui.ContactWidget.prototype.validate = function() { var dfd = $.Deferred(); var inputsToValidate = [ this.firstNameInput, this.lastNameInput, this.emailInput ]; this.validateInternaly( inputsToValidate, dfd ); return dfd.promise(); }; eucc.ui.ContactWidget.prototype.validateInternaly = function( inputsToValidate, dfd ) { if( inputsToValidate.length === 0 ) { return dfd.resolve(); } inputsToValidate[ 0 ].getValidity() .done( function() { inputsToValidate.splice( 0, 1 ); this.validateInternaly( inputsToValidate, dfd ); }.bind( this ) ) .fail( function() { inputsToValidate[ 0 ].focus(); inputsToValidate[ 0 ].setValidityFlag( false ); dfd.reject(); } ); }; eucc.ui.ContactWidget.prototype.getUserInfo = function() { return { firstName: this.firstNameInput.getValue(), lastName: this.lastNameInput.getValue(), emailAddress: this.emailInput.getValue(), country: this.country, newsletterSignup: this.newsletterCheckbox.isSelected(), emailText: this.getCompiledText(), freeText: this.customTextWidget.getValue(), selectedIssues: this.getSelectedIssues(), selectedRepresentative: this.representative, }; }; eucc.ui.ContactWidget.prototype.getCompiledText = function() { var greetingText, userInfo, firstPart, preIssueText, secondPart, outro, complimentaryClose; this.compiledText = ''; greetingText = mw.message( 'eucc-email-greeting', this.representative.fullName ).text(); this.addParagraph( greetingText ); userInfo = mw.message( 'eucc-email-user-info', this.firstNameInput.getValue(), this.lastNameInput.getValue(), this.countryNameOfficial ).text(); this.addParagraph( userInfo ); if( this.customTextWidget.getValue() ) { this.addParagraph( this.customTextWidget.getValue() ); } firstPart = mw.message( this.firstPartMessageKey ).text(); preIssueText = mw.message( 'eucc-email-issues-intro' ).text(); secondPart = mw.message( 'eucc-email-part-two' ).text(); outro = mw.message( this.outroMessageKey ).text(); complimentaryClose = mw.message( 'eucc-email-complimentary-close' ).text(); this.addParagraph( firstPart ); this.addParagraph( preIssueText ); var selectedIssues = this.getSelectedIssues(); for( var idx in selectedIssues ) { this.addParagraph( selectedIssues[ idx ].text ); } this.addParagraph( secondPart ); this.addParagraph( outro ); this.addParagraph( complimentaryClose ); this.addParagraph( this.firstNameInput.getValue() + ' ' + this.lastNameInput.getValue() + ' (' + this.emailInput.getValue() + ')' ); // When text is compiled, form is considered clean this.dirty = false; return this.compiledText; }; eucc.ui.ContactWidget.prototype.addParagraph = function( text ) { this.compiledText += text + "\n\n"; }; eucc.ui.ContactWidget.prototype.getTextForEmailClient = function() { // In mailto: only allowed link break character is "%0D%0A" // https://tools.ietf.org/html/rfc2368#page-3 var emailText = this.getCompiledText(); return emailText.replace( new RegExp( "\n", 'g' ), "%0D%0A" ); }; eucc.ui.ContactWidget.prototype.pickVariation = function( baseMsgKey, numberOfVariations ) { var variationNumber = Math.floor( Math.random() * ( numberOfVariations ) ) + 1; return baseMsgKey + '-v' + variationNumber; }; eucc.ui.ContactWidget.prototype.openCallDialog = function() { if( !this.callDialog ) { this.callDialog = new eucc.ui.dialog.Call( { representative: this.representative, callScriptContainer: $( '#eucc-call-script' ), size: 'larger' } ); this.windowManager.addWindows( [ this.callDialog ] ); } this.windowManager.openWindow( this.callDialog ) .closed.then( this.onDialogClose.bind( this ) ); this.emit( 'dialogOpened', 'call' ); }; eucc.ui.ContactWidget.prototype.openTweetDialog = function() { if( !this.twitterDialog ) { this.twitterDialog = new eucc.ui.dialog.Twitter( { representative: this.representative, defaultText: mw.message( 'eucc-tweet-at-rep-default-text' ).text(), size: 'large' } ); this.windowManager.addWindows( [ this.twitterDialog ] ); } this.windowManager.openWindow( this.twitterDialog ) .closed.then( this.onDialogClose.bind( this ) ); this.emit( 'dialogOpened', 'tweet' ); }; eucc.ui.ContactWidget.prototype.openMailDialog = function() { this.mailDialog = new eucc.ui.dialog.Mail( { representative: this.representative, emailText: this.getCompiledText(), emailTextForEmailClient: this.getTextForEmailClient(), size: 'large' } ); this.windowManager.addWindows( [ this.mailDialog ] ); this.windowManager.openWindow( this.mailDialog ) .closed.then( this.onDialogClose.bind( this ) ); this.emit( 'dialogOpened', 'mail' ); }; eucc.ui.ContactWidget.prototype.onDialogClose = function( data ) { if( data === undefined ) { return; } if( data.action === 'markAsDone' ) { this.emit( 'actionDone' ); } } } ) ( mediaWiki, jQuery );