]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/media/js/osqa.main.js
forgot to check in the main javascript file. sorry.
[osqa.git] / forum / skins / default / media / js / osqa.main.js
index dc84677ba01f3a2efd228ae941bdcf4ca744508b..487b1dbe0a0a8ea152aa67cb1f3e71deabd15e9c 100644 (file)
@@ -49,10 +49,7 @@ var response_commands = {
         }\r
     },\r
 \r
-    mark_accepted: function(id) {\r
-        $('.accepted-answer').removeClass('accepted-answer');\r
-        $('.accept-answer.on').removeClass('on');\r
-        \r
+    mark_accepted: function(id) {        \r
         var $answer = $('#answer-container-' + id);\r
         $answer.addClass('accepted-answer');\r
         $answer.find('.accept-answer').addClass('on');\r
@@ -163,6 +160,8 @@ function show_dialog (extern) {
 \r
     $dialog = $(html);\r
     $('body').append($dialog);\r
+    var message = $('.dialog-content')[0];\r
+    message.style.visibility = "hidden";\r
 \r
     if (options.dim === false) {\r
         $dialog.css({\r
@@ -189,8 +188,10 @@ function show_dialog (extern) {
         left: "-=" + (options.dim.w / 2),\r
         width: options.dim.w,\r
         height: options.dim.h\r
-    }, 200);\r
-    \r
+    }, 200, function() {\r
+        message.style.visibility = "visible";\r
+    });\r
+\r
     $dialog.find('.dialog-no').click(function() {\r
         default_close_function($dialog);\r
     });\r
@@ -225,12 +226,11 @@ function show_message(evt, msg, callback) {
     });\r
 }\r
 \r
-function load_prompt(evt, url) {\r
+function load_prompt(evt, el, url) {\r
     $.get(url, function(data) {\r
-        var $dialog = show_dialog({\r
-            html: data,\r
+        var doptions = {\r
+         html: data,\r
             extra_class: 'prompt',\r
-            event: evt,\r
             yes_callback: function() {\r
                 var postvars = {};\r
                 $dialog.find('input, textarea, select').each(function() {\r
@@ -244,7 +244,13 @@ function load_prompt(evt, url) {
                 }, 'json');\r
             },\r
             show_no: true\r
-        });\r
+        }\r
+\r
+        if (!el.is('.centered')) {\r
+            doptions.event = evt;\r
+        }\r
+\r
+        var $dialog = show_dialog(doptions);\r
     });\r
 }\r
 \r
@@ -290,15 +296,16 @@ $(function() {
     $('a.ajax-command').live('click', function(evt) {\r
         if (running) return false;\r
 \r
+        $('.context-menu-dropdown').slideUp('fast');\r
+\r
         var el = $(this);\r
 \r
         if (el.is('.withprompt')) {\r
-            load_prompt(evt, el.attr('href'));\r
+            load_prompt(evt, el, el.attr('href'));\r
         } else if(el.is('.confirm')) {\r
-            $dialog = show_dialog({\r
+            var doptions = {\r
                 html: messages.confirm,\r
                 extra_class: 'confirm',\r
-                event: evt,\r
                 yes_callback: function() {\r
                     start_command();\r
                     $.getJSON(el.attr('href'), function(data) {\r
@@ -311,7 +318,12 @@ $(function() {
                 yes_text: messages.yes,\r
                 show_no: true,\r
                 no_text: messages.no\r
-            });\r
+            }\r
+\r
+            if (!el.is('.centered')) {\r
+                doptions.event = evt;\r
+            }\r
+            var $dialog = show_dialog(doptions);\r
         } else {\r
             start_command();\r
             $.getJSON(el.attr('href'), function(data) {\r
@@ -331,7 +343,8 @@ $(function() {
             $dropdown.slideToggle('fast', function() {\r
                 if ($dropdown.is(':visible')) {\r
                    $dropdown.one('clickoutside', function() {\r
-                        $dropdown.slideUp('fast')\r
+                       if ($dropdown.is(':visible'))\r
+                            $dropdown.slideUp('fast');\r
                     });\r
                 }\r
             });    \r
@@ -435,6 +448,7 @@ $(function() {
             function show_comment_form() {\r
                 $container.slideDown('slow');\r
                 $add_comment_link.fadeOut('slow');\r
+                $textarea.focus();\r
                 window.setInterval(function() {\r
                     process_form_changes();\r
                 }, 200);\r
@@ -496,11 +510,14 @@ $(function() {
                 return false;\r
             });\r
 \r
-            $cancel.click(function() {\r
-                if (comment_in_form) {\r
-                    $comment = $('#comment-' + comment_in_form).slideDown('slow');\r
+            $cancel.click(function(event) {\r
+                if (confirm("You will lose all of your changes in this comment.  Do you still wish to proceed?")){\r
+                    if (comment_in_form) {\r
+                        $comment = $('#comment-' + comment_in_form).slideDown('slow');\r
+                    }\r
+                    hide_comment_form();\r
+                    cleanup_form();\r
                 }\r
-                hide_comment_form();\r
                 return false;\r
             });\r
         }\r
@@ -535,7 +552,8 @@ function pickedTags(){
 \r
         var call_settings = {\r
             type:'POST',\r
-            url:url\r
+            url:url,\r
+            data: ''\r
         };\r
         if (callback !== false){\r
             call_settings.success = callback;\r
@@ -662,7 +680,7 @@ function pickedTags(){
         init: function(){\r
             collectPickedTags();\r
             setupHideIgnoredQuestionsControl();\r
-            $("#interestingTagInput, #ignoredTagInput").autocomplete("/matching_tags/", {\r
+            $("#interestingTagInput, #ignoredTagInput").autocomplete(messages.matching_tags_url, {\r
                 minChars: 1,\r
                 matchContains: true,\r
                 max: 20,\r
@@ -684,11 +702,6 @@ function pickedTags(){
     };\r
 }\r
 \r
-$(document).ready( function(){\r
-    //if (window.tags != undefined)\r
-        pickedTags().init();\r
-});\r
-\r
 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;c<Hilite.search_engines.length;c++){var f=Hilite.search_engines[c];e.compile("^http://(www\\.)?"+f[0],"i");var b=d.match(e);if(b){var a;if(isNaN(f[1])){a=Hilite.decodeReferrerQS(d,f[1])}else{a=b[f[1]+1]}if(a){a=decodeURIComponent(a);if(f.length>2&&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;b<e.length;b++){e[b]=e[b].toLowerCase();if(Hilite.exact){c.push("\\b"+e[b]+"\\b")}else{c.push(e[b])}}c=new RegExp(c.join("|"),"i");var a={};for(var b=0;b<e.length;b++){if(Hilite.style_name_suffix){a[e[b]]=Hilite.style_name+(b+1)}else{a[e[b]]=Hilite.style_name}}var d=function(m){var j=c.exec(m.data);if(j){var n=j[0];var i="";var h=m.splitText(j.index);var g=h.splitText(n.length);var l=m.ownerDocument.createElement("SPAN");m.parentNode.replaceChild(l,h);l.className=a[n.toLowerCase()];l.appendChild(h);return l}else{return m}};Hilite.walkElements(f.childNodes[0],1,d)};Hilite.hilite=function(){var a=Hilite.debug_referrer?Hilite.debug_referrer:document.referrer;var b=null;a=Hilite.decodeReferrer(a);if(a&&((Hilite.elementid&&(b=document.getElementById(Hilite.elementid)))||(b=document.body))){Hilite.hiliteElement(b,a)}};Hilite.walkElements=function(d,f,e){var a=/^(script|style|textarea)/i;var c=0;while(d&&f>0){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()}}}};\r
 \r
 var mediaUrl = function(resource){\r
@@ -1033,4 +1046,35 @@ var notify = function() {
  * Dual licensed under the MIT and GPL licenses.\r
  * http://benalman.com/about/license/\r
  */\r
-(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");\r
+\r
+$(document).ready( function(){\r
+    pickedTags().init();\r
+\r
+    $('input#bnewaccount').click(function() {\r
+        $('#bnewaccount').disabled=true;\r
+    });\r
+});\r
+\r
+function yourWorkWillBeLost(e) {\r
+    if(browserTester('chrome')) {\r
+        return "You sure you want to leave?  Your work will be lost.";\r
+    } else if(browserTester('safari')) {\r
+        return "You sure you want to leave?  Your work will be lost.";\r
+    } else {\r
+        if(!e) e = window.event;\r
+        e.cancelBubble = true;\r
+        e.returnValue = 'If you leave your work will be lost.';\r
+\r
+        if (e.stopPropagation) {\r
+            e.stopPropagation();\r
+            e.preventDefault();\r
+        }\r
+        return e;\r
+    }\r
+}\r
+\r
+function browserTester(browserString) {\r
+    var test = navigator.userAgent;\r
+    return navigator.userAgent.toLowerCase().indexOf(browserString) > -1;\r
+}
\ No newline at end of file