Skip to content

Commit

Permalink
Moving our local jquery-related (but otherwise general) utils into a …
Browse files Browse the repository at this point in the history
…file of their own
  • Loading branch information
scc committed Jun 18, 2008
1 parent f79c91c commit 540b55b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
1 change: 1 addition & 0 deletions plugins/Ajax/PLUGIN
Expand Up @@ -29,6 +29,7 @@ htdoc=htdocs/images/slashbox.js
htdoc=htdocs/images/common.js
htdoc=htdocs/images/nodnix.js
htdoc=htdocs/images/jquery/jquery-1.2.6.js
htdoc=htdocs/images/jquery/slashdot.jquery.js
htdoc=htdocs/images/sectionprefs.js
requiresplugin=ResKey
template=templates/ajax_reskey_signoff;misc;default
Expand Down
38 changes: 0 additions & 38 deletions plugins/Ajax/htdocs/images/common.js
@@ -1,44 +1,6 @@
// _*_ Mode: JavaScript; tab-width: 8; indent-tabs-mode: true _*_
// $Id$

function $dom( id ) {
return document.getElementById(id);
}

jQuery.fn.extend({

mapClass: function( map ) {
map['?'] = map['?'] || [];
return this.each(function() {
var unique = {};
var cl = [];
$.each($.map(this.className.split(/\s+/), function(k){
return k in map ? map[k] : ('*' in map ? map['*'] : k)
}).concat(map['+']), function(i, k) {
if ( k && !(k in unique) ) {
unique[k] = true;
cl.push(k);
}
});
this.className = (cl.length ? cl : map['?']).join(' ');
});
},

setClass: function( c1 ) {
return this.each(function() {
this.className = c1
});
},

toggleClasses: function( c1, c2, force ) {
var map = { '?': force };
map[c1]=c2;
map[c2]=c1;
return this.mapClass(map);
}

});

var reskey_static = '';

// global settings, but a firehose might use a local settings object instead
Expand Down
39 changes: 39 additions & 0 deletions plugins/Ajax/htdocs/images/jquery/slashdot.jquery.js
@@ -0,0 +1,39 @@
// slashdot.jquery.js: jquery-related general utilities we wrote ourselves

function $dom( id ) {
return document.getElementById(id);
}

jQuery.fn.extend({

mapClass: function( map ) {
map['?'] = map['?'] || [];
return this.each(function() {
var unique = {};
var cl = [];
$.each($.map(this.className.split(/\s+/), function(k){
return k in map ? map[k] : ('*' in map ? map['*'] : k)
}).concat(map['+']), function(i, k) {
if ( k && !(k in unique) ) {
unique[k] = true;
cl.push(k);
}
});
this.className = (cl.length ? cl : map['?']).join(' ');
});
},

setClass: function( c1 ) {
return this.each(function() {
this.className = c1
});
},

toggleClasses: function( c1, c2, force ) {
var map = { '?': force };
map[c1]=c2;
map[c2]=c1;
return this.mapClass(map);
}

});
1 change: 1 addition & 0 deletions themes/slashcode/templates/html-header;misc;default
Expand Up @@ -29,6 +29,7 @@ __template__
[% END -%]
[%- IF constants.plugin.Ajax %]
<script src="[% constants.imagedir %]/jquery/jquery-1.2.6.js?[% constants.cvs_tag_currentcode %]" type="text/javascript"></script>
<script src="[% constants.imagedir %]/jquery/slashdot.jquery.js?[% constants.cvs_tag_currentcode %]" type="text/javascript"></script>
<script src="[% constants.imagedir %]/yui/yahoo.js?[% constants.cvs_tag_currentcode %]" type="text/javascript"></script>
<script src="[% constants.imagedir %]/yui/dom.js?[% constants.cvs_tag_currentcode %]" type="text/javascript"></script>
<script src="[% constants.imagedir %]/yui/event.js?[% constants.cvs_tag_currentcode %]" type="text/javascript"></script>
Expand Down

0 comments on commit 540b55b

Please sign in to comment.