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.
20 * MTrack.register('a.changeset-link', 'each', function() ....)
21 * MTrack.register('a.changeset-link', 'on', 'click', function() ....)
24 register : function( selector, method, arg1, arg2)
26 MTrack.registry.push( {
29 event : method == 'on' ? arg1 : false,
30 args : method == 'on' ? arg2 : arg1
34 addHandlers : function (toWhat)
36 // forEach? - no IE support?
37 toWhat = toWhat || document.body; //
38 // run the main registry
39 MTrack.registry.forEach(function(cfg) {
40 var el = Roo.get(toWhat).select(cfg.selector,true)
41 el[cfg.method].apply(el, cfg.event ? [ event, args ] : [ args ] );
43 // any other weird crap goes here.
46 Roo.select(toWhat,true).select("form").set( { "autocomplete" : "off" });
49 //jQuery.timeago.settings.allowFuture = true;
50 //$(toWhat).find('abbr.timeinterval').timeago();
52 // multipe select addon
53 //$(toWhat).find("select[multiple]").asmSelect({
54 // addItemTarget: 'bottom',
57 // removeLabel: '[x]',
64 missingHashRequest : false,
67 // This is the main body load tool...
68 // it still needs to handle anchors...
71 ajaxLoad : function(url,slideleft)
73 this.currentURL = url;
74 var target = Roo.get("ajaxbody");
75 var content = Roo.get("content");
76 target.setStyle('position', 'relative');
78 Roo.select('.mask').show(); // must show first?
79 Roo.select('.mask-loading').show();
80 // content has a border...
81 var t = content.getBox().top - Roo.get(document).getScroll().top - 13;
82 var l = content.getBox().left - Roo.get(document).getScroll().top - 13;
83 var w = content.getBox().width+ 26;
84 var h = content.getBox().height + 26;
86 Roo.select('.mask').first().setLocation(l,t);
87 Roo.select('.mask').first().setSize( w , h, false );
89 Roo.select('.mask-loading').first().setLocation(
90 l + ( w / 2) - 16, t + 16
93 if (MTrack.missingHashRequest) {
94 MTrack.missingHashRequest.abort();
95 MTrack.missingHashRequest = false;
97 Roo.get('loader').hide();
100 params : { ajax_body : 1 },
101 success : function(data) {
103 Roo.select('.mask').hide();
104 Roo.get('loader').update(data);
105 Roo.get('loader').show();
106 Roo.get('loader').setWidth( w );
107 Roo.get('loader').setPosition( slideleft? l+w : l-w , t );
111 left: slideleft ? -1 * w : w
115 target.setPosition( 0, 0 ); // reset it at end of animation - as it ends up with the new content.
119 Roo.get('loader').animate(
125 target.update( Roo.get('loader').dom.innerHTML);
126 Roo.get('loader').hide();
127 Roo.get('loader').update("");
128 target.show();// make sure!!
130 MTrack.missingHashes(target, url);
131 MTrack.addHandlers(target);
135 //console.log('loaded dif');
144 missingHashRequest : false,
145 missingHashes: function(el,url) {
146 //console.log('finding missing hashes?');
148 el.select('.browse-missing-hash').each(function() {
149 hashes.push(this.dom.id);
151 if (!hashes.length) {
154 if (MTrack.missingHashRequest) {
155 MTrack.missingHashRequest.abort();
157 MTrack.missingHashRequest = Roo.Ajax.request({
160 params : { hashes : hashes.join(',') },
161 success : function(data) {
162 //console.log(data.data);
164 for(var hash in data.data) {
165 var o = data.data[hash];
166 Roo.select('#'+ hash).first().dom.innerHTML = o.changeby + ' : ' + o.changelog;
167 Roo.select('#age-'+ hash).first().dom.innerHTML = o.age ; // do magic replacement!!!
168 Roo.select('#rev-'+ hash).first().dom.innerHTML = o.rev ; // do magic replacement!!!
169 MTrack.addHandlers(Roo.select('#age-'+ hash).first());
170 MTrack.missingHashRequest = false;
183 Roo.onReady(function() {
184 MTrack.addHandlers(); // adds to main body..
187 Roo.select('#banner select').on('change', function(e) {
188 // ajax change project, and refresh body..
190 url : baseURL + '/Project.html',
191 params : { active_project_id : this.value },
192 success : function() {
193 // what if it's false..currentURL = false;
194 MTrack.ajaxLoad(MTrack.currentURL, true);
207 window.onpopstate = function(ev) {
209 if (!ev.state || typeof(ev.state.url) == 'undefined') {
212 MTrack.ajaxLoad(ev.state.url, false);
222 // any date picers.. - on milestones?
223 MTrack.register('.dateinput', 'each', function(e) {
224 var ee = new Roo.form.DateField({
225 dateFormat: 'Y-m-d' // nice and compatible..
234 MTrack.register('a.browse-link', 'on', 'click', function(event)
236 event.preventDefault();
238 var href= this.getAttribute('href').substring(baseURL.length);
240 window.history.pushState( { url: href }, "Browse : " + href , this.href );
242 var slideleft = $(this).is('.browse-link-up') ? 0 : 1;
243 MTrack.ajaxLoad(href,slideleft);
248 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
253 $(document).ready(function() {
258 $("textarea.wiki").markItUp({
260 previewParserPath: baseURL + "/Preview",
261 root: rootURL + "/js",
262 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
265 name:'Heading 1', key:'1',
266 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
269 name:'Heading 2', key:'2',
270 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
273 name:'Heading 3', key:'3',
274 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
277 name:'Heading 4', key:'4',
278 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
281 name:'Heading 5', key:'5',
282 openWith:'====== ', closeWith:' ======',
283 placeHolder:'Your title here...'
285 {separator:'---------------' },
286 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
287 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
288 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
289 {separator:'---------------' },
290 {name:'Bulleted list', openWith:' * '},
291 {name:'Numeric list', openWith:' 1. '},
292 {separator:'---------------' },
293 {name:'Quotes', openWith:'(!(> |!|>)!)'},
294 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
295 {separator:'---------------' },
296 {name:'Preview', call:'preview', className:'preview'}
300 $.tablesorter.addParser({
303 return /^#\d+/.test(s);
305 format: function(s) {
306 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
311 $.tablesorter.addParser({
317 format: function(s) {
318 // relies on the textExtraction routine below to pull a
319 // date/time string out of the title portion of the abbr tag
320 return $.tablesorter.formatFloat(new Date(s).getTime());
327 $("table.report, table.wiki").tablesorter({
328 textExtraction: function(node) {
329 var kid = node.childNodes[0];
330 if (kid && kid.tagName == 'ABBR') {
331 // assuming that this abbr is of class='timeinterval'
334 // default 'simple' behavior
335 if (kid && kid.hasChildNodes()) {
336 return kid.innerHTML;
338 return node.innerHTML;
343 $('input.search[type=text]').each(function () {
344 if ($.browser.webkit) {
345 this.type = 'search';
346 ///$(this).attr('autosave', ABSWEB+'/');
347 $(this).attr('results', 5);
349 $(this).addClass('roundsearch');
352 // Convert links that are styled after buttons into actual buttons
353 $('a.button[href]').each(function () {
354 var href = $(this).attr('href');
355 var but = $('<button type="button"/>');
356 but.text($(this).text());
357 $(this).replaceWith(but);
358 but.click(function () {
359 document.location.href = href;
364 $.fn.mtrackWatermark = function () {
365 this.each(function () {
366 var ph = $(this).attr('title');
367 if ($.browser.webkit) {
368 // Use native safari placeholder for watermark
369 $(this).attr('placeholder', ph);
371 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
374 me.focus(function () {
377 me.removeClass('watermark').data('w', 0).val('');
383 me.addClass('watermark').data('w', 1).val(ph);
386 .closest('form').submit(function () {
395 // Watermarking -??? what??
396 $('input[title!=""]').mtrackWatermark();
399 // Arrange for the footer to sink to the bottom of the window, if the window
400 // contents are not very tall
403 function mtrack_footer_position(force) {
404 var ele = $('#footer');
406 (last_dh != $(document).height() || last_wh != $(window).height)) {
410 // Force a from-scratch layout assessment; put the footer back in
411 // it's natural location in the doc
413 position: "relative",
418 if ($(document).height() <= $(window).height()) {
420 position: "absolute",
423 $(window).scrollTop() +
430 position: "relative",
434 last_dh = $(document).height();
435 last_wh = $(window).height();
437 window.mtrack_footer_position = mtrack_footer_position;
439 .scroll(mtrack_footer_position)
440 .resize(mtrack_footer_position);
441 function mtrack_footer_set_and_wait() {
442 mtrack_footer_position();
443 setTimeout(function () {
444 mtrack_footer_set_and_wait();
447 mtrack_footer_set_and_wait();
454 // from head -- probably for reports only..
457 $(document).ready(function() {
459 $.tablesorter.addParser({
465 format: function(s) {
466 if (typeof(priorities[s]) != 'undefined') {
467 return priorities[s];
474 $.tablesorter.addParser({
480 format: function(s) {
481 if (typeof(severities[s]) != 'undefined') {
482 return severities[s];
492 $(document).ready(function(){
493 $('ul.wikitree').treeview({