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 document.body.scrollTop = 0;
46 MTrack.addHandlers($('#ajaxbody'));
47 MTrack.missingHashes($('#ajaxbody'), href)
57 * MTrack.register('a.changeset-link', 'click', function() ....)
60 register : function( selector, event, handler)
62 MTrack.registry.push( {
69 addHandlers : function (toWhat)
71 // forEach? - no IE support?
72 toWhat = toWhat || document.body; //
73 // run the main registry
74 MTrack.registry.forEach(function(cfg) {
76 $(toWhat).find(cfg.selector)[cfg.event](cfg.handler);
78 // any other weird crap goes here.
80 if ($.browser.mozilla) {
81 $(toWhat).find("form").attr("autocomplete", "off");
84 jQuery.timeago.settings.allowFuture = true;
85 $(toWhat).find('abbr.timeinterval').timeago();
87 // multipe select addon
88 $(toWhat).find("select[multiple]").asmSelect({
89 addItemTarget: 'bottom',
98 keepLoggedIn: function()
101 url : baseURL + '/Login.html',
103 data : { refresh : 1 },
104 success : function() {
106 setTimeout(MTrack.keepLoggedIn, 30000);
107 // what if it's false..currentURL = false;
120 $(document).ready(function() {
121 MTrack.addHandlers(); // adds to main body..
123 $('#banner select').change( function(e) {
124 // ajax change project, and refresh body..
126 url : baseURL + '/core_project.html',
127 data : { active_project_id : this.value },
128 success : function() {
129 // what if it's false..currentURL = false;
130 MTrack.ajaxLoad(MTrack.currentURL, true);
141 // any date picers.. - on milestones?
142 MTrack.register('.dateinput', 'datepicker', {
144 dateFormat: 'yy-mm-dd' // nice and compatible..
148 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
153 $(document).ready(function() {
158 $("textarea.wiki").markItUp({
160 previewParserPath: baseURL + "/Preview",
161 root: rootURL + "/js",
162 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
165 name:'Heading 1', key:'1',
166 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
169 name:'Heading 2', key:'2',
170 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
173 name:'Heading 3', key:'3',
174 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
177 name:'Heading 4', key:'4',
178 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
181 name:'Heading 5', key:'5',
182 openWith:'====== ', closeWith:' ======',
183 placeHolder:'Your title here...'
185 {separator:'---------------' },
186 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
187 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
188 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
189 {separator:'---------------' },
190 {name:'Bulleted list', openWith:' * '},
191 {name:'Numeric list', openWith:' 1. '},
192 {separator:'---------------' },
193 {name:'Quotes', openWith:'(!(> |!|>)!)'},
194 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
195 {separator:'---------------' },
196 {name:'Preview', call:'preview', className:'preview'}
200 $.tablesorter.addParser({
203 return /^#\d+/.test(s);
205 format: function(s) {
206 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
211 $.tablesorter.addParser({
217 format: function(s) {
218 // relies on the textExtraction routine below to pull a
219 // date/time string out of the title portion of the abbr tag
220 return $.tablesorter.formatFloat(new Date(s).getTime());
227 $("table.report, table.wiki").tablesorter({
228 textExtraction: function(node) {
229 var kid = node.childNodes[0];
230 if (kid && kid.tagName == 'ABBR') {
231 // assuming that this abbr is of class='timeinterval'
234 // default 'simple' behavior
235 if (kid && kid.hasChildNodes()) {
236 return kid.innerHTML;
238 return node.innerHTML;
243 $('input.search[type=text]').each(function () {
244 if ($.browser.webkit) {
245 this.type = 'search';
246 ///$(this).attr('autosave', ABSWEB+'/');
247 $(this).attr('results', 5);
249 $(this).addClass('roundsearch');
252 // Convert links that are styled after buttons into actual buttons
253 $('a.button[href]').each(function () {
254 var href = $(this).attr('href');
255 var but = $('<button type="button"/>');
256 but.text($(this).text());
257 $(this).replaceWith(but);
258 but.click(function () {
259 document.location.href = href;
264 $.fn.mtrackWatermark = function () {
265 this.each(function () {
266 var ph = $(this).attr('title');
267 if ($.browser.webkit) {
268 // Use native safari placeholder for watermark
269 $(this).attr('placeholder', ph);
271 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
274 me.focus(function () {
277 me.removeClass('watermark').data('w', 0).val('');
283 me.addClass('watermark').data('w', 1).val(ph);
286 .closest('form').submit(function () {
295 // Watermarking -??? what??
296 $('input[title!=""]').mtrackWatermark();
299 // Arrange for the footer to sink to the bottom of the window, if the window
300 // contents are not very tall
303 function mtrack_footer_position(force) {
305 var ele = $('#footer');
307 (last_dh != $(document).height() || last_wh != $(window).height)) {
311 // Force a from-scratch layout assessment; put the footer back in
312 // it's natural location in the doc
314 position: "relative",
319 if ($(document).height() <= $(window).height()) {
321 position: "absolute",
324 $(window).scrollTop() +
331 position: "relative",
335 last_dh = $(document).height();
336 last_wh = $(window).height();
338 window.mtrack_footer_position = mtrack_footer_position;
340 .scroll(mtrack_footer_position)
341 .resize(mtrack_footer_position);
342 function mtrack_footer_set_and_wait() {
344 mtrack_footer_position();
345 setTimeout(function () {
346 mtrack_footer_set_and_wait();
349 mtrack_footer_set_and_wait();
356 // from head -- probably for reports only..
359 $(document).ready(function() {
361 $.tablesorter.addParser({
367 format: function(s) {
368 if (typeof(priorities[s]) != 'undefined') {
369 return priorities[s];
376 $.tablesorter.addParser({
382 format: function(s) {
383 if (typeof(severities[s]) != 'undefined') {
384 return severities[s];
394 $(document).ready(function(){
395 $('ul.wikitree').treeview({