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) {
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 // 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().y ;// - Roo.get(document).getScroll().top;// - 13;
120 var l = content.getBox().x ;// - Roo.get(document).getScroll().left;// - 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) {
133 // MTrack.missingHashRequest = false;
135 Roo.get('loader').hide();
139 params : { ajax_body : 1 },
140 success : function(data) {
142 Roo.select('.mask').hide();
143 Roo.get('loader').update(data.responseText);
144 Roo.get('loader').show();
145 Roo.get('loader').setWidth( w );
146 Roo.get('loader').setLocation( slideleft? l+w : l-w , t );
148 // old layer - move it away..
151 left: { from : 0 , to : slideleft ? -1 * w : w }
155 // reset it at end of animation - as it ends up with the new content.
156 //target.setLocation( 0 , t );
161 Roo.get('loader').animate(
163 left: { from : slideleft? l+w : l-w , to : l }
167 target.update( Roo.get('loader').dom.innerHTML);
168 Roo.get('loader').hide();
169 Roo.get('loader').update("");
170 target.show();// make sure!!
171 target.setLocation( l ,t );
173 MTrack.missingHashes(target, url);
174 MTrack.addHandlers(target);
179 //console.log('loaded dif');
188 missingHashRequest : false,
189 missingHashes: function(el,url) {
190 //console.log('finding missing hashes?');
192 el.select('.browse-missing-hash').each(function() {
193 hashes.push(this.dom.id);
195 if (!hashes.length) {
198 if (MTrack.missingHashRequest) {
199 MTrack.missingHashRequest.abort();
201 MTrack.missingHashRequest = Roo.Ajax.request({
204 params : { hashes : hashes.join(',') },
205 success : function(data) {
206 //console.log(data.data);
208 for(var hash in data.data) {
209 var o = data.data[hash];
210 Roo.select('#'+ hash).first().dom.innerHTML = o.changeby + ' : ' + o.changelog;
211 Roo.select('#age-'+ hash).first().dom.innerHTML = o.age ; // do magic replacement!!!
212 Roo.select('#rev-'+ hash).first().dom.innerHTML = o.rev ; // do magic replacement!!!
213 MTrack.addHandlers(Roo.select('#age-'+ hash).first());
214 MTrack.missingHashRequest = false;
226 footerPosition : function (force) {
227 var ele = Roo.get('footer');
229 (MTrack.last_dh != Roo.lib.Dom.getDocumentHeight() || MTrack.last_wh != Roo.lib.Dom.getViewHeight())) {
234 // Force a from-scratch layout assessment; put the footer back in
235 // it's natural location in the doc
237 position: "relative",
242 if (Roo.lib.Dom.getDocumentHeight() <= Roo.lib.Dom.getViewHeight()) {
244 position: "absolute",
247 Roo.get(document).getScroll().top +
248 Roo.lib.Dom.getViewHeight() -
249 ele.getSize().height - 1
254 position: "relative",
258 MTrack.last_dh = Roo.lib.Dom.getDocumentHeight();
259 MTrack.last_wh = Roo.lib.Dom.getViewHeight();
265 .scroll(mtrack_footer_position)
266 .resize(mtrack_footer_position);
270 footerSetAndWait : function () {
271 this.footerPosition();
272 setTimeout(function () {
273 MTrack.footerSetAndWait();
282 Roo.onReady(function() {
283 MTrack.addHandlers(); // adds to main body..
286 Roo.select('#banner select').on('change', function(e) {
287 // ajax change project, and refresh body..
290 url : baseURL + '/Project.html',
291 params : { active_project_id : this.value },
292 success : function() {
293 // what if it's false..currentURL = false;
294 MTrack.ajaxLoad(MTrack.currentURL, true);
307 window.onpopstate = function(ev) {
309 if (!ev.state || typeof(ev.state.url) == 'undefined') {
312 MTrack.ajaxLoad(ev.state.url, false);
322 // any date picers.. - on milestones?
323 MTrack.register('.dateinput', 'each', function(e) {
324 var ee = new Roo.form.DateField({
325 dateFormat: 'Y-m-d' // nice and compatible..
334 MTrack.register('a.browse-link', 'on', 'click', function(event)
336 event.preventDefault();
338 var href= this.dom.getAttribute('href').substring(baseURL.length);
340 window.history.pushState( { url: href }, "Browse : " + href , this.href );
342 var slideleft = this.is('.browse-link-up') ? 0 : 1;
343 MTrack.ajaxLoad(href,slideleft);
348 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
353 $(document).ready(function() {
358 $("textarea.wiki").markItUp({
360 previewParserPath: baseURL + "/Preview",
361 root: rootURL + "/js",
362 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
365 name:'Heading 1', key:'1',
366 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
369 name:'Heading 2', key:'2',
370 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
373 name:'Heading 3', key:'3',
374 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
377 name:'Heading 4', key:'4',
378 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
381 name:'Heading 5', key:'5',
382 openWith:'====== ', closeWith:' ======',
383 placeHolder:'Your title here...'
385 {separator:'---------------' },
386 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
387 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
388 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
389 {separator:'---------------' },
390 {name:'Bulleted list', openWith:' * '},
391 {name:'Numeric list', openWith:' 1. '},
392 {separator:'---------------' },
393 {name:'Quotes', openWith:'(!(> |!|>)!)'},
394 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
395 {separator:'---------------' },
396 {name:'Preview', call:'preview', className:'preview'}
400 $.tablesorter.addParser({
403 return /^#\d+/.test(s);
405 format: function(s) {
406 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
411 $.tablesorter.addParser({
417 format: function(s) {
418 // relies on the textExtraction routine below to pull a
419 // date/time string out of the title portion of the abbr tag
420 return $.tablesorter.formatFloat(new Date(s).getTime());
427 $("table.report, table.wiki").tablesorter({
428 textExtraction: function(node) {
429 var kid = node.childNodes[0];
430 if (kid && kid.tagName == 'ABBR') {
431 // assuming that this abbr is of class='timeinterval'
434 // default 'simple' behavior
435 if (kid && kid.hasChildNodes()) {
436 return kid.innerHTML;
438 return node.innerHTML;
443 $('input.search[type=text]').each(function () {
444 if ($.browser.webkit) {
445 this.type = 'search';
446 ///$(this).attr('autosave', ABSWEB+'/');
447 $(this).attr('results', 5);
449 $(this).addClass('roundsearch');
452 // Convert links that are styled after buttons into actual buttons
453 $('a.button[href]').each(function () {
454 var href = $(this).attr('href');
455 var but = $('<button type="button"/>');
456 but.text($(this).text());
457 $(this).replaceWith(but);
458 but.click(function () {
459 document.location.href = href;
464 $.fn.mtrackWatermark = function () {
465 this.each(function () {
466 var ph = $(this).attr('title');
467 if ($.browser.webkit) {
468 // Use native safari placeholder for watermark
469 $(this).attr('placeholder', ph);
471 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
474 me.focus(function () {
477 me.removeClass('watermark').data('w', 0).val('');
483 me.addClass('watermark').data('w', 1).val(ph);
486 .closest('form').submit(function () {
495 // Watermarking -??? what??
496 $('input[title!=""]').mtrackWatermark();
506 // from head -- probably for reports only..
509 $(document).ready(function() {
511 $.tablesorter.addParser({
517 format: function(s) {
518 if (typeof(priorities[s]) != 'undefined') {
519 return priorities[s];
526 $.tablesorter.addParser({
532 format: function(s) {
533 if (typeof(severities[s]) != 'undefined') {
534 return severities[s];
544 $(document).ready(function(){
545 $('ul.wikitree').treeview({