From 1110cf7a339fea54030dab7912555dde4889ac14 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Sun, 27 Jan 2013 18:35:26 -0500 Subject: [PATCH] the jquery-ui autocomplete prototype for reassign actions. jquery-ui is pretty easy to use! --- wp-trac-client/ajax.php | 24 ++++++++++++++++++ wp-trac-client/css/trac_ticket.css | 5 ++++ wp-trac-client/images/ui-anim_basic_16x16.gif | Bin 0 -> 1459 bytes wp-trac-client/js/trac-wikitoolbar.js | 18 ++++++++++++- .../templates/page-ticket-details.php | 4 +++ wp-trac-client/widgets.php | 7 +++-- wp-trac-client/wp-trac-client.php | 5 +++- 7 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 wp-trac-client/images/ui-anim_basic_16x16.gif diff --git a/wp-trac-client/ajax.php b/wp-trac-client/ajax.php index bfa25de..05ba5b5 100644 --- a/wp-trac-client/ajax.php +++ b/wp-trac-client/ajax.php @@ -1,5 +1,29 @@ Wip zr1+)TIKaUJCb)3nLQ_*yOiaw=qF!qFketMoIjjxu+*ELIq3^F;|~!D}xJWooB?$cBKq{?z$?hNo|cNFAPo` zO&OTQC}y}+m@%P=WhA$rVnnh{7SX(PoVYv)TAFz|#t}bjGsZt@H(&cIJk_o%TK$P8 z&W+_ANA|oaG-UsCh~PsE`m$&m=VJlYpSd>1NRj}UnXH$GV0woD@cLQj6Rf^=McCnB zg+*<5$0ufhHcqTUQ*f2Fs7ya!*`Tg8=_L@pu5UEdC?Ry0lRXBRtnC}?^b)ls@VafK zO%*|@Ha-=PlK$X9<|fzB!opOt@XO$X`Jt~6aj!psv%Ex;MJIGlWF>?xz2uIpJiAKi zUU(I#D$IsD3p&`sc{@Nbp8*)XG|-*Sjba<3B*P`0w9?g%FRbS|WtQ;(0x-bSj(V~G z?4Y5JcE!V7`lxm!L-?}b+%G>94EO7IpV&3_4tR)Wogv4hEE$zEEmhH_5p^s$wHroE z_p-^!FhfOEG0*xDLq_h$1t?7264baJFYhw2^8Bu3sI^Uzy^-#PG;NcZMrou5t1a~!Fx&L zqTF*i=y!*63|dySwPRn6=THf65kfW}3iGuN^tGOo+2(TI1ubJI`x>N2qH}6(;WgLl z#tqoCOiY-u4SJrP5{p%@gmkIg(nPtn9%DBmp{~1FXHu%CKrikbOKtgyB*o)S8D6y^ zd?Z02c4RIuOX!iQ^4JKKth?L+w!SSv^kMTOXQ2;*||OP8`L)bqdZ6=hG3znjBdyouQC- z2{|0(#LB*c*Y@m8w%x8e$)!>@aePd#Gz1{;x;$GLm$RD-;+&E4OTfN^l#oYz+pl{9 ztGltv^dIhTL5CU(YkuB>N{G0Dv}w(IDcts{ZL`6#^nPt?i$=m{D23_}=zdLGKobnbKO&IVDbBU4*Z5%!iq zwd4gy;B|a{6z_Y3ZCGELzjfi*#NXQob_F!etMeQXTP?>q_esTGgPMt!lYSi3Dk%lV zFj`-5x050$NZ}(6i)}hQkYTlvY8Qp-Z!otT;M%|JB!Kwrq1mAuVh-s8J`2(Z^xnPt zR!4ECmU?MGIlsK8xxEj(F5}*c?K-Fx9TCTsJOoyoO->S0t0Ql}USDv~FFZ_3wlL+k zE`6{8Ds$jwATl0?qVdNe@X*G7G+tihnA%zLE@dA$P0U95A6u*S^xk5 literal 0 HcmV?d00001 diff --git a/wp-trac-client/js/trac-wikitoolbar.js b/wp-trac-client/js/trac-wikitoolbar.js index 76250ae..a5531c3 100644 --- a/wp-trac-client/js/trac-wikitoolbar.js +++ b/wp-trac-client/js/trac-wikitoolbar.js @@ -1,6 +1,7 @@ (function($){ - + + // trac wiki toolbar window.addWikiFormattingToolbar = function(textarea) { if ((document.selection == undefined) && (textarea.setSelectionRange == undefined)) { @@ -124,6 +125,21 @@ jQuery(document).ready(function($) { // attach folding function to foldable class. $(".foldable").enableFolding(false, true); + // username auto complete for re-assign action. + var wptc_username_ac = "wptc_username_autocomplete" + $("#action_reassign_reassign_owner").autocomplete({ + source: function(request, response) { + $.getJSON(WptcAjaxObj.url + "?callback=?&action=" + + wptc_username_ac, request, response); + }, + minLength: 2, + select: function(event, ui) { + // selected value could get from ui param. + // ui.item.id, ui.item.value. + alert (ui.item.value); + } + }); + // only enable control elements for // the currently selected action var actions = $("#action input[name='action']"); diff --git a/wp-trac-client/templates/page-ticket-details.php b/wp-trac-client/templates/page-ticket-details.php index 9e41ece..4e18fe5 100644 --- a/wp-trac-client/templates/page-ticket-details.php +++ b/wp-trac-client/templates/page-ticket-details.php @@ -3,9 +3,13 @@ * Template Name: Trac Ticket Details * Description: a page to show the details for a ticket. */ +wp_enqueue_script('jquery-ui-autocomplete'); // enqueue styles and scripts for trac project. wp_enqueue_style('wptc-trac-ticket'); wp_enqueue_script('wptc-trac-wikitoolbar'); +wp_localize_script('wptc-trac-wikitoolbar', 'WptcAjaxObj', + array('url' => admin_url('admin-ajax.php'))); +wp_enqueue_style('jquery-ui'); // you may not need the following section if you // don't have tiny-mce comments plugin installed. diff --git a/wp-trac-client/widgets.php b/wp-trac-client/widgets.php index 87771ca..9de5853 100644 --- a/wp-trac-client/widgets.php +++ b/wp-trac-client/widgets.php @@ -469,14 +469,13 @@ function wptc_widget_action_resolve($action) { function wptc_widget_action_reassign($action) { $fields = $action[3][0]; - $options = wptc_widget_options_html($fields[2], $fields[1]); + //$options = wptc_widget_options_html($fields[2], $fields[1]); // the resolve is a select element. // it will be disabled untile the radio button is selected. $select = << - {$options} - + +{$options} EOT; return apply_filters('wptc_widget_action_reassign', $select); diff --git a/wp-trac-client/wp-trac-client.php b/wp-trac-client/wp-trac-client.php index f1e6185..0efae5f 100644 --- a/wp-trac-client/wp-trac-client.php +++ b/wp-trac-client/wp-trac-client.php @@ -87,7 +87,10 @@ function register_resources() { // using wp_enqueue_style to load this css. // jquery ui dialog style seens not automatically loaded. wp_register_style('jquery-ui', - 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css'); + 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css'); + // javascript for autocomplete. + wp_register_script('wptc-autocomplete', + plugins_url('wt-trac-client/js/wptc-autocomplete.js')); } function get_wptc_client() {