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',
60 $(document).ready(function() {
61 MTrack.addHandlers(); // adds to main body..
63 $('#banner select').change( function(e) {
64 // ajax change project, and refresh body..
66 url : baseURL + '/Project.html',
67 data : { active_project_id : this.value },
68 success : function() {
69 // what if it's false..currentURL = false;
70 MTrack.ajaxLoad(MTrack.currentURL, true);
81 // any date picers.. - on milestones?
82 MTrack.register('.dateinput', 'datepicker', {
84 dateFormat: 'yyyyy-mm-dd' // nice and compatible..
88 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
93 $(document).ready(function() {
98 $("textarea.wiki").markItUp({
100 previewParserPath: baseURL + "/Preview",
101 root: rootURL + "/js",
102 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
105 name:'Heading 1', key:'1',
106 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
109 name:'Heading 2', key:'2',
110 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
113 name:'Heading 3', key:'3',
114 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
117 name:'Heading 4', key:'4',
118 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
121 name:'Heading 5', key:'5',
122 openWith:'====== ', closeWith:' ======',
123 placeHolder:'Your title here...'
125 {separator:'---------------' },
126 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
127 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
128 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
129 {separator:'---------------' },
130 {name:'Bulleted list', openWith:' * '},
131 {name:'Numeric list', openWith:' 1. '},
132 {separator:'---------------' },
133 {name:'Quotes', openWith:'(!(> |!|>)!)'},
134 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
135 {separator:'---------------' },
136 {name:'Preview', call:'preview', className:'preview'}
140 $.tablesorter.addParser({
143 return /^#\d+/.test(s);
145 format: function(s) {
146 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
151 $.tablesorter.addParser({
157 format: function(s) {
158 // relies on the textExtraction routine below to pull a
159 // date/time string out of the title portion of the abbr tag
160 return $.tablesorter.formatFloat(new Date(s).getTime());
167 $("table.report, table.wiki").tablesorter({
168 textExtraction: function(node) {
169 var kid = node.childNodes[0];
170 if (kid && kid.tagName == 'ABBR') {
171 // assuming that this abbr is of class='timeinterval'
174 // default 'simple' behavior
175 if (kid && kid.hasChildNodes()) {
176 return kid.innerHTML;
178 return node.innerHTML;
183 $('input.search[type=text]').each(function () {
184 if ($.browser.webkit) {
185 this.type = 'search';
186 ///$(this).attr('autosave', ABSWEB+'/');
187 $(this).attr('results', 5);
189 $(this).addClass('roundsearch');
192 // Convert links that are styled after buttons into actual buttons
193 $('a.button[href]').each(function () {
194 var href = $(this).attr('href');
195 var but = $('<button type="button"/>');
196 but.text($(this).text());
197 $(this).replaceWith(but);
198 but.click(function () {
199 document.location.href = href;
204 $.fn.mtrackWatermark = function () {
205 this.each(function () {
206 var ph = $(this).attr('title');
207 if ($.browser.webkit) {
208 // Use native safari placeholder for watermark
209 $(this).attr('placeholder', ph);
211 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
214 me.focus(function () {
217 me.removeClass('watermark').data('w', 0).val('');
223 me.addClass('watermark').data('w', 1).val(ph);
226 .closest('form').submit(function () {
235 // Watermarking -??? what??
236 $('input[title!=""]').mtrackWatermark();
239 // Arrange for the footer to sink to the bottom of the window, if the window
240 // contents are not very tall
243 function mtrack_footer_position(force) {
244 var ele = $('#footer');
246 (last_dh != $(document).height() || last_wh != $(window).height)) {
250 // Force a from-scratch layout assessment; put the footer back in
251 // it's natural location in the doc
253 position: "relative",
258 if ($(document).height() <= $(window).height()) {
260 position: "absolute",
263 $(window).scrollTop() +
270 position: "relative",
274 last_dh = $(document).height();
275 last_wh = $(window).height();
277 window.mtrack_footer_position = mtrack_footer_position;
279 .scroll(mtrack_footer_position)
280 .resize(mtrack_footer_position);
281 function mtrack_footer_set_and_wait() {
282 mtrack_footer_position();
283 setTimeout(function () {
284 mtrack_footer_set_and_wait();
287 mtrack_footer_set_and_wait();
294 // from head -- probably for reports only..
297 $(document).ready(function() {
299 $.tablesorter.addParser({
305 format: function(s) {
306 if (typeof(priorities[s]) != 'undefined') {
307 return priorities[s];
314 $.tablesorter.addParser({
320 format: function(s) {
321 if (typeof(severities[s]) != 'undefined') {
322 return severities[s];
332 $(document).ready(function(){
333 $('ul.wikitree').treeview({