Skip to content

Commit

Permalink
make autocomplete set top tags via ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
scc committed Oct 10, 2006
1 parent 8e66f9b commit f14ab12
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
9 changes: 9 additions & 0 deletions plugins/Ajax/htdocs/images/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ function tagsCreateForUrl(id) {
}

//Firehose functions begin
function setOneTopTagForFirehose(id, newtag) {
var params = [];
params['op'] = 'firehose_update_one_tag';
params['id'] = id;
params['tags'] = newtag;
params['reskey'] = reskeyel.value;
ajax_update(params, '');
}

function tagsCreateForFirehose(id) {
var toggletags_message_id = 'toggletags-message-' + id;
var toggletags_message_el = $(toggletags_message_id);
Expand Down
18 changes: 16 additions & 2 deletions plugins/Ajax/htdocs/images/sd_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ YAHOO.slashdot.AutoCompleteWidget.prototype._show = function( obj, callbackParam
{
this._sourceEl = obj;
this._callbackParams = callbackParams;
this._callbackParams._tagDomain = tagDomain;
this._completer = this._newCompleter(tagDomain);

if ( this._sourceEl && YAHOO.util.Dom.hasClass(this._widget, "hidden") )
Expand Down Expand Up @@ -334,11 +335,24 @@ YAHOO.slashdot.AutoCompleteWidget.prototype._onItemSelectEvent = function( type,
if ( tagname && me._sourceEl )
{
me._sourceEl.innerHTML = tagname;
YAHOO.util.Dom.addClass(me._sourceEl, "not-yet-saved");
// YAHOO.util.Dom.addClass(me._sourceEl, "not-yet-saved");
}
var p = me._callbackParams;
me._hide();
tagsOpenAndEnter(p._id, tagname, p._is_admin, p._type);

// really need to move this into a separate function...
// at least when there is more than just p._type=='firehose'
switch ( p._tagDomain )
{
case 1: // action
case 2: // section
case 3: // topic
setOneTopTagForFirehose(p._id, tagname);
break;

default:
tagsOpenAndEnter(p._id, tagname, p._is_admin, p._type);
}
}

YAHOO.slashdot.AutoCompleteWidget.prototype._onTextboxBlurEvent = function( type, args, me )
Expand Down
9 changes: 9 additions & 0 deletions plugins/FireHose/FireHose.pm
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,15 @@ sub rejectItem {

}

sub ajaxSaveOneTopTagFirehose {
my($slashdb, $constants, $user, $form, $options) = @_;
my $id = $form->{id};
my $tagsstring = $form->{tags};
if ($user->{is_admin}) {
$firehose->setSectionTopicsFromTagstring($id, $tagsstring);
}
}

sub ajaxSaveNoteFirehose {
my($slashdb, $constants, $user, $form) = @_;
my $id = $form->{id};
Expand Down
5 changes: 2 additions & 3 deletions plugins/FireHose/templates/firehose_tags_top;misc;default
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ __seclev__
__template__
[% IF tags_top.size %]
[% FOR t = tags_top;
parts = t.split(":");
parts.1 = parts.1 || "0"; %]
<span class="tagname">[% IF user.tags_canwrite_stories %]<a onClick="attachCompleter(this, '[% id %]','[% user.is_admin %]','firehose', [% parts.1 %])">[% END %][% parts.0 | strip_html %][% IF user.tags_canwrite_stories %]</a>[% END %]</span>[% IF !loop.last() %], [% END -%]
parts = t.split(":"); %]
<span class="tagname">[% IF user.tags_canwrite_stories && parts.1.defined) %]<a onClick="attachCompleter(this, '[% id %]','[% user.is_admin %]','firehose', [% parts.1 %])">[% END %][% parts.0 | strip_html %][% IF user.tags_canwrite_stories && parts.1.defined %]</a>[% END %]</span>[% IF !loop.last() %], [% END -%]
[%- END %]
[% END %]
1 change: 1 addition & 0 deletions sql/mysql/upgrades
Original file line number Diff line number Diff line change
Expand Up @@ -4041,6 +4041,7 @@ ALTER TABLE users_info CHANGE COLUMN mods_saved m2_mods_saved varchar(120) NOT N
# Updates for plugins/FireHose
INSERT INTO ajax_ops VALUES (NULL, 'firehose_fetch_new', 'Slash::FireHose', 'ajaxFireHoseFetchNew', 'ajax_user', 'createuse');
INSERT INTO ajax_ops VALUES (NULL, 'firehose_check_removed', 'Slash::FireHose', 'ajaxFireHoseCheckRemoved', 'ajax_user', 'createuse');
INSERT INTO ajax_ops VALUES (NULL, 'firehose_update_one_tag', 'Slash::FireHose', 'ajaxSaveOneTopTagFirehose', 'ajax_user', 'createuse');

# 2006-09-06
UPDATE vars SET value = 'T_2_5_0_125' WHERE name = 'cvs_tag_currentcode';
Expand Down

0 comments on commit f14ab12

Please sign in to comment.