1 //<Script type="text/javascript">
4 * The way JQuery is used, we need to continually re-apply the css handlers whenever a new segment is loaded.
6 * to solve this, we will use a simple mtrack.registry - all code get's added to it,
7 * then whenever html is loaded via AJAX, we can run run through the handlers and add them.
17 * MTrack.register('a.changeset-link', 'click', function() ....)
20 register : function( selector, event, handler)
22 MTrack.registry.push( {
29 addHandlers : function (toWhat)
31 // forEach? - no IE support?
32 toWhat = toWhat || document.body; //
33 // run the main registry
34 MTrack.registry.forEach(function(cfg) {
36 $(toWhat).find(cfg.selector)[cfg.event](cfg.handler);
38 // any other weird crap goes here.
40 if ($.browser.mozilla) {
41 $(toWhat).find("form").attr("autocomplete", "off");
44 jQuery.timeago.settings.allowFuture = true;
45 $(toWhat).find('abbr.timeinterval').timeago();
47 // multipe select addon
48 $(toWhat).find("select[multiple]").asmSelect({
49 addItemTarget: 'bottom',
58 keepLoggedIn: function()
66 $(document).ready(function() {
67 MTrack.addHandlers(); // adds to main body..
69 $('#banner select').change( function(e) {
70 // ajax change project, and refresh body..
72 url : baseURL + '/Project.html',
73 data : { active_project_id : this.value },
74 success : function() {
75 // what if it's false..currentURL = false;
76 MTrack.ajaxLoad(MTrack.currentURL, true);
87 // any date picers.. - on milestones?
88 MTrack.register('.dateinput', 'datepicker', {
90 dateFormat: 'yy-mm-dd' // nice and compatible..
94 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
99 $(document).ready(function() {
104 $("textarea.wiki").markItUp({
106 previewParserPath: baseURL + "/Preview",
107 root: rootURL + "/js",
108 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
111 name:'Heading 1', key:'1',
112 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
115 name:'Heading 2', key:'2',
116 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
119 name:'Heading 3', key:'3',
120 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
123 name:'Heading 4', key:'4',
124 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
127 name:'Heading 5', key:'5',
128 openWith:'====== ', closeWith:' ======',
129 placeHolder:'Your title here...'
131 {separator:'---------------' },
132 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
133 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
134 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
135 {separator:'---------------' },
136 {name:'Bulleted list', openWith:' * '},
137 {name:'Numeric list', openWith:' 1. '},
138 {separator:'---------------' },
139 {name:'Quotes', openWith:'(!(> |!|>)!)'},
140 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
141 {separator:'---------------' },
142 {name:'Preview', call:'preview', className:'preview'}
146 $.tablesorter.addParser({
149 return /^#\d+/.test(s);
151 format: function(s) {
152 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
157 $.tablesorter.addParser({
163 format: function(s) {
164 // relies on the textExtraction routine below to pull a
165 // date/time string out of the title portion of the abbr tag
166 return $.tablesorter.formatFloat(new Date(s).getTime());
173 $("table.report, table.wiki").tablesorter({
174 textExtraction: function(node) {
175 var kid = node.childNodes[0];
176 if (kid && kid.tagName == 'ABBR') {
177 // assuming that this abbr is of class='timeinterval'
180 // default 'simple' behavior
181 if (kid && kid.hasChildNodes()) {
182 return kid.innerHTML;
184 return node.innerHTML;
189 $('input.search[type=text]').each(function () {
190 if ($.browser.webkit) {
191 this.type = 'search';
192 ///$(this).attr('autosave', ABSWEB+'/');
193 $(this).attr('results', 5);
195 $(this).addClass('roundsearch');
198 // Convert links that are styled after buttons into actual buttons
199 $('a.button[href]').each(function () {
200 var href = $(this).attr('href');
201 var but = $('<button type="button"/>');
202 but.text($(this).text());
203 $(this).replaceWith(but);
204 but.click(function () {
205 document.location.href = href;
210 $.fn.mtrackWatermark = function () {
211 this.each(function () {
212 var ph = $(this).attr('title');
213 if ($.browser.webkit) {
214 // Use native safari placeholder for watermark
215 $(this).attr('placeholder', ph);
217 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
220 me.focus(function () {
223 me.removeClass('watermark').data('w', 0).val('');
229 me.addClass('watermark').data('w', 1).val(ph);
232 .closest('form').submit(function () {
241 // Watermarking -??? what??
242 $('input[title!=""]').mtrackWatermark();
245 // Arrange for the footer to sink to the bottom of the window, if the window
246 // contents are not very tall
249 function mtrack_footer_position(force) {
250 var ele = $('#footer');
252 (last_dh != $(document).height() || last_wh != $(window).height)) {
256 // Force a from-scratch layout assessment; put the footer back in
257 // it's natural location in the doc
259 position: "relative",
264 if ($(document).height() <= $(window).height()) {
266 position: "absolute",
269 $(window).scrollTop() +
276 position: "relative",
280 last_dh = $(document).height();
281 last_wh = $(window).height();
283 window.mtrack_footer_position = mtrack_footer_position;
285 .scroll(mtrack_footer_position)
286 .resize(mtrack_footer_position);
287 function mtrack_footer_set_and_wait() {
288 mtrack_footer_position();
289 setTimeout(function () {
290 mtrack_footer_set_and_wait();
293 mtrack_footer_set_and_wait();
300 // from head -- probably for reports only..
303 $(document).ready(function() {
305 $.tablesorter.addParser({
311 format: function(s) {
312 if (typeof(priorities[s]) != 'undefined') {
313 return priorities[s];
320 $.tablesorter.addParser({
326 format: function(s) {
327 if (typeof(severities[s]) != 'undefined') {
328 return severities[s];
338 $(document).ready(function(){
339 $('ul.wikitree').treeview({