Permalink
Browse files

TagUI: always install complete tag-ui

Until now, we used firehose_init_tag_ui() the firehose list page (or anything with a #firehoselist),
and tag_ui_init_new_articles() anywhere else (presuming that most fireshose functions won't work on
something that's not the firehose.  With this commit, we:
  - eliminate tag_ui_init_new_articles(); now everything goes through firehose_init_tag_ui()
  - make firehose_init_tag_ui() check for capabilities, e.g., install nod/nix handling if the updown buttons are found
  - relax the constraints on what defines an article, now anything with a class 'article'
  - in the case where #firehoselist isn't found, install click handler directly on each article
  - recognize user.is_admin in a larger context than fh_is_admin
  - process the init_tag_ui template much higher, now right after js includes --- everybody gets it
  - removed a stale plugin from FireHose/PLUGIN
  • Loading branch information...
1 parent 8591b3f commit 6661bd065ebf099f18a5cc24de1322354c9ddbe3 @wolf wolf committed Dec 18, 2008
View
64 plugins/Ajax/htdocs/images/common.js
@@ -749,69 +749,61 @@ function firehose_handle_comment_nodnix( commands ){
}
-function tag_ui_init_new_articles(){
- if ( $('#firehose').length ) {
- return firehose_init_tag_ui();
- }
-
- var $new_articles = $(document).article_info__find_articles(':not(:has(span.sd-info-block .tag-ui))');
- $new_articles.
- click(firehose_click_tag).
- each(function(){
- install_tag_server(this);
- this.command_pipeline.push(firehose_handle_context_triggers);
- });
- $init_tag_widgets($new_articles.find('.tag-widget-stub'));
- init_tag_ui_styles($new_articles);
- $new_articles.article_info('tag-ui', true);
- return $new_articles;
-}
-
$(function(){
- tag_ui_init_new_articles();
+ firehose_init_tag_ui();
+ $('#firehoselist').click(firehose_click_tag); // if no #firehoselist, install click handler per article
});
function firehose_init_tag_ui( $new_entries ){
+ var $firehoselist = $('#firehoselist');
+
if ( ! $new_entries || ! $new_entries.length ) {
- var $firehoselist = $('#firehoselist');
if ( $firehoselist.length ) {
$new_entries = $firehoselist.children('[id^=firehose-][class*=article]');
} else {
- $new_entries = $('[id^=firehose-][class*=article]');
+ $new_entries = $('[class*=article]');
}
}
$new_entries = $new_entries.filter(':not([tag-server])');
+ var have_nodnix = $new_entries.children('[id^=updown-]').length;
$new_entries.
each(function(){
var $this = $(this), id = firehose_id_of(this);
install_tag_server(this, id);
- if ( fh_is_admin ) {
+ if ( tag_admin ) {
this.command_pipeline.push(firehose_handle_admin_commands);
}
- this.command_pipeline.push(
- firehose_handle_context_triggers,
- ($this.attr('type') == 'comment') ?
- firehose_handle_comment_nodnix :
- firehose_handle_nodnix );
-
- $this.
- find('> h3').
- append('<div class="tag-widget-stub nod-nix-reasons" init="context_timeout:15000">' +
- '<div class="tag-display-stub" context="related" init="menu:false" />' +
- '</div>').
- find('.tag-display-stub').
- click(firehose_click_nodnix_reason);
+ this.command_pipeline.push(firehose_handle_context_triggers);
+
+ if ( have_nodnix ) {
+ // install nod/nix handling only if I see the nod/nix buttons
+ this.command_pipeline.push(
+ ($this.attr('type') == 'comment') ?
+ firehose_handle_comment_nodnix :
+ firehose_handle_nodnix);
+ $this.
+ find('> h3').
+ append('<div class="tag-widget-stub nod-nix-reasons" init="context_timeout:15000">' +
+ '<div class="tag-display-stub" context="related" init="menu:false" />' +
+ '</div>').
+ find('.tag-display-stub').
+ click(firehose_click_nodnix_reason);
+ }
});
+ if ( ! $firehoselist.length ) {
+ $new_entries.click(firehose_click_tag);
+ }
+
var $widgets = $init_tag_widgets($new_entries.find('.tag-widget-stub'));
- if ( fh_is_admin ) {
+ if ( tag_admin ) {
$widgets.
filter('.body-widget').
each(function(){
View
4 plugins/Ajax/htdocs/images/tag-ui.js
@@ -443,7 +443,7 @@ function $init_tag_displays( $stubs, options ){
$init_tag_displays.default_menu = 'x !';
$(function(){
- if ( fh_is_admin ) {
+ if ( tag_admin ) {
$init_tag_displays.default_menu = 'x ! # ## _ ^';
}
});
@@ -1034,7 +1034,7 @@ YAHOO.slashdot.topicTags = ["keyword",
update_class_map(well_known_tags, 'p', ['mainpage']); // Rob requests 'mainpage' never show its face
update_class_map(well_known_tags, 'd p', data_types);
- if ( fh_is_admin ) {
+ if ( tag_admin ) {
update_class_map(well_known_tags, 'w p', ['signed', 'unsigned', 'signoff']);
update_class_map(well_known_tags, 'd', ['unknown']); // Tags.pm debugging
} else {
View
6 plugins/Ajax/templates/init_tag_ui;misc;default
@@ -15,9 +15,11 @@ init_tag_ui
__seclev__
10000
__template__
+[% IF !user.state.init_tag_ui_already_processed %]
[% tags_reader = Slash.getObject('Slash::Tags', { db_type => 'reader' });
postags = tags_reader.getPositivePopupTags.sort;
negtags = tags_reader.getNegativePopupTags.sort;
+ user.state.init_tag_ui_already_processed = 1;
-%]
<script type="text/javascript">
var suggestions_for_context = {
@@ -29,8 +31,10 @@ var suggestions_for_context = {
[% END %]
metanod: 'insightful interesting informative funny underrated',
metanix: 'offtopic flamebait troll redundant overrated'
-}
+};
+var tag_admin = [% IF user.is_admin %]true[% ELSE %]false[% END %];
</script>
+[% END %]
__version__
$Id$
View
1 plugins/FireHose/PLUGIN
@@ -33,7 +33,6 @@ template=templates/paginate;firehose;default
template=templates/portalmap;firehose;default
template=templates/reject_firehose;misc;default
template=templates/tag_widget;firehose;default
-template=templates/init_tag_ui;firehose;default
task=firehose_reject_old.pl
task=firehose_track_volume.pl
task=firehose_backend.pl
View
2 plugins/FireHose/templates/list;firehose;default
@@ -64,7 +64,6 @@ __template__
[% IF form.metamod %]
<div id="metamodwrap">
[% END %]
-[% PROCESS init_tag_ui -%]
[% firehose = Slash.getObject("Slash::FireHose"); %]
[% IF env.script_name == "/firehose.pl" || env.script_name == "/index2.pl" || form.ssi %]
[% ua = env.HTTP_USER_AGENT %]
@@ -265,7 +264,6 @@ $(function(){
}
});
- $('#firehoselist').click(firehose_click_tag);
if ( fh_is_admin ) {
firehose_init_note_flags();
}
View
1 plugins/FireHose/templates/view;firehose;default
@@ -26,7 +26,6 @@ __template__
[% firehosetext %]
</div>
</div>
-[% PROCESS init_tag_ui %]
<script type="text/javascript">
var firehose_user_class = [% user.is_anon ? 0 : 1 %];
$(function(){
View
1 themes/slashcode/templates/display;article;default
@@ -19,7 +19,6 @@ en_US
__name__
display
__template__
-[% PROCESS init_tag_ui %]
<div id="slashboxes">
[% UNLESS user.lowbandwidth %]
[% PROCESS userboxes hits = story.hits stoid = story.stoid; %]
View
1 themes/slashcode/templates/html-header;misc;default
@@ -55,6 +55,7 @@ __template__
[% IF user.is_admin -%]
<script src="[% constants.imagedir %]/admin.js?[% constants.cvs_tag_currentcode %]" type="text/javascript"></script>
[% END %]
+[% PROCESS init_tag_ui %]
[% PROCESS ajax_reskey_tag reskey_label => 'reskey_static', reskey_name => 'ajax_user_static', reskey_tag_js => 2 %]
[% END # constants.plugin.Ajax %]
__seclev__

0 comments on commit 6661bd0

Please sign in to comment.