Skip to content

Commit

Permalink
Add data tags hint for alerts notification adapter
Browse files Browse the repository at this point in the history
Resolves #22
  • Loading branch information
shadyvb committed Feb 1, 2014
1 parent 0453f29 commit 115a24b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
37 changes: 37 additions & 0 deletions classes/adapters/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,43 @@ public static function fields() {
);
}

public static function hints() {
ob_start();
?>
<a href="#" class="toggler" rel="#data-tag-glossary"
data-text-toggle="<?php _e( 'Hide Data Tag glossary', 'stream-notifications' ) ?>"
><?php _e( 'Show Data Tag glossary', 'stream-notifications' ) ?></a>
<div id="data-tag-glossary" class="toggled">
<strong><?php _e( 'Available Data Tags', 'stream-notifications' ) ?></strong>
<dl>
<dt><code>%%summary%%</code></dt>
<dd><?php _e( 'Summary of triggered record', 'stream-notifications' ) ?></dd>
</dl>
<dl>
<dt><code>%%object_id%%</code></dt>
<dd><?php _e( 'Date of triggered record', 'stream-notifications' ) ?></dd>
</dl>
<dl>
<dt><code>%%created%%</code></dt>
<dd><?php _e( 'Date of triggered record', 'stream-notifications' ) ?></dd>
</dl>
<dl>
<dt><code>%%author.??%%</code></dt>
<dd><?php _e( 'Attribute of record author, ie: author.user_login, author.user_email', 'stream-notifications' ) ?></dd>
</dl>
<dl>
<dt><code>%%object.??%%</code></dt>
<dd><?php _e( 'Attribute of record object, ie: object.post_title, object.term_id', 'stream-notifications' ) ?></dd>
</dl>
<dl>
<dt><code>%%meta.??%%</code></dt>
<dd><?php _e( 'Record meta field, ie: meta.old_theme ( in Themes:Switch )', 'stream-notifications' ) ?></dd>
</dl>
</div>
<?php
return ob_get_clean();
}

public function send( $log ) {
$users = $this->params['users'];
$user_emails = array();
Expand Down
1 change: 1 addition & 0 deletions includes/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ public function get_js_options() {
$args['adapters'][$name] = array(
'title' => $options['title'],
'fields' => $options['class']::fields(),
'hints' => $options['class']::hints(),
);
}

Expand Down
22 changes: 19 additions & 3 deletions ui/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ jQuery(function($){
var text = item.text;
if ( typeof item.avatar != 'undefined' ) {
text = item.avatar + item.text;
} else{
console.log('no avatar', item)
}
return text;
},
Expand Down Expand Up @@ -218,7 +216,7 @@ jQuery(function($){

if ( ! options ) { return; }

$this.parent().after( tmpl_alert_options( $.extend( options, { index: index } ) ) );
$this.parent().after( tmpl_alert_options( $.extend( options, { index: index } ) ) );
selectify( $this.parent().next().find('select') );
selectify( $this.parent().next().find('input.tags, input.ajax'), { tags: [] } );
})
Expand Down Expand Up @@ -317,4 +315,22 @@ jQuery(function($){
}
});

divAlerts
.on( 'click', '.toggler', function(e) {
e.preventDefault();
var rel = this.rel,
toggled = $(rel),
toggler = $(this)
;

if ( ! toggled.is(':visible') ) {
toggled.slideDown('fast');
toggler.data( 'text', toggler.text() );
toggler.text( toggler.data('text-toggle') );
} else {
toggled.slideUp('fast');
toggler.text( toggler.data('text') );
}
} );

});
14 changes: 12 additions & 2 deletions views/rule-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,16 @@
<% } %>
</div>
</td>
</div>
</tr>
<% } %>
</div>
<% if ( typeof vars.hints != 'undefined' ) { %>
<tr>
<th></th>
<td><%= vars.hints %></td>
</tr>
<% } %>
</table>

</script>

<style>
Expand Down Expand Up @@ -359,4 +366,7 @@
table.alert-options tbody tr td {
border-top: 1px solid #f5f5f5;
}
.toggled {
display: none;
}
</style>

0 comments on commit 115a24b

Please sign in to comment.