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
70 addHandlers : function (toWhat)
72 // forEach? - no IE support?
73 toWhat = toWhat || document.body; //
74 // run the main registry
75 MTrack.registry.forEach(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();
278 .scroll(mtrack_footer_position)
279 .resize(mtrack_footer_position);
283 footerSetAndWait : function () {
285 this.footerPosition();
286 setTimeout(function () {
287 MTrack.footerSetAndWait();
296 Roo.onReady(function() {
297 MTrack.addHandlers(); // adds to main body..
300 Roo.select('#banner select').on('change', function(e) {
301 // ajax change project, and refresh body..
304 url : baseURL + '/Project.html',
305 params : { active_project_id : this.value },
306 success : function() {
307 // what if it's false..currentURL = false;
308 MTrack.ajaxLoad(MTrack.currentURL, true);
321 window.onpopstate = function(ev) {
323 if (!ev.state || typeof(ev.state.url) == 'undefined') {
326 MTrack.ajaxLoad(ev.state.url, false);
336 // any date picers.. - on milestones?
337 MTrack.register('.dateinput', 'each', function(e) {
338 var ee = new Roo.form.DateField({
339 dateFormat: 'Y-m-d' // nice and compatible..
348 MTrack.register('a.browse-link', 'on', 'click', function(event)
350 event.preventDefault();
352 var href= this.dom.getAttribute('href').substring(baseURL.length);
354 window.history.pushState( { url: href }, "Browse : " + href , this.dom.href );
355 Roo.log("history push state");
360 var slideleft = this.is('.browse-link-up') ? 0 : 1;
361 MTrack.ajaxLoad(href,slideleft);
366 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
371 $(document).ready(function() {
376 $("textarea.wiki").markItUp({
378 previewParserPath: baseURL + "/Preview",
379 root: rootURL + "/js",
380 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
383 name:'Heading 1', key:'1',
384 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
387 name:'Heading 2', key:'2',
388 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
391 name:'Heading 3', key:'3',
392 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
395 name:'Heading 4', key:'4',
396 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
399 name:'Heading 5', key:'5',
400 openWith:'====== ', closeWith:' ======',
401 placeHolder:'Your title here...'
403 {separator:'---------------' },
404 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
405 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
406 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
407 {separator:'---------------' },
408 {name:'Bulleted list', openWith:' * '},
409 {name:'Numeric list', openWith:' 1. '},
410 {separator:'---------------' },
411 {name:'Quotes', openWith:'(!(> |!|>)!)'},
412 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
413 {separator:'---------------' },
414 {name:'Preview', call:'preview', className:'preview'}
418 $.tablesorter.addParser({
421 return /^#\d+/.test(s);
423 format: function(s) {
424 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
429 $.tablesorter.addParser({
435 format: function(s) {
436 // relies on the textExtraction routine below to pull a
437 // date/time string out of the title portion of the abbr tag
438 return $.tablesorter.formatFloat(new Date(s).getTime());
445 $("table.report, table.wiki").tablesorter({
446 textExtraction: function(node) {
447 var kid = node.childNodes[0];
448 if (kid && kid.tagName == 'ABBR') {
449 // assuming that this abbr is of class='timeinterval'
452 // default 'simple' behavior
453 if (kid && kid.hasChildNodes()) {
454 return kid.innerHTML;
456 return node.innerHTML;
461 $('input.search[type=text]').each(function () {
462 if ($.browser.webkit) {
463 this.type = 'search';
464 ///$(this).attr('autosave', ABSWEB+'/');
465 $(this).attr('results', 5);
467 $(this).addClass('roundsearch');
470 // Convert links that are styled after buttons into actual buttons
471 $('a.button[href]').each(function () {
472 var href = $(this).attr('href');
473 var but = $('<button type="button"/>');
474 but.text($(this).text());
475 $(this).replaceWith(but);
476 but.click(function () {
477 document.location.href = href;
482 $.fn.mtrackWatermark = function () {
483 this.each(function () {
484 var ph = $(this).attr('title');
485 if ($.browser.webkit) {
486 // Use native safari placeholder for watermark
487 $(this).attr('placeholder', ph);
489 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
492 me.focus(function () {
495 me.removeClass('watermark').data('w', 0).val('');
501 me.addClass('watermark').data('w', 1).val(ph);
504 .closest('form').submit(function () {
513 // Watermarking -??? what??
514 $('input[title!=""]').mtrackWatermark();
524 // from head -- probably for reports only..
527 $(document).ready(function() {
529 $.tablesorter.addParser({
535 format: function(s) {
536 if (typeof(priorities[s]) != 'undefined') {
537 return priorities[s];
544 $.tablesorter.addParser({
550 format: function(s) {
551 if (typeof(severities[s]) != 'undefined') {
552 return severities[s];
562 $(document).ready(function(){
563 $('ul.wikitree').treeview({