Skip to content

Commit c799561

Browse files
committed
➡️
1 parent 388ebdd commit c799561

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66
- Added support for webhooks that send GET requests.
77
- Webhook names and group names can now contain emojis, even if using MySQL.
8+
- Typing `->` or `=>` into a webhook’s Name field now creates a ➡️.
89

910
## 1.0.1 - 2018-12-13
1011

src/assets/edit/EditAsset.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* @link https://craftcms.com/
4+
* @copyright Copyright (c) Pixel & Tonic, Inc.
5+
* @license MIT
6+
*/
7+
8+
namespace craft\webhooks\assets\edit;
9+
10+
use craft\web\AssetBundle;
11+
use craft\web\assets\cp\CpAsset;
12+
use craft\web\View;
13+
14+
/**
15+
* Webhooks index asset bundle
16+
*
17+
* @author Pixel & Tonic, Inc. <[email protected]>
18+
* @since 1.0
19+
*/
20+
class EditAsset extends AssetBundle
21+
{
22+
public $sourcePath = __DIR__ . '/dist';
23+
24+
public $depends = [
25+
CpAsset::class,
26+
];
27+
28+
public $js = [
29+
'js/EditWebhook.js',
30+
];
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
(function($) {
2+
/** global: Craft */
3+
/** global: Garnish */
4+
var EditWebhook = Garnish.Base.extend(
5+
{
6+
$nameInput: null,
7+
8+
init: function() {
9+
this.$nameInput = $('#name');
10+
11+
this.addListener(this.$nameInput, 'change, keyup', 'handleTextChange');
12+
},
13+
14+
handleTextChange: function() {
15+
var input = this.$nameInput.get(0);
16+
17+
// does it look like they just typed -> or => ?
18+
if (typeof input.selectionStart !== 'undefined' && input.selectionStart === input.selectionEnd) {
19+
var pos = input.selectionStart;
20+
var last2 = input.value.substring(pos - 2, pos);
21+
if (last2 === '->' || last2 === '=>') {
22+
input.value = input.value.substring(0, pos - 2) + '➡️' + input.value.substring(pos);
23+
input.setSelectionRange(pos, pos);
24+
}
25+
}
26+
}
27+
})
28+
29+
30+
Garnish.$doc.ready(function() {
31+
new EditWebhook();
32+
});
33+
})(jQuery);

src/controllers/WebhooksController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Craft;
66
use craft\helpers\UrlHelper;
77
use craft\web\Controller as BaseController;
8+
use craft\webhooks\assets\edit\EditAsset;
89
use craft\webhooks\Plugin;
910
use craft\webhooks\Webhook;
1011
use yii\base\InvalidArgumentException;
@@ -91,6 +92,8 @@ public function actionEdit(int $id = null, int $groupId = null, Webhook $webhook
9192
}
9293
}
9394

95+
Craft::$app->getView()->registerAssetBundle(EditAsset::class);
96+
9497
return $this->renderTemplate('webhooks/_edit', compact(
9598
'groupOptions',
9699
'webhook',

0 commit comments

Comments
 (0)