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().top - Roo.get(document).getScroll().top - 13;
120 var l = content.getBox().left - Roo.get(document).getScroll().top - 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) {
132 MTrack.missingHashRequest.abort();
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 );
150 left: slideleft ? -1 * w : w
154 target.setLocation( 0, 0 ); // reset it at end of animation - as it ends up with the new content.
158 Roo.get('loader').animate(
164 target.update( Roo.get('loader').dom.innerHTML);
165 Roo.get('loader').hide();
166 Roo.get('loader').update("");
167 target.show();// make sure!!
169 MTrack.missingHashes(target, url);
170 MTrack.addHandlers(target);
174 //console.log('loaded dif');
183 missingHashRequest : false,
184 missingHashes: function(el,url) {
185 //console.log('finding missing hashes?');
187 el.select('.browse-missing-hash').each(function() {
188 hashes.push(this.dom.id);
190 if (!hashes.length) {
193 if (MTrack.missingHashRequest) {
194 MTrack.missingHashRequest.abort();
196 MTrack.missingHashRequest = Roo.Ajax.request({
199 params : { hashes : hashes.join(',') },
200 success : function(data) {
201 //console.log(data.data);
203 for(var hash in data.data) {
204 var o = data.data[hash];
205 Roo.select('#'+ hash).first().dom.innerHTML = o.changeby + ' : ' + o.changelog;
206 Roo.select('#age-'+ hash).first().dom.innerHTML = o.age ; // do magic replacement!!!
207 Roo.select('#rev-'+ hash).first().dom.innerHTML = o.rev ; // do magic replacement!!!
208 MTrack.addHandlers(Roo.select('#age-'+ hash).first());
209 MTrack.missingHashRequest = false;
221 footerPosition : function (force) {
222 var ele = Roo.get('footer');
224 (MTrack.last_dh != Roo.lib.Dom.getDocumentHeight() || MTrack.last_wh != Roo.lib.Dom.getViewHeight())) {
229 // Force a from-scratch layout assessment; put the footer back in
230 // it's natural location in the doc
232 position: "relative",
237 if (Roo.lib.Dom.getDocumentHeight() <= Roo.lib.Dom.getViewHeight()) {
239 position: "absolute",
242 Roo.get(document).getScroll().top +
243 Roo.lib.Dom.getViewHeight() -
244 ele.getSize().height - 1
249 position: "relative",
253 MTrack.last_dh = Roo.lib.Dom.getDocumentHeight();
254 MTrack.last_wh = Roo.lib.Dom.getViewHeight();
260 .scroll(mtrack_footer_position)
261 .resize(mtrack_footer_position);
265 footerSetAndWait : function () {
266 this.footerPosition();
267 setTimeout(function () {
268 MTrack.footerSetAndWait();
277 Roo.onReady(function() {
278 MTrack.addHandlers(); // adds to main body..
281 Roo.select('#banner select').on('change', function(e) {
282 // ajax change project, and refresh body..
284 url : baseURL + '/Project.html',
285 params : { active_project_id : this.value },
286 success : function() {
287 // what if it's false..currentURL = false;
288 MTrack.ajaxLoad(MTrack.currentURL, true);
301 window.onpopstate = function(ev) {
303 if (!ev.state || typeof(ev.state.url) == 'undefined') {
306 MTrack.ajaxLoad(ev.state.url, false);
316 // any date picers.. - on milestones?
317 MTrack.register('.dateinput', 'each', function(e) {
318 var ee = new Roo.form.DateField({
319 dateFormat: 'Y-m-d' // nice and compatible..
328 MTrack.register('a.browse-link', 'on', 'click', function(event)
330 event.preventDefault();
332 var href= this.dom.getAttribute('href').substring(baseURL.length);
334 window.history.pushState( { url: href }, "Browse : " + href , this.href );
336 var slideleft = this.is('.browse-link-up') ? 0 : 1;
337 MTrack.ajaxLoad(href,slideleft);
342 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
347 $(document).ready(function() {
352 $("textarea.wiki").markItUp({
354 previewParserPath: baseURL + "/Preview",
355 root: rootURL + "/js",
356 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
359 name:'Heading 1', key:'1',
360 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
363 name:'Heading 2', key:'2',
364 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
367 name:'Heading 3', key:'3',
368 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
371 name:'Heading 4', key:'4',
372 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
375 name:'Heading 5', key:'5',
376 openWith:'====== ', closeWith:' ======',
377 placeHolder:'Your title here...'
379 {separator:'---------------' },
380 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
381 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
382 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
383 {separator:'---------------' },
384 {name:'Bulleted list', openWith:' * '},
385 {name:'Numeric list', openWith:' 1. '},
386 {separator:'---------------' },
387 {name:'Quotes', openWith:'(!(> |!|>)!)'},
388 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
389 {separator:'---------------' },
390 {name:'Preview', call:'preview', className:'preview'}
394 $.tablesorter.addParser({
397 return /^#\d+/.test(s);
399 format: function(s) {
400 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
405 $.tablesorter.addParser({
411 format: function(s) {
412 // relies on the textExtraction routine below to pull a
413 // date/time string out of the title portion of the abbr tag
414 return $.tablesorter.formatFloat(new Date(s).getTime());
421 $("table.report, table.wiki").tablesorter({
422 textExtraction: function(node) {
423 var kid = node.childNodes[0];
424 if (kid && kid.tagName == 'ABBR') {
425 // assuming that this abbr is of class='timeinterval'
428 // default 'simple' behavior
429 if (kid && kid.hasChildNodes()) {
430 return kid.innerHTML;
432 return node.innerHTML;
437 $('input.search[type=text]').each(function () {
438 if ($.browser.webkit) {
439 this.type = 'search';
440 ///$(this).attr('autosave', ABSWEB+'/');
441 $(this).attr('results', 5);
443 $(this).addClass('roundsearch');
446 // Convert links that are styled after buttons into actual buttons
447 $('a.button[href]').each(function () {
448 var href = $(this).attr('href');
449 var but = $('<button type="button"/>');
450 but.text($(this).text());
451 $(this).replaceWith(but);
452 but.click(function () {
453 document.location.href = href;
458 $.fn.mtrackWatermark = function () {
459 this.each(function () {
460 var ph = $(this).attr('title');
461 if ($.browser.webkit) {
462 // Use native safari placeholder for watermark
463 $(this).attr('placeholder', ph);
465 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
468 me.focus(function () {
471 me.removeClass('watermark').data('w', 0).val('');
477 me.addClass('watermark').data('w', 1).val(ph);
480 .closest('form').submit(function () {
489 // Watermarking -??? what??
490 $('input[title!=""]').mtrackWatermark();
500 // from head -- probably for reports only..
503 $(document).ready(function() {
505 $.tablesorter.addParser({
511 format: function(s) {
512 if (typeof(priorities[s]) != 'undefined') {
513 return priorities[s];
520 $.tablesorter.addParser({
526 format: function(s) {
527 if (typeof(severities[s]) != 'undefined') {
528 return severities[s];
538 $(document).ready(function(){
539 $('ul.wikitree').treeview({