Skip to content

Commit 2d456e5

Browse files
committed
maint: Upgrade to Patternslib v4 final - content-mirror customizations.
1 parent 8271517 commit 2d456e5

File tree

4 files changed

+43
-40
lines changed

4 files changed

+43
-40
lines changed

index.html

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
<!DOCTYPE HTML>
22
<html>
33
<head>
4-
<meta http-equiv="content-type" content="text/html; charset=utf-8">
5-
<title>Content-mirror pattern demo</title>
6-
<script src="bundle.js"></script>
7-
<link rel="icon" type="image/png" href="http://patterns.cornae.com/media/favicon.png" />
4+
<meta http-equiv="refresh" content="0; url=./src" />
85
</head>
9-
<body class="sidebar-left-open generic application- ">
10-
<div id="content" class="application">
11-
<h1>Content-mirror pattern demo</h1>
12-
<p class="my-mirror"
13-
><span class="text"
14-
><em class="placeholder">Leave a comment</em></span
15-
><em class="selected-users" id="selected-users"></em
16-
><em class="selected-tags" id="selected-tags"></em
17-
></p>
18-
<textarea class="pat-content-mirror" placeholder="Type some text" data-pat-content-mirror="target:.my-mirror .text"></textarea>
19-
<hr />
20-
<p class="my-other-mirror"
21-
><span class="text"
22-
><em class="placeholder">I am the other mirror. Try me.</em></em
23-
></p>
24-
<textarea class="pat-content-mirror" placeholder="Say what's on your mind" data-pat-content-mirror="target:.my-other-mirror .text"></textarea>
25-
</div>
26-
</body>
276
</html>

package.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
"name": "pat-content-mirror",
33
"version": "1.0.0",
44
"description": "A pattern for content-mirror",
5-
"author": {
6-
"name": "Syslab GesmbH",
7-
"email": "[email protected]"
8-
},
95
"license": "MIT",
10-
"homepage": "https://gitub.com/ploneintranet/pat-content-mirror",
11-
"main": "./src/content-mirror.js",
6+
"main": "./src/pat-content-mirror.js",
127
"dependencies": {
138
"@patternslib/patternslib": "4"
149
},
@@ -69,5 +64,14 @@
6964
},
7065
"publishConfig": {
7166
"access": "public"
67+
},
68+
"author": {
69+
"name": "Syslab GesmbH",
70+
"email": "[email protected]"
71+
},
72+
"homepage": "https://github.com/ploneintranet/pat-PATTERN_TEMPLATE",
73+
"repository": {
74+
"type": "git",
75+
"url": "https://github.com/ploneintranet/pat-PATTERN_TEMPLATE.git"
7276
}
7377
}

src/index.html

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
5+
<title>Content-mirror pattern demo</title>
6+
<script src="/dist/bundle.js"></script>
7+
</head>
8+
<body class="sidebar-left-open generic application- ">
9+
<div id="content" class="application">
10+
<h1>Content-mirror pattern demo</h1>
11+
<p class="my-mirror"
12+
><span class="text"
13+
><em class="placeholder">Leave a comment</em></span
14+
><em class="selected-users" id="selected-users"></em
15+
><em class="selected-tags" id="selected-tags"></em
16+
></p>
17+
<textarea class="pat-content-mirror" placeholder="Type some text" data-pat-content-mirror="target:.my-mirror .text"></textarea>
18+
<hr />
19+
<p class="my-other-mirror"
20+
><span class="text"
21+
><em class="placeholder">I am the other mirror. Try me.</em></em
22+
></p>
23+
<textarea class="pat-content-mirror" placeholder="Say what's on your mind" data-pat-content-mirror="target:.my-other-mirror .text"></textarea>
24+
</div>
25+
</body>
26+
</html>

src/pat-content-mirror.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import $ from "jquery";
22
import _ from "underscore";
3-
import Base from "patternslib/src/core/base";
4-
import Parser from "patternslib/src/core/parser";
3+
import Base from "@patternslib/patternslib/src/core/base";
4+
import Parser from "@patternslib/patternslib/src/core/parser";
55

66
const parser = new Parser("content-mirror");
77
parser.add_argument("target");
@@ -16,22 +16,18 @@ export default Base.extend({
1616
init: function content_mirror_init($el, opts) {
1717
const options = parser.parse($el, opts, true)[0];
1818
this.options = _.extend(_.clone(this.defaults), options);
19-
const $mirror = $(this.options.target)
20-
.parents("p.content-mirror")
21-
.first();
19+
const $mirror = $(this.options.target).parents("p.content-mirror").first();
2220
$el.on(
2321
"input propertychange",
2422
$.proxy(this.updateMirror, this, this.options.target)
2523
);
2624
$el.parents("form")
2725
.first()
28-
.on("reset", function (e) {
26+
.on("reset", function () {
2927
$el.val("");
3028
$mirror.html($mirror.html());
3129
});
32-
$(".placeholder", this.options.target).text(
33-
$el.attr("placeholder") || ""
34-
);
30+
$(".placeholder", this.options.target).text($el.attr("placeholder") || "");
3531
},
3632

3733
updateMirror: function updateMirror(target, ev) {
@@ -41,9 +37,7 @@ export default Base.extend({
4137
if (!$el.val().length) {
4238
const placeholder = $el.attr("placeholder");
4339
if (placeholder) {
44-
the_mirror.html(
45-
'<em class="placeholder">' + placeholder + "</em>"
46-
);
40+
the_mirror.html('<em class="placeholder">' + placeholder + "</em>");
4741
}
4842
}
4943
},

0 commit comments

Comments
 (0)