From: rich Date: Tue, 26 Oct 2004 17:42:08 +0000 (+0000) Subject: Warning message if nothing is selected before hitting a button. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=003313a089818874e39c0926733290230354306c;p=cocanwiki.git Warning message if nothing is selected before hitting a button. --- diff --git a/debian/changelog b/debian/changelog index f7c0fb1..de4813a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -cocanwiki (1.3.5-1) unstable; urgency=low +cocanwiki (1.3.5-2) unstable; urgency=low * Initial Release. diff --git a/html/_js/editor.js b/html/_js/editor.js index 7be9b42..7479059 100644 --- a/html/_js/editor.js +++ b/html/_js/editor.js @@ -1,6 +1,6 @@ /* Javascript for OCAMLWIKI. * Copyright (C) 2004 Merjis Ltd. - * $Id: editor.js,v 1.2 2004/10/26 17:17:08 rich Exp $ + * $Id: editor.js,v 1.3 2004/10/26 17:42:08 rich Exp $ */ var delay = 1000; // Delay in milliseconds before updating. @@ -66,7 +66,7 @@ function init_edit_buttons (div_id, content_id, preview_id) div.innerHTML = edit_buttons_html; } -function replace_selection (content_id, fn) +function replace_selection (content_id, fn, warning) { var textarea = document.getElementById (content_id); @@ -78,7 +78,8 @@ function replace_selection (content_id, fn) var replacement = fn (text); textarea.value = textarea.value.substring (0, start) + replacement + textarea.value.substring (end); - } + } else + if (warning) alert (warning); } else if (document.selection) { // IE var range = document.selection.createRange (); if (range.parentElement () == textarea && range.text != "") { @@ -97,15 +98,6 @@ function replace_selection (content_id, fn) // Replace \r\n with just \n. text = text.replace ("\r\n", "\n"); - /* - var wtf; - for (i = 0; i < len; ++i) { - wtf += "," + text.charCodeAt (i); - if ((i % 32) == 0) wtf += "\n"; - } - alert (wtf); - */ - // IE's selections often include a trailing space or carriage // return. Ignore this whitespace when calling the replacement // function. @@ -122,7 +114,8 @@ function replace_selection (content_id, fn) if (append) replacement += "\n"; range.text = replacement; - } + } else + if (warning) alert (warning); } } @@ -134,7 +127,8 @@ function link (content_id, preview_id) else return "[[" + text + "]]"; }; - replace_selection (content_id, fn); + var warning = "Select an area of text first."; + replace_selection (content_id, fn, warning); update_preview_now (content_id, preview_id); } @@ -146,7 +140,8 @@ function bold (content_id, preview_id) else return "" + text + ""; }; - replace_selection (content_id, fn); + var warning = "Select an area of text first."; + replace_selection (content_id, fn, warning); update_preview_now (content_id, preview_id); } @@ -158,7 +153,8 @@ function italic (content_id, preview_id) else return "" + text + ""; }; - replace_selection (content_id, fn); + var warning = "Select an area of text first."; + replace_selection (content_id, fn, warning); update_preview_now (content_id, preview_id); } @@ -170,7 +166,8 @@ function strikeout (content_id, preview_id) else return "" + text + ""; }; - replace_selection (content_id, fn); + var warning = "Select an area of text first."; + replace_selection (content_id, fn, warning); update_preview_now (content_id, preview_id); } @@ -182,7 +179,8 @@ function bullet (content_id, preview_id) else return "* " + text.replace (/\n/g, "\n* "); }; - replace_selection (content_id, fn); + var warning = "Select some whole lines of text first."; + replace_selection (content_id, fn, warning); update_preview_now (content_id, preview_id); } @@ -194,6 +192,7 @@ function numbered (content_id, preview_id) else return "# " + text.replace (/\n/g, "\n# "); }; - replace_selection (content_id, fn); + var warning = "Select some whole lines of text first."; + replace_selection (content_id, fn, warning); update_preview_now (content_id, preview_id); }