summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2014-01-27 11:12:27 +0000
committerpad <pad@vm-pad-b.spline.inf.fu-berlin.de>2014-01-27 11:12:27 +0000
commit33b97da914105927bc5800224b9bab0ad1d312c6 (patch)
tree565c8906361f37d4c42ba23c0ea4897f722984d8
downloadep_headline_buttons-33b97da914105927bc5800224b9bab0ad1d312c6.tar.gz
ep_headline_buttons-33b97da914105927bc5800224b9bab0ad1d312c6.tar.bz2
ep_headline_buttons-33b97da914105927bc5800224b9bab0ad1d312c6.zip
Initial commit
-rw-r--r--ep.json17
-rw-r--r--index.js14
-rw-r--r--locales/en.json8
-rw-r--r--package.json16
-rw-r--r--static/css/buttons.css32
-rw-r--r--static/css/headline_buttons.css23
-rw-r--r--static/img/etherpad_lite_headline_icons.pngbin0 -> 1062 bytes
-rw-r--r--static/js/index.js7
-rw-r--r--static/js/shared.js28
-rw-r--r--templates/editbarButtons.ejs31
-rw-r--r--templates/editbarButtons_styles.ejs1
11 files changed, 177 insertions, 0 deletions
diff --git a/ep.json b/ep.json
new file mode 100644
index 0000000..5249002
--- /dev/null
+++ b/ep.json
@@ -0,0 +1,17 @@
+{
+ "parts": [
+ {
+ "name": "main",
+ "client_hooks": {
+ "aceEditorCSS": "ep_headline_buttons/static/js/index",
+ "collectContentPre": "ep_headline_buttons/static/js/shared"
+ },
+ "hooks": {
+ "eejsBlock_styles": "ep_headline_buttons/index",
+ "eejsBlock_editbarMenuLeft": "ep_headline_buttons/index",
+ "collectContentPre": "ep_headline_buttons/static/js/shared",
+ "collectContentPost": "ep_headline_buttons/static/js/shared"
+ }
+ }
+ ]
+}
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..43b349c
--- /dev/null
+++ b/index.js
@@ -0,0 +1,14 @@
+var eejs = require('ep_etherpad-lite/node/eejs/');
+var Changeset = require("ep_etherpad-lite/static/js/Changeset");
+
+exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
+ args.content = args.content + eejs.require("ep_headline_buttons/templates/editbarButtons.ejs");
+ return cb();
+}
+
+exports.eejsBlock_styles = function (hook_name, args, cb) {
+ args.content = args.content + eejs.require("ep_headline_buttons/templates/editbarButtons_styles.ejs");
+ return cb();
+}
+
+
diff --git a/locales/en.json b/locales/en.json
new file mode 100644
index 0000000..b05c85c
--- /dev/null
+++ b/locales/en.json
@@ -0,0 +1,8 @@
+{
+ "pad.toolbar.h1.title" : "H1",
+ "pad.toolbar.h2.title" : "H2",
+ "pad.toolbar.h3.title" : "H3",
+ "pad.toolbar.h4.title" : "H4",
+ "pad.toolbar.h5.title" : "H5",
+ "pad.toolbar.h6.title" : "H6"
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e7e5364
--- /dev/null
+++ b/package.json
@@ -0,0 +1,16 @@
+{
+ "description": "Adds buttons for headlines to Etherpad Lite.",
+ "name": "ep_headline_buttons",
+ "version": "0.1.0",
+ "author": "Alexander Sulfrian <alexander@sulfrian.net>",
+ "dependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "homepage": "https://github.com/AlexanderS/ep_headline_buttons",
+ "devDependencies": {},
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/AlexanderS/ep_headline_buttons.git"
+ }
+}
diff --git a/static/css/buttons.css b/static/css/buttons.css
new file mode 100644
index 0000000..e073b0f
--- /dev/null
+++ b/static/css/buttons.css
@@ -0,0 +1,32 @@
+.buttonicon-headline {
+ width: 16px;
+ height: 16px;
+ background-image: url('../../static/img/etherpad_lite_headline_icons.png');
+ background-repeat: no-repeat;
+ display: inline-block;
+ vertical-align: middle;
+}
+
+.buttonicon-headline-h1 {
+ background-position: 0px 1px;
+}
+
+.buttonicon-headline-h2 {
+ background-position: 0px -15px;
+}
+
+.buttonicon-headline-h3 {
+ background-position: 0px -31px;
+}
+
+.buttonicon-headline-h4 {
+ background-position: 0px -47px;
+}
+
+.buttonicon-headline-h5 {
+ background-position: 0px -63px;
+}
+
+.buttonicon-headline-h6 {
+ background-position: 0px -79px;
+}
diff --git a/static/css/headline_buttons.css b/static/css/headline_buttons.css
new file mode 100644
index 0000000..100b879
--- /dev/null
+++ b/static/css/headline_buttons.css
@@ -0,0 +1,23 @@
+h1 span, h2 span, h3 span, h4 span, h5 span, h6 span {
+ line-height: 1.5em;
+}
+
+h1 {
+ font-size: 2em;
+}
+
+h2 {
+ font-size: 1.5em;
+}
+
+h3 {
+ font-size: 1.17em;
+}
+
+h5 {
+ font-size: .83em;
+}
+
+h6 {
+ font-size: .75em;
+}
diff --git a/static/img/etherpad_lite_headline_icons.png b/static/img/etherpad_lite_headline_icons.png
new file mode 100644
index 0000000..b8f30b8
--- /dev/null
+++ b/static/img/etherpad_lite_headline_icons.png
Binary files differ
diff --git a/static/js/index.js b/static/js/index.js
new file mode 100644
index 0000000..ab18207
--- /dev/null
+++ b/static/js/index.js
@@ -0,0 +1,7 @@
+var cssFiles = ['ep_headline_buttons/static/css/headline_buttons.css'];
+
+function aceEditorCSS(){
+ return cssFiles;
+};
+
+exports.aceEditorCSS = aceEditorCSS;
diff --git a/static/js/shared.js b/static/js/shared.js
new file mode 100644
index 0000000..df88e6b
--- /dev/null
+++ b/static/js/shared.js
@@ -0,0 +1,28 @@
+var _ = require('ep_etherpad-lite/static/js/underscore');
+
+var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
+
+var collectContentPre = function(hook, context){
+ var tname = context.tname;
+ var state = context.state;
+ var lineAttributes = state.lineAttributes
+ var tagIndex = _.indexOf(tags, tname);
+
+ if (tagIndex >= 0) {
+ lineAttributes['heading'] = tags[tagIndex];
+ }
+};
+
+var collectContentPost = function(hook, context){
+ var tname = context.tname;
+ var state = context.state;
+ var lineAttributes = state.lineAttributes
+ var tagIndex = _.indexOf(tags, tname);
+
+ if (tagIndex >= 0) {
+ delete lineAttributes['heading'];
+ }
+};
+
+exports.collectContentPre = collectContentPre;
+exports.collectContentPost = collectContentPost;
diff --git a/templates/editbarButtons.ejs b/templates/editbarButtons.ejs
new file mode 100644
index 0000000..0682bf1
--- /dev/null
+++ b/templates/editbarButtons.ejs
@@ -0,0 +1,31 @@
+<li class="separator acl-write"></li>
+<li class="acl-write" id="headline_h1" data-key="headline_h1">
+ <a class="grouped-left" data-l10n-id="pad.toolbar.h1.title">
+ <span class="buttonicon-headline buttonicon-headline-h1"></span>
+ </a>
+</li>
+<li class="acl-write" id="headline_h2" data-key="headline_h2">
+ <a class="grouped-middle" data-l10n-id="pad.toolbar.h2.title">
+ <span class="buttonicon-headline buttonicon-headline-h2"></span>
+ </a>
+</li>
+<li class="acl-write" id="headline_h3" data-key="headline_h3">
+ <a class="grouped-middle" data-l10n-id="pad.toolbar.h3.title">
+ <span class="buttonicon-headline buttonicon-headline-h3"></span>
+ </a>
+</li>
+<li class="acl-write" id="headline_h4" data-key="headline_h4">
+ <a class="grouped-middle" data-l10n-id="pad.toolbar.h4.title">
+ <span class="buttonicon-headline buttonicon-headline-h4"></span>
+ </a>
+</li>
+<li class="acl-write" id="headline_h5" data-key="headline_h5">
+ <a class="grouped-middle" data-l10n-id="pad.toolbar.h5.title">
+ <span class="buttonicon-headline buttonicon-headline-h5"></span>
+ </a>
+</li>
+<li class="acl-write" id="headline_h6" data-key="headline_h6">
+ <a class="grouped-right" data-l10n-id="pad.toolbar.h6.title">
+ <span class="buttonicon-headline buttonicon-headline-h6"></span>
+ </a>
+</li>
diff --git a/templates/editbarButtons_styles.ejs b/templates/editbarButtons_styles.ejs
new file mode 100644
index 0000000..4c11afc
--- /dev/null
+++ b/templates/editbarButtons_styles.ejs
@@ -0,0 +1 @@
+<link href="/static/plugins/ep_headline_buttons/static/css/buttons.css" rel="stylesheet">