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.
18 $(document).ready(function () {
19 window.mtrack_footer_position();
21 setTimeout(MTrack.keepLoggedIn, 30000);
29 $(document).ready(function () {
30 var path = [ 'Tree' ];
31 //if (repoName) path.push( repoName );
34 var href = (window.location.pathname + window.location.search).substring(baseURL.length);
36 window.history.pushState( { url: href }, document.title , window.location.pathname + window.location.search );
38 MTrack.currentURL = href;
41 url : window.location.pathname + window.location.search,
42 data : { ajax_body : 1 } ,
43 success : function (data) {
44 $('#ajaxbody').html(data);
45 MTrack.addHandlers($('#ajaxbody'));
46 MTrack.missingHashes($('#ajaxbody'), href)
56 * MTrack.register('a.changeset-link', 'click', function() ....)
59 register : function( selector, event, handler)
61 MTrack.registry.push( {
68 addHandlers : function (toWhat)
70 // forEach? - no IE support?
71 toWhat = toWhat || document.body; //
72 // run the main registry
73 MTrack.registry.forEach(function(cfg) {
75 $(toWhat).find(cfg.selector)[cfg.event](cfg.handler);
77 // any other weird crap goes here.
79 if ($.browser.mozilla) {
80 $(toWhat).find("form").attr("autocomplete", "off");
83 jQuery.timeago.settings.allowFuture = true;
84 $(toWhat).find('abbr.timeinterval').timeago();
86 // multipe select addon
87 $(toWhat).find("select[multiple]").asmSelect({
88 addItemTarget: 'bottom',
97 keepLoggedIn: function()
100 url : baseURL + '/Login.html',
102 data : { refresh : 1 },
103 success : function() {
105 setTimeout(MTrack.keepLoggedIn, 30000);
106 // what if it's false..currentURL = false;
119 $(document).ready(function() {
120 MTrack.addHandlers(); // adds to main body..
122 $('#banner select').change( function(e) {
123 // ajax change project, and refresh body..
125 url : baseURL + '/Project.html',
126 data : { active_project_id : this.value },
127 success : function() {
128 // what if it's false..currentURL = false;
129 MTrack.ajaxLoad(MTrack.currentURL, true);
140 // any date picers.. - on milestones?
141 MTrack.register('.dateinput', 'datepicker', {
143 dateFormat: 'yy-mm-dd' // nice and compatible..
147 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
152 $(document).ready(function() {
157 $("textarea.wiki").markItUp({
159 previewParserPath: baseURL + "/Preview",
160 root: rootURL + "/js",
161 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
164 name:'Heading 1', key:'1',
165 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
168 name:'Heading 2', key:'2',
169 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
172 name:'Heading 3', key:'3',
173 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
176 name:'Heading 4', key:'4',
177 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
180 name:'Heading 5', key:'5',
181 openWith:'====== ', closeWith:' ======',
182 placeHolder:'Your title here...'
184 {separator:'---------------' },
185 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
186 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
187 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
188 {separator:'---------------' },
189 {name:'Bulleted list', openWith:' * '},
190 {name:'Numeric list', openWith:' 1. '},
191 {separator:'---------------' },
192 {name:'Quotes', openWith:'(!(> |!|>)!)'},
193 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
194 {separator:'---------------' },
195 {name:'Preview', call:'preview', className:'preview'}
199 $.tablesorter.addParser({
202 return /^#\d+/.test(s);
204 format: function(s) {
205 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
210 $.tablesorter.addParser({
216 format: function(s) {
217 // relies on the textExtraction routine below to pull a
218 // date/time string out of the title portion of the abbr tag
219 return $.tablesorter.formatFloat(new Date(s).getTime());
226 $("table.report, table.wiki").tablesorter({
227 textExtraction: function(node) {
228 var kid = node.childNodes[0];
229 if (kid && kid.tagName == 'ABBR') {
230 // assuming that this abbr is of class='timeinterval'
233 // default 'simple' behavior
234 if (kid && kid.hasChildNodes()) {
235 return kid.innerHTML;
237 return node.innerHTML;
242 $('input.search[type=text]').each(function () {
243 if ($.browser.webkit) {
244 this.type = 'search';
245 ///$(this).attr('autosave', ABSWEB+'/');
246 $(this).attr('results', 5);
248 $(this).addClass('roundsearch');
251 // Convert links that are styled after buttons into actual buttons
252 $('a.button[href]').each(function () {
253 var href = $(this).attr('href');
254 var but = $('<button type="button"/>');
255 but.text($(this).text());
256 $(this).replaceWith(but);
257 but.click(function () {
258 document.location.href = href;
263 $.fn.mtrackWatermark = function () {
264 this.each(function () {
265 var ph = $(this).attr('title');
266 if ($.browser.webkit) {
267 // Use native safari placeholder for watermark
268 $(this).attr('placeholder', ph);
270 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
273 me.focus(function () {
276 me.removeClass('watermark').data('w', 0).val('');
282 me.addClass('watermark').data('w', 1).val(ph);
285 .closest('form').submit(function () {
294 // Watermarking -??? what??
295 $('input[title!=""]').mtrackWatermark();
298 // Arrange for the footer to sink to the bottom of the window, if the window
299 // contents are not very tall
302 function mtrack_footer_position(force) {
303 var ele = $('#footer');
305 (last_dh != $(document).height() || last_wh != $(window).height)) {
309 // Force a from-scratch layout assessment; put the footer back in
310 // it's natural location in the doc
312 position: "relative",
317 if ($(document).height() <= $(window).height()) {
319 position: "absolute",
322 $(window).scrollTop() +
329 position: "relative",
333 last_dh = $(document).height();
334 last_wh = $(window).height();
336 window.mtrack_footer_position = mtrack_footer_position;
338 .scroll(mtrack_footer_position)
339 .resize(mtrack_footer_position);
340 function mtrack_footer_set_and_wait() {
341 mtrack_footer_position();
342 setTimeout(function () {
343 mtrack_footer_set_and_wait();
346 mtrack_footer_set_and_wait();
353 // from head -- probably for reports only..
356 $(document).ready(function() {
358 $.tablesorter.addParser({
364 format: function(s) {
365 if (typeof(priorities[s]) != 'undefined') {
366 return priorities[s];
373 $.tablesorter.addParser({
379 format: function(s) {
380 if (typeof(severities[s]) != 'undefined') {
381 return severities[s];
391 $(document).ready(function(){
392 $('ul.wikitree').treeview({