-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #861 from ix5/js-template-labels-placeholders
[client] js: Postbox: Use labels rather than placeholders
- Loading branch information
Showing
8 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
module.exports = { | ||
"postbox-text": "Type Comment Here (at least 3 chars)", | ||
"postbox-author": "Name (optional)", | ||
"postbox-author-placeholder": "John Doe", | ||
"postbox-email": "E-mail (optional)", | ||
"postbox-email-placeholder": "[email protected]", | ||
"postbox-website": "Website (optional)", | ||
"postbox-website-placeholder": "https://example.com", | ||
"postbox-preview": "Preview", | ||
"postbox-edit": "Edit", | ||
"postbox-submit": "Submit", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Create Postbox 1`] = `"<div id=\\"isso-root\\"></div><div class=\\"isso-postbox\\"><div class=\\"isso-form-wrapper\\"><div class=\\"isso-textarea-wrapper\\"><div class=\\"isso-textarea isso-placeholder\\" contenteditable=\\"true\\">Type Comment Here (at least 3 chars)</div><div class=\\"isso-preview\\"><div class=\\"isso-comment\\"><div class=\\"isso-text-wrapper\\"><div class=\\"isso-text\\"></div></div></div></div></div><section class=\\"isso-auth-section\\"><p class=\\"isso-input-wrapper\\"><input type=\\"text\\" name=\\"author\\" placeholder=\\"Name (optional)\\" value=\\"\\"></p><p class=\\"isso-input-wrapper\\"><input type=\\"email\\" name=\\"email\\" placeholder=\\"E-mail (optional)\\" value=\\"\\"></p><p class=\\"isso-input-wrapper\\"><input type=\\"text\\" name=\\"website\\" placeholder=\\"Website (optional)\\" value=\\"\\"></p><p class=\\"isso-post-action\\"><input type=\\"submit\\" value=\\"Submit\\"></p><p class=\\"isso-post-action\\"><input type=\\"button\\" name=\\"preview\\" value=\\"Preview\\"></p><p class=\\"isso-post-action\\"><input type=\\"button\\" name=\\"edit\\" value=\\"Edit\\"></p></section><section class=\\"isso-notification-section\\" style=\\"display: none;\\"><label><input type=\\"checkbox\\" name=\\"notification\\">Subscribe to email notification of replies</label></section></div></div>"`; | ||
exports[`Create Postbox 1`] = `"<div id=\\"isso-root\\"></div><div class=\\"isso-postbox\\"><div class=\\"isso-form-wrapper\\"><div class=\\"isso-textarea-wrapper\\"><div class=\\"isso-textarea isso-placeholder\\" contenteditable=\\"true\\">Type Comment Here (at least 3 chars)</div><div class=\\"isso-preview\\"><div class=\\"isso-comment\\"><div class=\\"isso-text-wrapper\\"><div class=\\"isso-text\\"></div></div></div></div></div><section class=\\"isso-auth-section\\"><p class=\\"isso-input-wrapper\\"><label for=\\"isso-postbox-author\\">Name (optional)</label><input id=\\"isso-postbox-author\\" type=\\"text\\" name=\\"author\\" placeholder=\\"John Doe\\" value=\\"\\"></p><p class=\\"isso-input-wrapper\\"><label for=\\"isso-postbox-email\\">E-mail (optional)</label><input id=\\"isso-postbox-email\\" type=\\"email\\" name=\\"email\\" placeholder=\\"[email protected]\\" value=\\"\\"></p><p class=\\"isso-input-wrapper\\"><label for=\\"isso-postbox-website\\">Website (optional)</label><input id=\\"isso-postbox-website\\" type=\\"text\\" name=\\"website\\" placeholder=\\"https://example.com\\" value=\\"\\"></p><p class=\\"isso-post-action\\"><input type=\\"submit\\" value=\\"Submit\\"></p><p class=\\"isso-post-action\\"><input type=\\"button\\" name=\\"preview\\" value=\\"Preview\\"></p><p class=\\"isso-post-action\\"><input type=\\"button\\" name=\\"edit\\" value=\\"Edit\\"></p></section><section class=\\"isso-notification-section\\" style=\\"display: none;\\"><label><input type=\\"checkbox\\" name=\\"notification\\">Subscribe to email notification of replies</label></section></div></div>"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
/* Keep the above exactly as-is! | ||
* https://jestjs.io/docs/configuration#testenvironment-string | ||
* https://jestjs.io/docs/configuration#testenvironmentoptions-object | ||
*/ | ||
|
||
"use strict"; | ||
|
||
test('"(optional)" labels in Postox vanish if require-author/-email set', () => { | ||
// Set up our document body | ||
document.body.innerHTML = | ||
'<div id=isso-thread></div>' + | ||
'<script src="http://isso.api/js/embed.min.js"' | ||
+ 'data-isso="/"' | ||
+ 'data-isso-lang="de"' // falls back to "en" for placeholders | ||
+ '></script>'; | ||
|
||
const isso = require("app/isso"); | ||
const $ = require("app/dom"); | ||
|
||
var config = require("app/config"); | ||
config['require-author'] = true; | ||
config['require-email'] = true; | ||
|
||
const i18n = require("app/i18n"); | ||
const svg = require("app/svg"); | ||
|
||
const template = require("app/template"); | ||
|
||
template.set("conf", config); | ||
template.set("i18n", i18n.translate); | ||
template.set("pluralize", i18n.pluralize); | ||
template.set("svg", svg); | ||
|
||
var isso_thread = $('#isso-thread'); | ||
isso_thread.append('<div id="isso-root"></div>'); | ||
isso_thread.append(new isso.Postbox(null)); | ||
|
||
expect($("#isso-postbox-author").placeholder).toBe('John Doe'); | ||
expect($("#isso-postbox-email").placeholder).toBe('[email protected]'); | ||
// Instead of "Name (optional)" | ||
expect($("[for='isso-postbox-author']").textContent).toBe('Name'); | ||
// Instead of "E-mail (optional)" | ||
expect($("[for='isso-postbox-email']").textContent).toBe('E-Mail'); | ||
}); |