X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/1466fc2b08115122396e0cdf6871287db2e5317c..c07bef148aa59e35fe84e0c0cc8acff2cb5c6ee5:/forum/skins/default/media/js/osqa.main.js?ds=sidebyside diff --git a/forum/skins/default/media/js/osqa.main.js b/forum/skins/default/media/js/osqa.main.js index 0a8b86e..79cda45 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'); @@ -229,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() { @@ -248,7 +244,13 @@ function load_prompt(evt, url) { }, 'json'); }, show_no: true - }); + } + + if (!el.is('.centered')) { + doptions.event = evt; + } + + var $dialog = show_dialog(doptions); }); } @@ -294,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) { @@ -315,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) { @@ -335,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'); }); } }); @@ -501,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; }); } @@ -540,7 +552,8 @@ function pickedTags(){ var call_settings = { type:'POST', - url:url + url:url, + data: '' }; if (callback !== false){ call_settings.success = callback; @@ -667,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, @@ -675,11 +688,11 @@ function pickedTags(){ multipleSeparator: " "*/ formatItem: function(row, i, max, value) { - return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")"; + return row[1] + " (" + row[2] + ")"; }, formatResult: function(row, i, max, value){ - return row[0]; + return row[1]; } }); @@ -689,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){ @@ -1038,4 +1046,53 @@ 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 "Are you sure you want to leave? Your work will be lost."; + } else if(browserTester('safari')) { + return "Are 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) { + return navigator.userAgent.toLowerCase().indexOf(browserString) > -1; +} + +// Add missing IE functionality +if (!window.addEventListener) { + if (window.attachEvent) { + window.addEventListener = function (type, listener, useCapture) { + window.attachEvent('on' + type, listener); + }; + window.removeEventListener = function (type, listener, useCapture) { + window.detachEvent('on' + type, listener); + }; + } else { + window.addEventListener = function (type, listener, useCapture) { + window['on' + type] = listener; + }; + window.removeEventListener = function (type, listener, useCapture) { + window['on' + type] = null; + }; + } +} \ No newline at end of file