1 //<Script type="text/javascript">
4 * The way JQuery is used, we need to continually re-apply the css handlers whenever a new segment is loaded.
6 * to solve this, we will use a simple mtrack.registry - all code get's added to it,
7 * then whenever html is loaded via AJAX, we can run run through the handlers and add them.
17 * MTrack.register('a.changeset-link', 'click', function() ....)
20 register : function( selector, event, handler)
22 MTrack.registry.push( {
29 addHandlers : function (toWhat)
31 // forEach? - no IE support?
32 toWhat = toWhat || document.body; //
33 // run the main registry
34 MTrack.registry.forEach(function(cfg) {
36 $(toWhat).find(cfg.selector)[cfg.event](cfg.handler);
38 // any other weird crap goes here.
40 if ($.browser.mozilla) {
41 $(toWhat).find("form").attr("autocomplete", "off");
44 jQuery.timeago.settings.allowFuture = true;
45 $(toWhat).find('abbr.timeinterval').timeago();
47 // multipe select addon
48 $(toWhat).find("select[multiple]").asmSelect({
49 addItemTarget: 'bottom',
60 $(document).ready(function() {
61 MTrack.addHandlers(); // adds to main body..
66 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
71 $(document).ready(function() {
76 $("textarea.wiki").markItUp({
78 previewParserPath: baseURL + "/Preview",
79 root: rootURL + "/js",
80 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
83 name:'Heading 1', key:'1',
84 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
87 name:'Heading 2', key:'2',
88 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
91 name:'Heading 3', key:'3',
92 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
95 name:'Heading 4', key:'4',
96 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
99 name:'Heading 5', key:'5',
100 openWith:'====== ', closeWith:' ======',
101 placeHolder:'Your title here...'
103 {separator:'---------------' },
104 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
105 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
106 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
107 {separator:'---------------' },
108 {name:'Bulleted list', openWith:' * '},
109 {name:'Numeric list', openWith:' 1. '},
110 {separator:'---------------' },
111 {name:'Quotes', openWith:'(!(> |!|>)!)'},
112 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
113 {separator:'---------------' },
114 {name:'Preview', call:'preview', className:'preview'}
118 $.tablesorter.addParser({
121 return /^#\d+/.test(s);
123 format: function(s) {
124 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
129 $.tablesorter.addParser({
135 format: function(s) {
136 // relies on the textExtraction routine below to pull a
137 // date/time string out of the title portion of the abbr tag
138 return $.tablesorter.formatFloat(new Date(s).getTime());
145 $("table.report, table.wiki").tablesorter({
146 textExtraction: function(node) {
147 var kid = node.childNodes[0];
148 if (kid && kid.tagName == 'ABBR') {
149 // assuming that this abbr is of class='timeinterval'
152 // default 'simple' behavior
153 if (kid && kid.hasChildNodes()) {
154 return kid.innerHTML;
156 return node.innerHTML;
161 $('input.search[type=text]').each(function () {
162 if ($.browser.webkit) {
163 this.type = 'search';
164 ///$(this).attr('autosave', ABSWEB+'/');
165 $(this).attr('results', 5);
167 $(this).addClass('roundsearch');
170 // Convert links that are styled after buttons into actual buttons
171 $('a.button[href]').each(function () {
172 var href = $(this).attr('href');
173 var but = $('<button type="button"/>');
174 but.text($(this).text());
175 $(this).replaceWith(but);
176 but.click(function () {
177 document.location.href = href;
182 $.fn.mtrackWatermark = function () {
183 this.each(function () {
184 var ph = $(this).attr('title');
185 if ($.browser.webkit) {
186 // Use native safari placeholder for watermark
187 $(this).attr('placeholder', ph);
189 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
192 me.focus(function () {
195 me.removeClass('watermark').data('w', 0).val('');
201 me.addClass('watermark').data('w', 1).val(ph);
204 .closest('form').submit(function () {
213 // Watermarking -??? what??
214 $('input[title!=""]').mtrackWatermark();
217 // Arrange for the footer to sink to the bottom of the window, if the window
218 // contents are not very tall
221 function mtrack_footer_position(force) {
222 var ele = $('#footer');
224 (last_dh != $(document).height() || last_wh != $(window).height)) {
228 // Force a from-scratch layout assessment; put the footer back in
229 // it's natural location in the doc
231 position: "relative",
236 if ($(document).height() <= $(window).height()) {
238 position: "absolute",
241 $(window).scrollTop() +
248 position: "relative",
252 last_dh = $(document).height();
253 last_wh = $(window).height();
255 window.mtrack_footer_position = mtrack_footer_position;
257 .scroll(mtrack_footer_position)
258 .resize(mtrack_footer_position);
259 function mtrack_footer_set_and_wait() {
260 mtrack_footer_position();
261 setTimeout(function () {
262 mtrack_footer_set_and_wait();
265 mtrack_footer_set_and_wait();
272 // from head -- probably for reports only..
275 $(document).ready(function() {
277 $.tablesorter.addParser({
283 format: function(s) {
284 if (typeof(priorities[s]) != 'undefined') {
285 return priorities[s];
292 $.tablesorter.addParser({
298 format: function(s) {
299 if (typeof(severities[s]) != 'undefined') {
300 return severities[s];
310 $(document).ready(function(){
311 $('ul.wikitree').treeview({