Skip to content

Commit

Permalink
this is a very simple ticket finder, an input field for ticket
Browse files Browse the repository at this point in the history
and a image button with jQuery to redirect to ticket view page.
  • Loading branch information
seanchen committed Feb 15, 2013
1 parent 3ffce32 commit c9cd430
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
19 changes: 19 additions & 0 deletions wp-trac-client/css/trac_ticket.css
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,22 @@ h1 span, h2 span { color: gray; font-size: 90%;}
.ui-autocomplete-loading {
background: white url('../images/ui-anim_basic_16x16.gif') right center no-repeat;
}

/* for ticket finder */
#findTicket {
height: 28px;
padding: 10px 2px 2px 5px;
}
#ticketnumber {
border: 1px solid #DADBD5;
height: 17px;
width: 49px;
display: inline-block;
}
#ticketGo{
float: left;
margin: 0;
padding: 0 0 0 6px;
position: relative;
display: inline-block;
}
Binary file added wp-trac-client/images/ticketGo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions wp-trac-client/templates/page-ticket-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<h2 class='widgettitle'>Sprint Navigation</h2>
<?php echo wptc_widget_version_nav($ticket['project'])?>
</div>
<div id='ticket-finder' class="widget">
<h2 class='widgettitle'>Ticket Finder</h2>
<?php echo wptc_widget_ticket_finder('trac/ticket')?>
</div>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion wp-trac-client/templates/page-tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>
<div id='ticket-finder' class="widget">
<h2 class='widgettitle'>Ticket Finder</h2>
<p>Place Holder for Find Ticket Function</p>
<?php echo wptc_widget_ticket_finder('trac/ticket')?>
</div>
</div>
</div> <?php // END left_column ?>
Expand Down
42 changes: 42 additions & 0 deletions wp-trac-client/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,48 @@ function wptc_widget_version_nav($project) {
return apply_filters('wptc_widget_version_nav', $ret);
}

/**
* the ticket finder widget.
* this is more like a sample.
*/
function wptc_widget_ticket_finder($page_slug=null) {

global $post, $current_blog;
$blog_path = $current_blog->path;
$goImageUrl = plugins_url('wp-trac-client/images/ticketGo.gif');
if($page_slug == null) {
// using the current page to display the ticket.
$page_slug = $post->post_name;
}

$form = <<<EOT
<div id="findTicket">
<div style="float: left;">
<label for="ticketnumber"><b>Find Ticket by ID: </b></label>
<input id="ticketnumber" type="text"
maxlength="10" size="8" name="ticket_id">
</div>
<input id="ticketGo" type="image" alt="Go to Ticket"
name="ticketGo" src="{$goImageUrl}"
title="Go to Ticket">
<script>
jQuery("#ticketGo").click(function(){
var ticket_id = jQuery("#ticketnumber").val();
if((ticket_id != "") && jQuery.isNumeric(ticket_id)) {
// only handle number
// redirect to ticket details page.
ticket_url = "{$blog_path}{$page_slug}?id=" + ticket_id;
window.location = ticket_url;
}
})
</script>
</div>
EOT;

return apply_filters('wptc_widget_ticket_finder', $form);
}

/**
* preparing the user href by using wordpress user information.
*/
Expand Down

0 comments on commit c9cd430

Please sign in to comment.