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 MTrack.footerSetAndWait();
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) {
46 var ab = Roo.get('ajaxbody');
47 ab.dom.innerHTML = data.responseText;
48 MTrack.addHandlers(ab);
49 MTrack.missingHashes(ab, 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) {
79 var el = Roo.get(toWhat).select(cfg.selector,true)
80 el[cfg.method].apply(el, cfg.event ? [ cfg.event, cfg.args ] : [ cfg.args ] );
82 Roo.log("Error applying select:" + cfg.selector);
84 // do not throw any more..
88 // any other weird crap goes here.
91 Roo.select(toWhat,true).select("form").set( { "autocomplete" : "off" });
94 //jQuery.timeago.settings.allowFuture = true;
95 //$(toWhat).find('abbr.timeinterval').timeago();
97 // multipe select addon
98 //$(toWhat).find("select[multiple]").asmSelect({
99 // addItemTarget: 'bottom',
102 // removeLabel: '[x]',
109 missingHashRequest : false,
112 // This is the main body load tool...
113 // it still needs to handle anchors...
116 ajaxLoad : function(url,slideleft)
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);
187 //console.log('loaded dif');
196 missingHashRequest : false,
197 missingHashes: function(el,url) {
198 //console.log('finding missing hashes?');
200 el.select('.browse-missing-hash').each(function() {
201 hashes.push(this.dom.id);
203 if (!hashes.length) {
206 if (MTrack.missingHashRequest) {
207 MTrack.missingHashRequest.abort();
209 MTrack.missingHashRequest = Roo.Ajax.request({
212 params : { hashes : hashes.join(',') },
213 success : function(data) {
214 //console.log(data.data);
216 for(var hash in data.data) {
217 var o = data.data[hash];
218 Roo.select('#'+ hash).first().dom.innerHTML = o.changeby + ' : ' + o.changelog;
219 Roo.select('#age-'+ hash).first().dom.innerHTML = o.age ; // do magic replacement!!!
220 Roo.select('#rev-'+ hash).first().dom.innerHTML = o.rev ; // do magic replacement!!!
221 MTrack.addHandlers(Roo.select('#age-'+ hash).first());
222 MTrack.missingHashRequest = false;
234 footerPosition : function (force) {
235 var ele = Roo.get('footer');
237 (MTrack.last_dh != Roo.lib.Dom.getDocumentHeight() || MTrack.last_wh != Roo.lib.Dom.getViewHeight())) {
242 // Force a from-scratch layout assessment; put the footer back in
243 // it's natural location in the doc
245 position: "relative",
250 if (Roo.lib.Dom.getDocumentHeight() <= Roo.lib.Dom.getViewHeight()) {
252 position: "absolute",
255 Roo.get(document).getScroll().top +
256 Roo.lib.Dom.getViewHeight() -
257 ele.getSize().height - 1
262 position: "relative",
266 MTrack.last_dh = Roo.lib.Dom.getDocumentHeight();
267 MTrack.last_wh = Roo.lib.Dom.getViewHeight();
273 .scroll(mtrack_footer_position)
274 .resize(mtrack_footer_position);
278 footerSetAndWait : function () {
279 this.footerPosition();
280 setTimeout(function () {
281 MTrack.footerSetAndWait();
290 Roo.onReady(function() {
291 MTrack.addHandlers(); // adds to main body..
294 Roo.select('#banner select').on('change', function(e) {
295 // ajax change project, and refresh body..
298 url : baseURL + '/Project.html',
299 params : { active_project_id : this.value },
300 success : function() {
301 // what if it's false..currentURL = false;
302 MTrack.ajaxLoad(MTrack.currentURL, true);
315 window.onpopstate = function(ev) {
317 if (!ev.state || typeof(ev.state.url) == 'undefined') {
320 MTrack.ajaxLoad(ev.state.url, false);
330 // any date picers.. - on milestones?
331 MTrack.register('.dateinput', 'each', function(e) {
332 var ee = new Roo.form.DateField({
333 dateFormat: 'Y-m-d' // nice and compatible..
342 MTrack.register('a.browse-link', 'on', 'click', function(event)
344 event.preventDefault();
346 var href= this.dom.getAttribute('href').substring(baseURL.length);
348 window.history.pushState( { url: href }, "Browse : " + href , this.href );
350 var slideleft = this.is('.browse-link-up') ? 0 : 1;
351 MTrack.ajaxLoad(href,slideleft);
356 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
361 $(document).ready(function() {
366 $("textarea.wiki").markItUp({
368 previewParserPath: baseURL + "/Preview",
369 root: rootURL + "/js",
370 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
373 name:'Heading 1', key:'1',
374 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
377 name:'Heading 2', key:'2',
378 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
381 name:'Heading 3', key:'3',
382 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
385 name:'Heading 4', key:'4',
386 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
389 name:'Heading 5', key:'5',
390 openWith:'====== ', closeWith:' ======',
391 placeHolder:'Your title here...'
393 {separator:'---------------' },
394 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
395 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
396 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
397 {separator:'---------------' },
398 {name:'Bulleted list', openWith:' * '},
399 {name:'Numeric list', openWith:' 1. '},
400 {separator:'---------------' },
401 {name:'Quotes', openWith:'(!(> |!|>)!)'},
402 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
403 {separator:'---------------' },
404 {name:'Preview', call:'preview', className:'preview'}
408 $.tablesorter.addParser({
411 return /^#\d+/.test(s);
413 format: function(s) {
414 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
419 $.tablesorter.addParser({
425 format: function(s) {
426 // relies on the textExtraction routine below to pull a
427 // date/time string out of the title portion of the abbr tag
428 return $.tablesorter.formatFloat(new Date(s).getTime());
435 $("table.report, table.wiki").tablesorter({
436 textExtraction: function(node) {
437 var kid = node.childNodes[0];
438 if (kid && kid.tagName == 'ABBR') {
439 // assuming that this abbr is of class='timeinterval'
442 // default 'simple' behavior
443 if (kid && kid.hasChildNodes()) {
444 return kid.innerHTML;
446 return node.innerHTML;
451 $('input.search[type=text]').each(function () {
452 if ($.browser.webkit) {
453 this.type = 'search';
454 ///$(this).attr('autosave', ABSWEB+'/');
455 $(this).attr('results', 5);
457 $(this).addClass('roundsearch');
460 // Convert links that are styled after buttons into actual buttons
461 $('a.button[href]').each(function () {
462 var href = $(this).attr('href');
463 var but = $('<button type="button"/>');
464 but.text($(this).text());
465 $(this).replaceWith(but);
466 but.click(function () {
467 document.location.href = href;
472 $.fn.mtrackWatermark = function () {
473 this.each(function () {
474 var ph = $(this).attr('title');
475 if ($.browser.webkit) {
476 // Use native safari placeholder for watermark
477 $(this).attr('placeholder', ph);
479 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
482 me.focus(function () {
485 me.removeClass('watermark').data('w', 0).val('');
491 me.addClass('watermark').data('w', 1).val(ph);
494 .closest('form').submit(function () {
503 // Watermarking -??? what??
504 $('input[title!=""]').mtrackWatermark();
514 // from head -- probably for reports only..
517 $(document).ready(function() {
519 $.tablesorter.addParser({
525 format: function(s) {
526 if (typeof(priorities[s]) != 'undefined') {
527 return priorities[s];
534 $.tablesorter.addParser({
540 format: function(s) {
541 if (typeof(severities[s]) != 'undefined') {
542 return severities[s];
552 $(document).ready(function(){
553 $('ul.wikitree').treeview({