]> git.openstreetmap.org Git - osqa.git/commitdiff
hopefully this will clear up all issues concerning the adding/editing of answers...
authorcourt <court@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 19 Aug 2010 21:21:49 +0000 (21:21 +0000)
committercourt <court@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 19 Aug 2010 21:21:49 +0000 (21:21 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@560 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/skins/default/media/js/osqa.main.js
forum/skins/default/media/js/wmd/wmd.css
forum/skins/default/media/style/style.css
forum/skins/default/templates/answer_edit.html
forum/skins/default/templates/ask.html
forum/skins/default/templates/question.html
forum/skins/default/templates/question_edit.html

index 4b07d9b914d2703f32252a24158f62a4483768aa..677b365e044bf36dc7e04b11e98033720834e8b6 100644 (file)
@@ -1059,7 +1059,7 @@ $(document).ready( function(){
 function yourWorkWillBeLost(e) {\r
        if(!e) e = window.event;\r
        e.cancelBubble = true;\r
-       e.returnValue = 'You sure you want to leave?  Your work will be lost.';\r
+       e.returnValue = 'If you leave your work will be lost.';\r
 \r
        if (e.stopPropagation) {\r
                e.stopPropagation();\r
index 057eefda0b7fe5d684432c76db277a810c241b78..c71ba6e431c6f358a02f3c1b2c0a3c6cf455a00a 100644 (file)
@@ -58,8 +58,6 @@ body
        
        position: absolute;
     background-color:#aaaaaa;
-    /*border-color:#aaaaaa;
-    border-style:solid;*/
        display: inline-block;
        list-style: none;
 }
index 9b844c5cc2cc78b1e40d229c94e268372477c3a6..61b8281466ee94f759488242592a7ce98fc6094b 100644 (file)
@@ -1812,3 +1812,9 @@ div.subscription_tags a:hover {
     color: #FFFFFF;
 }
 
+div.wmd-button {
+    color:white;
+}
+div.wmd-button-bar {
+    float:left;
+}
\ No newline at end of file
index 66712ac526ceff97d8f8a5175dc24e3eb715642f..d7423af6c60e21f38cefc523ffd7c922716d63bb 100644 (file)
@@ -12,7 +12,8 @@
         $().ready(function(){
             $("#nav_questions").attr('className',"on");
             $('#editor').TextAreaResizer();
-                             
+
+
             //toggle preview of editor
             var display = true;
             var txt = "{% trans "hide preview" %}";
                 $('#pre-collapse').text(txt);
             });
 
-            
+
             $('#id_revision').unbind().change(function(){
                 $("#select_revision").click();
             });
+
+
+            answer = $("textarea#editor")[0].value;
         });
 
-        function beforeUnload(e) {
-            if($("textarea#editor")[0].value != "") {
-               yourWorkWillBeLost(e);
+
+        function submitClicked(e) {
+            if(!is_chrome) {
+                $("input.submit")[0].disabled=true;
+                $("input.submit")[1].disabled=true;
             }
+            window.removeEventListener('beforeunload', beforeUnload, true);
+        }
 
-            return false;
+        function beforeUnload(e) {
+            var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
+            if($("textarea#editor")[0].value != answer) {
+                 if(is_chrome) {
+                     return "You sure you want to leave?  Your work will be lost.";
+                 } else {
+                     yourWorkWillBeLost(e);
+                 }
+                 return false;
+            }
         }
         window.addEventListener('beforeunload', beforeUnload, true);
+
+
+        var answer = "";
+        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
         </script>
 {% endblock %}
         
@@ -73,8 +94,8 @@
             <div class="title-desc">
                 {{ form.summary.help_text }}
             </div>
-            <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
-            <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);" />
+            <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event)" />
+            <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);submitClicked(event)" />
         </form>
     </div>
 </div>
index 6be8f59e9f74c1836538195020fe91bf4ef8ddd3..c65bf9f676f37bc1136452e4b40b04b4d3d61638 100644 (file)
                 }
 
             });
+
         });
 
+        function submitClicked(e) {
+            if(!is_chrome)$("input.submit")[0].disabled=true;
+            window.removeEventListener('beforeunload', beforeUnload, true);
+        }
+
         function beforeUnload(e) {
             if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
-                yourWorkWillBeLost(e);
+                if(is_chrome) {
+                    return "You sure you want to leave?  Your work will be lost.";
+                } else {
+                    yourWorkWillBeLost(e);
+                }
             }
             return false;
         }
         window.addEventListener('beforeunload', beforeUnload, true);
 
-        function submitClicked() {
-            window.removeEventListener('beforeunload', beforeUnload, true);
-            $("input.submit").each(function() {
-                this.disabled=true;
-            });
-        }
-
+        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
         var related_questions_url = "{% url related_questions %}";
         </script>
         <script src="{% media "/media/js/osqa.ask.js" %}" type="text/javascript"></script>
                        <p class="title-desc">
                                {{ form.tags.help_text }}
                        </p>
-            {% if not request.user.is_authenticated %}
-            <input name="ask" type="submit" value="{% trans "Login/signup to post your question" %}" class="submit" />
+            {% if not request.user.is_authenticated %}                                                                        
+            <input name="ask" type="submit" value="{% trans "Login/signup to post your question" %}" class="submit" onclick="submitClicked(event)"/>
                        {% else %}
-            <input name="ask" type="submit" value="{% trans "Ask your question" %}" class="submit" onclick="submitClicked()" />
+            <input name="ask" type="submit" value="{% trans "Ask your question" %}" class="submit" onclick="submitClicked(event)"/>
             {% endif %}
         </form>
     </div>
index a9a170608a036ac8df4d873040d8ff655adf3eab..7afcf407e372a7d94e72f15ad5f3745053140850 100644 (file)
                 $('#previewer').toggle();\r
                 $('#pre-collapse').text(txt);\r
             });\r
-\r
         });\r
 \r
+        function submitClicked(e) {\r
+            if(!is_chrome)$("input.submit")[0].disabled=true;\r
+            window.removeEventListener('beforeunload', beforeUnload, true);\r
+        }\r
+\r
         function beforeUnload(e) {\r
+            var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;\r
+\r
             if($("textarea#editor")[0].value != "") {\r
-               yourWorkWillBeLost(e);\r
+                if(is_chrome) {\r
+                    return "You sure you want to leave?  Your work will be lost.";\r
+                } else {\r
+                    yourWorkWillBeLost(e);\r
+                }\r
+                return false;\r
             }\r
 \r
-            $("textarea.commentBox").each(function() {\r
-               if(this.value != "") {\r
-                   yourWorkWillBeLost(e);\r
-               }\r
-            });\r
-\r
-            return false;\r
+            var commentBoxes = $("textarea.commentBox");\r
+            for(var index = 0; index < commentBoxes.length; index++) {\r
+                if(commentBoxes[index].value != "") {\r
+                    if(is_chrome) {\r
+                        return "You sure you want to leave?  Your work will be lost.";\r
+                    } else {\r
+                        yourWorkWillBeLost(e);\r
+                    }\r
+                    return false;\r
+                }\r
+            }\r
         }\r
         window.addEventListener('beforeunload', beforeUnload, true);\r
 \r
-        function submitClicked() {\r
-             window.removeEventListener('beforeunload', beforeUnload, true);\r
-             $("input.submit").each(function() {\r
-                 this.disabled=true;\r
-             });\r
-         }\r
-\r
-         </script>\r
+        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;\r
+        </script>\r
         <noscript>\r
             <style>\r
                 .comment.not_top_scorer {\r
                         value="{% trans "Answer the question" %}" \r
                         {% endif %}\r
                     {% endif %}\r
-                    class="submit" style="float:left" onclick="submitClicked()" />\r
+                    class="submit" style="float:left" onclick="submitClicked(event)"/>\r
             {% endif %}\r
         </form>\r
     </div>\r
index 25ea9bb67a91ef67bed8a03261d3e6eb04fc7a11..1d3246c7d1e36a78c2ffdcf1aa1833618d9d63ab 100644 (file)
             });
 
             init = $("textarea#editor")[0].value;
+
+            title = $("input#id_title")[0].value;
+            body = $("textarea#editor")[0].value;
+            tag = $("input#id_tags")[0].value;
         });
 
-         function beforeUnload(e) {
-             if($("input#id_title")[0].value != "" || $("textarea#editor")[0].value != "" || $("input#id_tags")[0].value != "") {
-                 yourWorkWillBeLost(e);
-             }
-             return false;
-         }
-         window.addEventListener('beforeunload', beforeUnload, true);
+        function submitClicked(e) {
+            if(!is_chrome) {
+                $("input.submit")[0].disabled=true;
+                $("input.submit")[1].disabled=true;
+            }
+            window.removeEventListener('beforeunload', beforeUnload, true);
+        }
+
+        function beforeUnload(e) {
+            var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
+
+            if($("input#id_title")[0].value != title || $("textarea#editor")[0].value != body || $("input#id_tags")[0].value != tag) {
+                 if(is_chrome) {
+                     return "You sure you want to leave?  Your work will be lost.";
+                 } else {
+                     yourWorkWillBeLost(e);
+                 }
+                 return false;
+            }
+        }
+        window.addEventListener('beforeunload', beforeUnload, true);
 
         var init = "";
+        var title = "";
+        var body = "";
+        var tag = "";
+        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
         </script>
 {% endblock %}
         
                 {{ form.summary.help_text }}
             </div>
             <div class="error" ></div>
-            <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
-
+            <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="submitClicked(event)" />
+            <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);submitClicked(event)" />
         </form>
     </div>
 </div>