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.
17 Roo.onReady(function () {
18 MTrack.footerSetAndWait();
20 setTimeout(MTrack.keepLoggedIn, 30000);
28 Roo.onReady( function () {
29 var path = [ 'Tree' ];
30 //if (repoName) path.push( repoName );
33 var href = (window.location.pathname + window.location.search).substring(baseURL.length);
35 window.history.pushState( { url: href }, document.title , window.location.pathname + window.location.search );
37 MTrack.currentURL = href;
40 url : window.location.pathname + window.location.search,
41 params: { ajax_body : 1 } ,
42 success : function (data) {
43 var ab = Roo.get('ajaxbody');
44 ab.dom.innerHTML = data.responseText;
45 MTrack.addHandlers(ab);
46 MTrack.missingHashes(ab, href)
55 * MTrack.register('a.changeset-link', 'each', function() ....)
56 * MTrack.register('a.changeset-link', 'on', 'click', function() ....)
59 register : function( selector, method, arg1, arg2)
61 MTrack.registry.push( {
64 event : method == 'on' ? arg1 : false,
65 args : method == 'on' ? arg2 : arg1
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 var el = Roo.get(toWhat).select(cfg.selector,true)
77 el[cfg.method].apply(el, cfg.event ? [ cfg.event, cfg.args ] : [ cfg.args ] );
79 Roo.log("Error applying select:" + cfg.selector);
81 // do not throw any more..
85 // any other weird crap goes here.
88 Roo.select(toWhat,true).select("form").set( { "autocomplete" : "off" });
91 //jQuery.timeago.settings.allowFuture = true;
92 //$(toWhat).find('abbr.timeinterval').timeago();
94 // multipe select addon
95 //$(toWhat).find("select[multiple]").asmSelect({
96 // addItemTarget: 'bottom',
99 // removeLabel: '[x]',
106 missingHashRequest : false,
109 // This is the main body load tool...
110 // it still needs to handle anchors...
113 ajaxLoad : function(url,slideleft)
115 this.currentURL = url;
116 var target = Roo.get("ajaxbody");
117 var content = Roo.get("content");
118 target.setStyle('position', 'relative');
120 Roo.select('.mask').show(); // must show first?
121 Roo.select('.mask-loading').show();
122 // content has a border...
123 var t = content.getBox().y ;// - Roo.get(document).getScroll().top;// - 13;
124 var l = content.getBox().x ;// - Roo.get(document).getScroll().left;// - 13;
125 var w = content.getBox().width+ 26;
126 var h = content.getBox().height + 26;
128 Roo.select('.mask').first().setLocation(l,t);
129 Roo.select('.mask').first().setSize( w , h, false );
131 Roo.select('.mask-loading').first().setLocation(
132 l + ( w / 2) - 16, t + 16
135 //if (MTrack.missingHashRequest) {
137 // MTrack.missingHashRequest = false;
139 Roo.get('loader').hide();
140 Roo.get('loader').setStyle('position', 'relative');
144 params : { ajax_body : 1 },
145 success : function(data) {
147 Roo.select('.mask').hide();
148 Roo.get('loader').update(data.responseText);
149 Roo.get('loader').show();
150 Roo.get('loader').setWidth( w );
151 Roo.get('loader').setLocation( slideleft? l+w : l-w , t );
153 // old layer - move it away..
156 left: { from : 0 , to : slideleft ? -1 * w : w }
160 // reset it at end of animation - as it ends up with the new content.
161 //target.setLocation( 0 , t );
166 Roo.get('loader').animate(
168 left: { from : slideleft? l+w : l-w , to : l }
172 target.update( Roo.get('loader').dom.innerHTML);
173 Roo.get('loader').hide();
174 Roo.get('loader').update("");
175 target.show();// make sure!!
176 target.setLocation( l ,t );
178 MTrack.missingHashes(target, url);
179 MTrack.addHandlers(target);
184 //console.log('loaded dif');
193 missingHashRequest : false,
194 missingHashes: function(el,url) {
195 //console.log('finding missing hashes?');
197 el.select('.browse-missing-hash').each(function() {
198 hashes.push(this.dom.id);
200 if (!hashes.length) {
203 if (MTrack.missingHashRequest) {
204 MTrack.missingHashRequest.abort();
206 MTrack.missingHashRequest = Roo.Ajax.request({
209 params : { hashes : hashes.join(',') },
210 success : function(data) {
211 //console.log(data.data);
213 for(var hash in data.data) {
214 var o = data.data[hash];
215 Roo.select('#'+ hash).first().dom.innerHTML = o.changeby + ' : ' + o.changelog;
216 Roo.select('#age-'+ hash).first().dom.innerHTML = o.age ; // do magic replacement!!!
217 Roo.select('#rev-'+ hash).first().dom.innerHTML = o.rev ; // do magic replacement!!!
218 MTrack.addHandlers(Roo.select('#age-'+ hash).first());
219 MTrack.missingHashRequest = false;
231 footerPosition : function (force) {
232 var ele = Roo.get('footer');
234 (MTrack.last_dh != Roo.lib.Dom.getDocumentHeight() || MTrack.last_wh != Roo.lib.Dom.getViewHeight())) {
239 // Force a from-scratch layout assessment; put the footer back in
240 // it's natural location in the doc
242 position: "relative",
247 if (Roo.lib.Dom.getDocumentHeight() <= Roo.lib.Dom.getViewHeight()) {
249 position: "absolute",
252 Roo.get(document).getScroll().top +
253 Roo.lib.Dom.getViewHeight() -
254 ele.getSize().height - 1
259 position: "relative",
263 MTrack.last_dh = Roo.lib.Dom.getDocumentHeight();
264 MTrack.last_wh = Roo.lib.Dom.getViewHeight();
270 .scroll(mtrack_footer_position)
271 .resize(mtrack_footer_position);
275 footerSetAndWait : function () {
276 this.footerPosition();
277 setTimeout(function () {
278 MTrack.footerSetAndWait();
287 Roo.onReady(function() {
288 MTrack.addHandlers(); // adds to main body..
291 Roo.select('#banner select').on('change', function(e) {
292 // ajax change project, and refresh body..
295 url : baseURL + '/Project.html',
296 params : { active_project_id : this.value },
297 success : function() {
298 // what if it's false..currentURL = false;
299 MTrack.ajaxLoad(MTrack.currentURL, true);
312 window.onpopstate = function(ev) {
314 if (!ev.state || typeof(ev.state.url) == 'undefined') {
317 MTrack.ajaxLoad(ev.state.url, false);
327 // any date picers.. - on milestones?
328 MTrack.register('.dateinput', 'each', function(e) {
329 var ee = new Roo.form.DateField({
330 dateFormat: 'Y-m-d' // nice and compatible..
339 MTrack.register('a.browse-link', 'on', 'click', function(event)
341 event.preventDefault();
343 var href= this.dom.getAttribute('href').substring(baseURL.length);
345 window.history.pushState( { url: href }, "Browse : " + href , this.dom.href );
346 Roo.log("history push state");
351 var slideleft = this.is('.browse-link-up') ? 0 : 1;
352 MTrack.ajaxLoad(href,slideleft);
357 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
362 $(document).ready(function() {
367 $("textarea.wiki").markItUp({
369 previewParserPath: baseURL + "/Preview",
370 root: rootURL + "/js",
371 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
374 name:'Heading 1', key:'1',
375 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
378 name:'Heading 2', key:'2',
379 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
382 name:'Heading 3', key:'3',
383 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
386 name:'Heading 4', key:'4',
387 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
390 name:'Heading 5', key:'5',
391 openWith:'====== ', closeWith:' ======',
392 placeHolder:'Your title here...'
394 {separator:'---------------' },
395 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
396 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
397 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
398 {separator:'---------------' },
399 {name:'Bulleted list', openWith:' * '},
400 {name:'Numeric list', openWith:' 1. '},
401 {separator:'---------------' },
402 {name:'Quotes', openWith:'(!(> |!|>)!)'},
403 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
404 {separator:'---------------' },
405 {name:'Preview', call:'preview', className:'preview'}
409 $.tablesorter.addParser({
412 return /^#\d+/.test(s);
414 format: function(s) {
415 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
420 $.tablesorter.addParser({
426 format: function(s) {
427 // relies on the textExtraction routine below to pull a
428 // date/time string out of the title portion of the abbr tag
429 return $.tablesorter.formatFloat(new Date(s).getTime());
436 $("table.report, table.wiki").tablesorter({
437 textExtraction: function(node) {
438 var kid = node.childNodes[0];
439 if (kid && kid.tagName == 'ABBR') {
440 // assuming that this abbr is of class='timeinterval'
443 // default 'simple' behavior
444 if (kid && kid.hasChildNodes()) {
445 return kid.innerHTML;
447 return node.innerHTML;
452 $('input.search[type=text]').each(function () {
453 if ($.browser.webkit) {
454 this.type = 'search';
455 ///$(this).attr('autosave', ABSWEB+'/');
456 $(this).attr('results', 5);
458 $(this).addClass('roundsearch');
461 // Convert links that are styled after buttons into actual buttons
462 $('a.button[href]').each(function () {
463 var href = $(this).attr('href');
464 var but = $('<button type="button"/>');
465 but.text($(this).text());
466 $(this).replaceWith(but);
467 but.click(function () {
468 document.location.href = href;
473 $.fn.mtrackWatermark = function () {
474 this.each(function () {
475 var ph = $(this).attr('title');
476 if ($.browser.webkit) {
477 // Use native safari placeholder for watermark
478 $(this).attr('placeholder', ph);
480 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
483 me.focus(function () {
486 me.removeClass('watermark').data('w', 0).val('');
492 me.addClass('watermark').data('w', 1).val(ph);
495 .closest('form').submit(function () {
504 // Watermarking -??? what??
505 $('input[title!=""]').mtrackWatermark();
515 // from head -- probably for reports only..
518 $(document).ready(function() {
520 $.tablesorter.addParser({
526 format: function(s) {
527 if (typeof(priorities[s]) != 'undefined') {
528 return priorities[s];
535 $.tablesorter.addParser({
541 format: function(s) {
542 if (typeof(severities[s]) != 'undefined') {
543 return severities[s];
553 $(document).ready(function(){
554 $('ul.wikitree').treeview({