Skip to content

Commit

Permalink
Merge pull request #29 from x-team/issue-18
Browse files Browse the repository at this point in the history
Show noice in form if no triggers exist, Fixes #18
  • Loading branch information
frankiejarrett committed Jan 30, 2014
2 parents 91b92b2 + 70e101c commit 5e653e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions stream-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
13 changes: 13 additions & 0 deletions ui/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div class="updated fade"><p>'+stream_notifications.i18n.empty_triggers+'</p></div>')
.next('.updated')
.delay(3000)
.fadeOut('slow');
$('body,html').scrollTop(0)
return false;
}
})

});
2 changes: 1 addition & 1 deletion views/rule-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<?php endif; ?>
</h2>

<form action="" method="post">
<form action="" method="post" id="rule-form">

<?php wp_nonce_field( 'stream-notifications-form' ); ?>

Expand Down

0 comments on commit 5e653e1

Please sign in to comment.