X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/a315fa9ad9fd25006b64983f54bd4d0dde70dec3..de421bfc33978f3d11fdbe247d6c34ff205e39eb:/forum/skins/default/media/js/osqa.main.js diff --git a/forum/skins/default/media/js/osqa.main.js b/forum/skins/default/media/js/osqa.main.js index dc84677..487b1db 100644 --- a/forum/skins/default/media/js/osqa.main.js +++ b/forum/skins/default/media/js/osqa.main.js @@ -49,10 +49,7 @@ var response_commands = { } }, - mark_accepted: function(id) { - $('.accepted-answer').removeClass('accepted-answer'); - $('.accept-answer.on').removeClass('on'); - + mark_accepted: function(id) { var $answer = $('#answer-container-' + id); $answer.addClass('accepted-answer'); $answer.find('.accept-answer').addClass('on'); @@ -163,6 +160,8 @@ function show_dialog (extern) { $dialog = $(html); $('body').append($dialog); + var message = $('.dialog-content')[0]; + message.style.visibility = "hidden"; if (options.dim === false) { $dialog.css({ @@ -189,8 +188,10 @@ function show_dialog (extern) { left: "-=" + (options.dim.w / 2), width: options.dim.w, height: options.dim.h - }, 200); - + }, 200, function() { + message.style.visibility = "visible"; + }); + $dialog.find('.dialog-no').click(function() { default_close_function($dialog); }); @@ -225,12 +226,11 @@ function show_message(evt, msg, callback) { }); } -function load_prompt(evt, url) { +function load_prompt(evt, el, url) { $.get(url, function(data) { - var $dialog = show_dialog({ - html: data, + var doptions = { + html: data, extra_class: 'prompt', - event: evt, yes_callback: function() { var postvars = {}; $dialog.find('input, textarea, select').each(function() { @@ -244,7 +244,13 @@ function load_prompt(evt, url) { }, 'json'); }, show_no: true - }); + } + + if (!el.is('.centered')) { + doptions.event = evt; + } + + var $dialog = show_dialog(doptions); }); } @@ -290,15 +296,16 @@ $(function() { $('a.ajax-command').live('click', function(evt) { if (running) return false; + $('.context-menu-dropdown').slideUp('fast'); + var el = $(this); if (el.is('.withprompt')) { - load_prompt(evt, el.attr('href')); + load_prompt(evt, el, el.attr('href')); } else if(el.is('.confirm')) { - $dialog = show_dialog({ + var doptions = { html: messages.confirm, extra_class: 'confirm', - event: evt, yes_callback: function() { start_command(); $.getJSON(el.attr('href'), function(data) { @@ -311,7 +318,12 @@ $(function() { yes_text: messages.yes, show_no: true, no_text: messages.no - }); + } + + if (!el.is('.centered')) { + doptions.event = evt; + } + var $dialog = show_dialog(doptions); } else { start_command(); $.getJSON(el.attr('href'), function(data) { @@ -331,7 +343,8 @@ $(function() { $dropdown.slideToggle('fast', function() { if ($dropdown.is(':visible')) { $dropdown.one('clickoutside', function() { - $dropdown.slideUp('fast') + if ($dropdown.is(':visible')) + $dropdown.slideUp('fast'); }); } }); @@ -435,6 +448,7 @@ $(function() { function show_comment_form() { $container.slideDown('slow'); $add_comment_link.fadeOut('slow'); + $textarea.focus(); window.setInterval(function() { process_form_changes(); }, 200); @@ -496,11 +510,14 @@ $(function() { return false; }); - $cancel.click(function() { - if (comment_in_form) { - $comment = $('#comment-' + comment_in_form).slideDown('slow'); + $cancel.click(function(event) { + if (confirm("You will lose all of your changes in this comment. Do you still wish to proceed?")){ + if (comment_in_form) { + $comment = $('#comment-' + comment_in_form).slideDown('slow'); + } + hide_comment_form(); + cleanup_form(); } - hide_comment_form(); return false; }); } @@ -535,7 +552,8 @@ function pickedTags(){ var call_settings = { type:'POST', - url:url + url:url, + data: '' }; if (callback !== false){ call_settings.success = callback; @@ -662,7 +680,7 @@ function pickedTags(){ init: function(){ collectPickedTags(); setupHideIgnoredQuestionsControl(); - $("#interestingTagInput, #ignoredTagInput").autocomplete("/matching_tags/", { + $("#interestingTagInput, #ignoredTagInput").autocomplete(messages.matching_tags_url, { minChars: 1, matchContains: true, max: 20, @@ -684,11 +702,6 @@ function pickedTags(){ }; } -$(document).ready( function(){ - //if (window.tags != undefined) - pickedTags().init(); -}); - Hilite={elementid:"content",exact:true,max_nodes:1000,onload:true,style_name:"hilite",style_name_suffix:true,debug_referrer:""};Hilite.search_engines=[["local","q"],["cnprog\\.","q"],["google\\.","q"],["search\\.yahoo\\.","p"],["search\\.msn\\.","q"],["search\\.live\\.","query"],["search\\.aol\\.","userQuery"],["ask\\.com","q"],["altavista\\.","q"],["feedster\\.","q"],["search\\.lycos\\.","q"],["alltheweb\\.","q"],["technorati\\.com/search/([^\\?/]+)",1],["dogpile\\.com/info\\.dogpl/search/web/([^\\?/]+)",1,true]];Hilite.decodeReferrer=function(d){var g=null;var e=new RegExp("");for(var c=0;c2&&f[2]){a=decodeURIComponent(a)}a=a.replace(/\'|"/g,"");a=a.split(/[\s,\+\.]+/);return a}break}}return null};Hilite.decodeReferrerQS=function(f,d){var b=f.indexOf("?");var c;if(b>=0){var a=new String(f.substring(b+1));b=0;c=0;while((b>=0)&&((c=a.indexOf("=",b))>=0)){var e,g;e=a.substring(b,c);b=a.indexOf("&",c)+1;if(e==d){if(b<=0){return a.substring(c+1)}else{return a.substring(c+1,b-1)}}else{if(b<=0){return null}}}}return null};Hilite.hiliteElement=function(f,e){if(!e||f.childNodes.length==0){return}var c=new Array();for(var b=0;b0){c++;if(c>=Hilite.max_nodes){var b=function(){Hilite.walkElements(d,f,e)};setTimeout(b,50);return}if(d.nodeType==1){if(!a.test(d.tagName)&&d.childNodes.length>0){d=d.childNodes[0];f++;continue}}else{if(d.nodeType==3){d=e(d)}}if(d.nextSibling){d=d.nextSibling}else{while(f>0){d=d.parentNode;f--;if(d.nextSibling){d=d.nextSibling;break}}}}};if(Hilite.onload){if(window.attachEvent){window.attachEvent("onload",Hilite.hilite)}else{if(window.addEventListener){window.addEventListener("load",Hilite.hilite,false)}else{var __onload=window.onload;window.onload=function(){Hilite.hilite();__onload()}}}}; var mediaUrl = function(resource){ @@ -1033,4 +1046,35 @@ var notify = function() { * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ -(function($,c,b){$.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "),function(d){a(d)});a("focusin","focus"+b);a("focusout","blur"+b);$.addOutsideEvent=a;function a(g,e){e=e||g+b;var d=$(),h=g+"."+e+"-special-event";$.event.special[e]={setup:function(){d=d.add(this);if(d.length===1){$(c).bind(h,f)}},teardown:function(){d=d.not(this);if(d.length===0){$(c).unbind(h)}},add:function(i){var j=i.handler;i.handler=function(l,k){l.target=k;j.apply(this,arguments)}}};function f(i){$(d).each(function(){var j=$(this);if(this!==i.target&&!j.has(i.target).length){j.triggerHandler(e,[i.target])}})}}})(jQuery,document,"outside"); \ No newline at end of file +(function($,c,b){$.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "),function(d){a(d)});a("focusin","focus"+b);a("focusout","blur"+b);$.addOutsideEvent=a;function a(g,e){e=e||g+b;var d=$(),h=g+"."+e+"-special-event";$.event.special[e]={setup:function(){d=d.add(this);if(d.length===1){$(c).bind(h,f)}},teardown:function(){d=d.not(this);if(d.length===0){$(c).unbind(h)}},add:function(i){var j=i.handler;i.handler=function(l,k){l.target=k;j.apply(this,arguments)}}};function f(i){$(d).each(function(){var j=$(this);if(this!==i.target&&!j.has(i.target).length){j.triggerHandler(e,[i.target])}})}}})(jQuery,document,"outside"); + +$(document).ready( function(){ + pickedTags().init(); + + $('input#bnewaccount').click(function() { + $('#bnewaccount').disabled=true; + }); +}); + +function yourWorkWillBeLost(e) { + if(browserTester('chrome')) { + return "You sure you want to leave? Your work will be lost."; + } else if(browserTester('safari')) { + return "You sure you want to leave? Your work will be lost."; + } else { + if(!e) e = window.event; + e.cancelBubble = true; + e.returnValue = 'If you leave your work will be lost.'; + + if (e.stopPropagation) { + e.stopPropagation(); + e.preventDefault(); + } + return e; + } +} + +function browserTester(browserString) { + var test = navigator.userAgent; + return navigator.userAgent.toLowerCase().indexOf(browserString) > -1; +} \ No newline at end of file