1 //<Script type="text/javascript">
6 * currenlty mostly a clone of the JQuery version..
8 * uses a simple registry - all code get's added to it,
9 * then whenever html is loaded via AJAX, we can run run through the handlers and add them.
19 Roo.onReady(function () {
20 window.mtrack_footer_position();
22 setTimeout(MTrack.keepLoggedIn, 30000);
30 Roo.onReady( function () {
31 var path = [ 'Tree' ];
32 //if (repoName) path.push( repoName );
35 var href = (window.location.pathname + window.location.search).substring(baseURL.length);
37 window.history.pushState( { url: href }, document.title , window.location.pathname + window.location.search );
39 MTrack.currentURL = href;
42 url : window.location.pathname + window.location.search,
43 params: { ajax_body : 1 } ,
44 success : function (data) {
47 $('#ajaxbody').html(data);
48 MTrack.addHandlers($('#ajaxbody'));
49 MTrack.missingHashes($('#ajaxbody'), href)
58 * MTrack.register('a.changeset-link', 'each', function() ....)
59 * MTrack.register('a.changeset-link', 'on', 'click', function() ....)
62 register : function( selector, method, arg1, arg2)
64 MTrack.registry.push( {
67 event : method == 'on' ? arg1 : false,
68 args : method == 'on' ? arg2 : arg1
72 addHandlers : function (toWhat)
74 // forEach? - no IE support?
75 toWhat = toWhat || document.body; //
76 // run the main registry
77 MTrack.registry.forEach(function(cfg) {
78 var el = Roo.get(toWhat).select(cfg.selector,true)
79 el[cfg.method].apply(el, cfg.event ? [ event, args ] : [ args ] );
81 // any other weird crap goes here.
84 Roo.select(toWhat,true).select("form").set( { "autocomplete" : "off" });
87 //jQuery.timeago.settings.allowFuture = true;
88 //$(toWhat).find('abbr.timeinterval').timeago();
90 // multipe select addon
91 //$(toWhat).find("select[multiple]").asmSelect({
92 // addItemTarget: 'bottom',
95 // removeLabel: '[x]',
102 missingHashRequest : false,
105 // This is the main body load tool...
106 // it still needs to handle anchors...
109 ajaxLoad : function(url,slideleft)
111 this.currentURL = url;
112 var target = Roo.get("ajaxbody");
113 var content = Roo.get("content");
114 target.setStyle('position', 'relative');
116 Roo.select('.mask').show(); // must show first?
117 Roo.select('.mask-loading').show();
118 // content has a border...
119 var t = content.getBox().top - Roo.get(document).getScroll().top - 13;
120 var l = content.getBox().left - Roo.get(document).getScroll().top - 13;
121 var w = content.getBox().width+ 26;
122 var h = content.getBox().height + 26;
124 Roo.select('.mask').first().setLocation(l,t);
125 Roo.select('.mask').first().setSize( w , h, false );
127 Roo.select('.mask-loading').first().setLocation(
128 l + ( w / 2) - 16, t + 16
131 if (MTrack.missingHashRequest) {
132 MTrack.missingHashRequest.abort();
133 MTrack.missingHashRequest = false;
135 Roo.get('loader').hide();
138 params : { ajax_body : 1 },
139 success : function(data) {
141 Roo.select('.mask').hide();
142 Roo.get('loader').update(data);
143 Roo.get('loader').show();
144 Roo.get('loader').setWidth( w );
145 Roo.get('loader').setPosition( slideleft? l+w : l-w , t );
149 left: slideleft ? -1 * w : w
153 target.setPosition( 0, 0 ); // reset it at end of animation - as it ends up with the new content.
157 Roo.get('loader').animate(
163 target.update( Roo.get('loader').dom.innerHTML);
164 Roo.get('loader').hide();
165 Roo.get('loader').update("");
166 target.show();// make sure!!
168 MTrack.missingHashes(target, url);
169 MTrack.addHandlers(target);
173 //console.log('loaded dif');
182 missingHashRequest : false,
183 missingHashes: function(el,url) {
184 //console.log('finding missing hashes?');
186 el.select('.browse-missing-hash').each(function() {
187 hashes.push(this.dom.id);
189 if (!hashes.length) {
192 if (MTrack.missingHashRequest) {
193 MTrack.missingHashRequest.abort();
195 MTrack.missingHashRequest = Roo.Ajax.request({
198 params : { hashes : hashes.join(',') },
199 success : function(data) {
200 //console.log(data.data);
202 for(var hash in data.data) {
203 var o = data.data[hash];
204 Roo.select('#'+ hash).first().dom.innerHTML = o.changeby + ' : ' + o.changelog;
205 Roo.select('#age-'+ hash).first().dom.innerHTML = o.age ; // do magic replacement!!!
206 Roo.select('#rev-'+ hash).first().dom.innerHTML = o.rev ; // do magic replacement!!!
207 MTrack.addHandlers(Roo.select('#age-'+ hash).first());
208 MTrack.missingHashRequest = false;
221 Roo.onReady(function() {
222 MTrack.addHandlers(); // adds to main body..
225 Roo.select('#banner select').on('change', function(e) {
226 // ajax change project, and refresh body..
228 url : baseURL + '/Project.html',
229 params : { active_project_id : this.value },
230 success : function() {
231 // what if it's false..currentURL = false;
232 MTrack.ajaxLoad(MTrack.currentURL, true);
245 window.onpopstate = function(ev) {
247 if (!ev.state || typeof(ev.state.url) == 'undefined') {
250 MTrack.ajaxLoad(ev.state.url, false);
260 // any date picers.. - on milestones?
261 MTrack.register('.dateinput', 'each', function(e) {
262 var ee = new Roo.form.DateField({
263 dateFormat: 'Y-m-d' // nice and compatible..
272 MTrack.register('a.browse-link', 'on', 'click', function(event)
274 event.preventDefault();
276 var href= this.getAttribute('href').substring(baseURL.length);
278 window.history.pushState( { url: href }, "Browse : " + href , this.href );
280 var slideleft = $(this).is('.browse-link-up') ? 0 : 1;
281 MTrack.ajaxLoad(href,slideleft);
286 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
291 $(document).ready(function() {
296 $("textarea.wiki").markItUp({
298 previewParserPath: baseURL + "/Preview",
299 root: rootURL + "/js",
300 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
303 name:'Heading 1', key:'1',
304 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
307 name:'Heading 2', key:'2',
308 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
311 name:'Heading 3', key:'3',
312 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
315 name:'Heading 4', key:'4',
316 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
319 name:'Heading 5', key:'5',
320 openWith:'====== ', closeWith:' ======',
321 placeHolder:'Your title here...'
323 {separator:'---------------' },
324 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
325 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
326 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
327 {separator:'---------------' },
328 {name:'Bulleted list', openWith:' * '},
329 {name:'Numeric list', openWith:' 1. '},
330 {separator:'---------------' },
331 {name:'Quotes', openWith:'(!(> |!|>)!)'},
332 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
333 {separator:'---------------' },
334 {name:'Preview', call:'preview', className:'preview'}
338 $.tablesorter.addParser({
341 return /^#\d+/.test(s);
343 format: function(s) {
344 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
349 $.tablesorter.addParser({
355 format: function(s) {
356 // relies on the textExtraction routine below to pull a
357 // date/time string out of the title portion of the abbr tag
358 return $.tablesorter.formatFloat(new Date(s).getTime());
365 $("table.report, table.wiki").tablesorter({
366 textExtraction: function(node) {
367 var kid = node.childNodes[0];
368 if (kid && kid.tagName == 'ABBR') {
369 // assuming that this abbr is of class='timeinterval'
372 // default 'simple' behavior
373 if (kid && kid.hasChildNodes()) {
374 return kid.innerHTML;
376 return node.innerHTML;
381 $('input.search[type=text]').each(function () {
382 if ($.browser.webkit) {
383 this.type = 'search';
384 ///$(this).attr('autosave', ABSWEB+'/');
385 $(this).attr('results', 5);
387 $(this).addClass('roundsearch');
390 // Convert links that are styled after buttons into actual buttons
391 $('a.button[href]').each(function () {
392 var href = $(this).attr('href');
393 var but = $('<button type="button"/>');
394 but.text($(this).text());
395 $(this).replaceWith(but);
396 but.click(function () {
397 document.location.href = href;
402 $.fn.mtrackWatermark = function () {
403 this.each(function () {
404 var ph = $(this).attr('title');
405 if ($.browser.webkit) {
406 // Use native safari placeholder for watermark
407 $(this).attr('placeholder', ph);
409 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
412 me.focus(function () {
415 me.removeClass('watermark').data('w', 0).val('');
421 me.addClass('watermark').data('w', 1).val(ph);
424 .closest('form').submit(function () {
433 // Watermarking -??? what??
434 $('input[title!=""]').mtrackWatermark();
437 // Arrange for the footer to sink to the bottom of the window, if the window
438 // contents are not very tall
441 function mtrack_footer_position(force) {
442 var ele = $('#footer');
444 (last_dh != $(document).height() || last_wh != $(window).height)) {
448 // Force a from-scratch layout assessment; put the footer back in
449 // it's natural location in the doc
451 position: "relative",
456 if ($(document).height() <= $(window).height()) {
458 position: "absolute",
461 $(window).scrollTop() +
468 position: "relative",
472 last_dh = $(document).height();
473 last_wh = $(window).height();
475 window.mtrack_footer_position = mtrack_footer_position;
477 .scroll(mtrack_footer_position)
478 .resize(mtrack_footer_position);
479 function mtrack_footer_set_and_wait() {
480 mtrack_footer_position();
481 setTimeout(function () {
482 mtrack_footer_set_and_wait();
485 mtrack_footer_set_and_wait();
492 // from head -- probably for reports only..
495 $(document).ready(function() {
497 $.tablesorter.addParser({
503 format: function(s) {
504 if (typeof(priorities[s]) != 'undefined') {
505 return priorities[s];
512 $.tablesorter.addParser({
518 format: function(s) {
519 if (typeof(severities[s]) != 'undefined') {
520 return severities[s];
530 $(document).ready(function(){
531 $('ul.wikitree').treeview({