From 70e101c9c1d855523f0e13acfbcec1e38e49f4cc Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Thu, 30 Jan 2014 05:47:10 +0200 Subject: [PATCH] Show noice in form if no triggers exist, Fixes #18 --- stream-notifications.php | 5 +++++ ui/js/main.js | 13 +++++++++++++ views/rule-form.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/stream-notifications.php b/stream-notifications.php index cf5e5a90f..4653aedbf 100644 --- a/stream-notifications.php +++ b/stream-notifications.php @@ -338,6 +338,11 @@ public function get_js_options() { ); } + // Localization + $args['i18n'] = array( + 'empty_triggers' => __( 'A rule must contain at least one trigger to be saved.', 'stream-notifications' ), + ); + return apply_filters( 'stream_notification_js_args', $args ); } diff --git a/ui/js/main.js b/ui/js/main.js index 921c58eb2..12e25c82f 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -294,4 +294,17 @@ jQuery(function($){ } } + // Do not submit if no triggers exist + $('#rule-form').submit(function(e){ + if ( divTriggers.find('.trigger').size() < 1 ) { + $('.wrap > h2') + .after('

'+stream_notifications.i18n.empty_triggers+'

') + .next('.updated') + .delay(3000) + .fadeOut('slow'); + $('body,html').scrollTop(0) + return false; + } + }) + }); \ No newline at end of file diff --git a/views/rule-form.php b/views/rule-form.php index 853c5fa31..7883c4c03 100644 --- a/views/rule-form.php +++ b/views/rule-form.php @@ -15,7 +15,7 @@ -
+