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 window.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
70 addHandlers : function (toWhat)
72 // forEach? - no IE support?
73 toWhat = toWhat || document.body; //
74 // run the main registry
75 Roo.each(MTrack.registry, function(cfg) {
76 //Roo.log("Add select:" + cfg.selector);
78 var el = Roo.get(toWhat).select(cfg.selector,true)
79 el[cfg.method].apply(el, cfg.event ? [ cfg.event, cfg.args ] : [ cfg.args ] );
81 Roo.log("Error applying select:" + cfg.selector);
83 // do not throw any more..
87 // any other weird crap goes here.
90 Roo.select(toWhat,true).select("form").set( { "autocomplete" : "off" });
93 //jQuery.timeago.settings.allowFuture = true;
94 //$(toWhat).find('abbr.timeinterval').timeago();
96 // multipe select addon
97 //$(toWhat).find("select[multiple]").asmSelect({
98 // addItemTarget: 'bottom',
101 // removeLabel: '[x]',
108 missingHashRequest : false,
111 // This is the main body load tool...
112 // it still needs to handle anchors...
115 ajaxLoad : function(url,slideleft)
117 Roo.get(document.body).scrollTo('top',0,true);
118 this.currentURL = url;
119 var target = Roo.get("ajaxbody");
120 var content = Roo.get("content");
121 target.setStyle('position', 'relative');
123 Roo.select('.mask').show(); // must show first?
124 Roo.select('.mask-loading').show();
125 // content has a border...
126 var t = content.getBox().y ;// - Roo.get(document).getScroll().top;// - 13;
127 var l = content.getBox().x ;// - Roo.get(document).getScroll().left;// - 13;
128 var w = content.getBox().width+ 26;
129 var h = content.getBox().height + 26;
131 Roo.select('.mask').first().setLocation(l,t);
132 Roo.select('.mask').first().setSize( w , h, false );
134 Roo.select('.mask-loading').first().setLocation(
135 l + ( w / 2) - 16, t + 16
138 //if (MTrack.missingHashRequest) {
140 // MTrack.missingHashRequest = false;
142 Roo.get('loader').hide();
143 Roo.get('loader').setStyle('position', 'relative');
147 params : { ajax_body : 1 },
148 success : function(data) {
150 Roo.select('.mask').hide();
151 Roo.get('loader').update(data.responseText);
152 Roo.get('loader').show();
153 Roo.get('loader').setWidth( w );
154 Roo.get('loader').setLocation( slideleft? l+w : l-w , t );
156 // old layer - move it away..
159 left: { from : 0 , to : slideleft ? -1 * w : w }
163 // reset it at end of animation - as it ends up with the new content.
164 //target.setLocation( 0 , t );
169 Roo.get('loader').animate(
171 left: { from : slideleft? l+w : l-w , to : l }
175 target.update( Roo.get('loader').dom.innerHTML);
176 Roo.get('loader').hide();
177 Roo.get('loader').update("");
178 target.show();// make sure!!
179 target.setLocation( l ,t );
181 MTrack.missingHashes(target, url);
182 MTrack.addHandlers(target);
189 //console.log('loaded dif');
198 missingHashRequest : false,
199 missingHashes: function(el,url) {
200 console.log('finding missing hashes?');
202 el.select('.browse-missing-hash').each(function() {
203 hashes.push(this.dom.id);
206 if (!hashes.length) {
207 Roo.log("no missing hashes");
214 params : { hashes : hashes.join(',') },
215 success : function(res) {
216 var data = Roo.decode(res.responseText);
218 //console.log(data.data);
220 for(var hash in data.data) {
221 var o = data.data[hash];
222 Roo.select('#'+ hash).first().dom.innerHTML = o.changeby + ' : ' + o.changelog;
223 Roo.select('#age-'+ hash).first().dom.innerHTML = o.age ; // do magic replacement!!!
224 Roo.select('#rev-'+ hash).first().dom.innerHTML = o.rev ; // do magic replacement!!!
225 MTrack.addHandlers(Roo.select('#age-'+ hash).first());
226 MTrack.missingHashRequest = false;
238 footerPosition : function (force) {
240 var ele = Roo.get('footer');
242 (MTrack.last_dh != Roo.lib.Dom.getDocumentHeight() || MTrack.last_wh != Roo.lib.Dom.getViewHeight())) {
247 // Force a from-scratch layout assessment; put the footer back in
248 // it's natural location in the doc
250 position: "relative",
255 if (Roo.lib.Dom.getDocumentHeight() <= Roo.lib.Dom.getViewHeight()) {
257 position: "absolute",
260 Roo.get(document).getScroll().top +
261 Roo.lib.Dom.getViewHeight() -
262 ele.getSize().height - 1
267 position: "relative",
271 MTrack.last_dh = Roo.lib.Dom.getDocumentHeight();
272 MTrack.last_wh = Roo.lib.Dom.getViewHeight();
276 keepLoggedIn: function()
279 url : baseURL + '/Login.html',
281 data : { refresh : 1 },
282 success : function() {
284 window.setTimeout(MTrack.keepLoggedIn, 30000);
285 // what if it's false..currentURL = false;
298 .scroll(mtrack_footer_position)
299 .resize(mtrack_footer_position);
303 footerSetAndWait : function () {
305 /*this.footerPosition();
306 window.setTimeout(function () {
307 MTrack.footerSetAndWait();
317 Roo.onReady(function() {
318 MTrack.addHandlers(); // adds to main body..
321 Roo.select('#banner select').on('change', function(e) {
322 // ajax change project, and refresh body..
325 url : baseURL + '/core_project',
326 params : { active_project_id : this.value },
327 success : function() {
328 // what if it's false..currentURL = false;
329 MTrack.ajaxLoad(MTrack.currentURL, true);
342 window.onpopstate = function(ev) {
344 if (!ev.state || typeof(ev.state.url) == 'undefined') {
347 MTrack.ajaxLoad(ev.state.url, false);
357 // any date picers.. - on milestones?
358 MTrack.register('.dateinput', 'each', function(e) {
359 var ee = new Roo.form.DateField({
360 dateFormat: 'Y-m-d' // nice and compatible..
369 MTrack.register('a.browse-link', 'on', 'click', function(event)
371 event.preventDefault();
373 var href= this.dom.getAttribute('href').substring(baseURL.length);
375 window.history.pushState( { url: href }, "Browse : " + href , this.dom.href );
376 Roo.log("history push state");
381 var slideleft = this.is('.browse-link-up') ? 0 : 1;
382 MTrack.ajaxLoad(href,slideleft);
387 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
392 $(document).ready(function() {
397 $("textarea.wiki").markItUp({
399 previewParserPath: baseURL + "/Preview",
400 root: rootURL + "/js",
401 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
404 name:'Heading 1', key:'1',
405 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
408 name:'Heading 2', key:'2',
409 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
412 name:'Heading 3', key:'3',
413 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
416 name:'Heading 4', key:'4',
417 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
420 name:'Heading 5', key:'5',
421 openWith:'====== ', closeWith:' ======',
422 placeHolder:'Your title here...'
424 {separator:'---------------' },
425 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
426 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
427 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
428 {separator:'---------------' },
429 {name:'Bulleted list', openWith:' * '},
430 {name:'Numeric list', openWith:' 1. '},
431 {separator:'---------------' },
432 {name:'Quotes', openWith:'(!(> |!|>)!)'},
433 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
434 {separator:'---------------' },1
435 {name:'Preview', call:'preview', className:'preview'}
439 $.tablesorter.addParser({
442 return /^#\d+/.test(s);
444 format: function(s) {
445 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
450 $.tablesorter.addParser({
456 format: function(s) {
457 // relies on the textExtraction routine below to pull a
458 // date/time string out of the title portion of the abbr tag
459 return $.tablesorter.formatFloat(new Date(s).getTime());
466 $("table.report, table.wiki").tablesorter({
467 textExtraction: function(node) {
468 var kid = node.childNodes[0];
469 if (kid && kid.tagName == 'ABBR') {
470 // assuming that this abbr is of class='timeinterval'
473 // default 'simple' behavior
474 if (kid && kid.hasChildNodes()) {
475 return kid.innerHTML;
477 return node.innerHTML;
482 $('input.search[type=text]').each(function () {
483 if ($.browser.webkit) {
484 this.type = 'search';
485 ///$(this).attr('autosave', ABSWEB+'/');
486 $(this).attr('results', 5);
488 $(this).addClass('roundsearch');
491 // Convert links that are styled after buttons into actual buttons
492 $('a.button[href]').each(function () {
493 var href = $(this).attr('href');
494 var but = $('<button type="button"/>');
495 but.text($(this).text());
496 $(this).replaceWith(but);
497 but.click(function () {
498 document.location.href = href;
503 $.fn.mtrackWatermark = function () {
504 this.each(function () {
505 var ph = $(this).attr('title');
506 if ($.browser.webkit) {
507 // Use native safari placeholder for watermark
508 $(this).attr('placeholder', ph);
510 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
513 me.focus(function () {
516 me.removeClass('watermark').data('w', 0).val('');
522 me.addClass('watermark').data('w', 1).val(ph);
525 .closest('form').submit(function () {
534 // Watermarking -??? what??
535 $('input[title!=""]').mtrackWatermark();
545 // from head -- probably for reports only..
548 $(document).ready(function() {
550 $.tablesorter.addParser({
556 format: function(s) {
557 if (typeof(priorities[s]) != 'undefined') {
558 return priorities[s];
565 $.tablesorter.addParser({
571 format: function(s) {
572 if (typeof(severities[s]) != 'undefined') {
573 return severities[s];
583 $(document).ready(function(){
584 $('ul.wikitree').treeview({