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 * MTrack.register('a.changeset-link', 'click', function() ....)
22 register : function( selector, event, arg1, arg2)
24 MTrack.registry.push( {
27 event : method == 'on' ? arg1 : false,
28 args : method == 'on' ? arg2 : arg1
32 addHandlers : function (toWhat)
34 // forEach? - no IE support?
35 toWhat = toWhat || document.body; //
36 // run the main registry
37 MTrack.registry.forEach(function(cfg) {
38 var el = Roo.get(toWhat).select(cfg.selector,true)
39 el[cfg.method].apply(el, cfg.event ? [ event, args ] : [ args ] );
41 // any other weird crap goes here.
44 Roo.select(toWhat,true).select("form").set( { "autocomplete" : "off" });
47 //jQuery.timeago.settings.allowFuture = true;
48 //$(toWhat).find('abbr.timeinterval').timeago();
50 // multipe select addon
51 //$(toWhat).find("select[multiple]").asmSelect({
52 // addItemTarget: 'bottom',
55 // removeLabel: '[x]',
63 Roo.onReady(function() {
64 MTrack.addHandlers(); // adds to main body..
67 Roo.select('#banner select').on('change', function(e) {
68 // ajax change project, and refresh body..
70 url : baseURL + '/Project.html',
71 params : { active_project_id : this.value },
72 success : function() {
73 // what if it's false..currentURL = false;
74 MTrack.ajaxLoad(MTrack.currentURL, true);
85 // any date picers.. - on milestones?
86 MTrack.register('.dateinput', 'each', function(e) {
87 var ee = new Roo.form.DateField({
88 dateFormat: 'yy-mm-dd' // nice and compatible..
96 //// ------------------- OLD STUFF NEEDS TIDY UP ----------------------
101 $(document).ready(function() {
106 $("textarea.wiki").markItUp({
108 previewParserPath: baseURL + "/Preview",
109 root: rootURL + "/js",
110 onShiftEnter: {keepDefault:false, replaceWith:'\\n\\n'},
113 name:'Heading 1', key:'1',
114 openWith:'== ', closeWith:' ==', placeHolder:'Your title here...'
117 name:'Heading 2', key:'2',
118 openWith:'=== ', closeWith:' ===', placeHolder:'Your title here...'
121 name:'Heading 3', key:'3',
122 openWith:'==== ', closeWith:' ====', placeHolder:'Your title here...'
125 name:'Heading 4', key:'4',
126 openWith:'===== ', closeWith:' =====', placeHolder:'Your title here...'
129 name:'Heading 5', key:'5',
130 openWith:'====== ', closeWith:' ======',
131 placeHolder:'Your title here...'
133 {separator:'---------------' },
134 {name:'Bold', key:'B', openWith:"'''", closeWith:"'''"},
135 {name:'Italic', key:'I', openWith:"''", closeWith:"''"},
136 {name:'Stroke through', key:'S', openWith:'~~', closeWith:'~~'},
137 {separator:'---------------' },
138 {name:'Bulleted list', openWith:' * '},
139 {name:'Numeric list', openWith:' 1. '},
140 {separator:'---------------' },
141 {name:'Quotes', openWith:'(!(> |!|>)!)'},
142 {name:'Code', openWith:'{{{\\n', closeWith:'\\n}}}'},
143 {separator:'---------------' },
144 {name:'Preview', call:'preview', className:'preview'}
148 $.tablesorter.addParser({
151 return /^#\d+/.test(s);
153 format: function(s) {
154 return $.tablesorter.formatFloat(s.replace(new RegExp(/#/g), ''));
159 $.tablesorter.addParser({
165 format: function(s) {
166 // relies on the textExtraction routine below to pull a
167 // date/time string out of the title portion of the abbr tag
168 return $.tablesorter.formatFloat(new Date(s).getTime());
175 $("table.report, table.wiki").tablesorter({
176 textExtraction: function(node) {
177 var kid = node.childNodes[0];
178 if (kid && kid.tagName == 'ABBR') {
179 // assuming that this abbr is of class='timeinterval'
182 // default 'simple' behavior
183 if (kid && kid.hasChildNodes()) {
184 return kid.innerHTML;
186 return node.innerHTML;
191 $('input.search[type=text]').each(function () {
192 if ($.browser.webkit) {
193 this.type = 'search';
194 ///$(this).attr('autosave', ABSWEB+'/');
195 $(this).attr('results', 5);
197 $(this).addClass('roundsearch');
200 // Convert links that are styled after buttons into actual buttons
201 $('a.button[href]').each(function () {
202 var href = $(this).attr('href');
203 var but = $('<button type="button"/>');
204 but.text($(this).text());
205 $(this).replaceWith(but);
206 but.click(function () {
207 document.location.href = href;
212 $.fn.mtrackWatermark = function () {
213 this.each(function () {
214 var ph = $(this).attr('title');
215 if ($.browser.webkit) {
216 // Use native safari placeholder for watermark
217 $(this).attr('placeholder', ph);
219 // http://plugins.jquery.com/files/jquery.tinywatermark-2.0.0.js.txt
222 me.focus(function () {
225 me.removeClass('watermark').data('w', 0).val('');
231 me.addClass('watermark').data('w', 1).val(ph);
234 .closest('form').submit(function () {
243 // Watermarking -??? what??
244 $('input[title!=""]').mtrackWatermark();
247 // Arrange for the footer to sink to the bottom of the window, if the window
248 // contents are not very tall
251 function mtrack_footer_position(force) {
252 var ele = $('#footer');
254 (last_dh != $(document).height() || last_wh != $(window).height)) {
258 // Force a from-scratch layout assessment; put the footer back in
259 // it's natural location in the doc
261 position: "relative",
266 if ($(document).height() <= $(window).height()) {
268 position: "absolute",
271 $(window).scrollTop() +
278 position: "relative",
282 last_dh = $(document).height();
283 last_wh = $(window).height();
285 window.mtrack_footer_position = mtrack_footer_position;
287 .scroll(mtrack_footer_position)
288 .resize(mtrack_footer_position);
289 function mtrack_footer_set_and_wait() {
290 mtrack_footer_position();
291 setTimeout(function () {
292 mtrack_footer_set_and_wait();
295 mtrack_footer_set_and_wait();
302 // from head -- probably for reports only..
305 $(document).ready(function() {
307 $.tablesorter.addParser({
313 format: function(s) {
314 if (typeof(priorities[s]) != 'undefined') {
315 return priorities[s];
322 $.tablesorter.addParser({
328 format: function(s) {
329 if (typeof(severities[s]) != 'undefined') {
330 return severities[s];
340 $(document).ready(function(){
341 $('ul.wikitree').treeview({