summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-10-15 20:44:04 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-10-15 20:44:04 +0200
commit5e1632788b8a5f5b9eebd2acb72e1de7d9f0ac63 (patch)
treec204ba3e934a2e64928d4d59395516b7c0bb881f /lib
parent20d062ca5220daf6606e2b1bcdd73d84eebafa45 (diff)
downloadrpg-5e1632788b8a5f5b9eebd2acb72e1de7d9f0ac63.tar.gz
rpg-5e1632788b8a5f5b9eebd2acb72e1de7d9f0ac63.tar.bz2
more unobstrusive javascript
The edit form now is free of inline event handlers. There are still other places where inline javascript and even document.write is used which should be fixed as well. Currently the window.onload event is used to initialize everything which may not the best way to do so. Dean Edwards may have a solution: http://dean.edwards.name/weblog/2005/09/busted/ darcs-hash:20051015184404-7ad00-2404744d008e5ea7e1b5800c96800824b532ff47.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/images/toolbar/bold.pngbin479 -> 433 bytes
-rw-r--r--lib/images/toolbar/chars.pngbin636 -> 594 bytes
-rw-r--r--lib/images/toolbar/h1.pngbin429 -> 387 bytes
-rw-r--r--lib/images/toolbar/h2.pngbin500 -> 453 bytes
-rw-r--r--lib/images/toolbar/h3.pngbin501 -> 464 bytes
-rw-r--r--lib/images/toolbar/h4.pngbin461 -> 429 bytes
-rw-r--r--lib/images/toolbar/h5.pngbin478 -> 437 bytes
-rw-r--r--lib/images/toolbar/hr.pngbin372 -> 329 bytes
-rw-r--r--lib/images/toolbar/image.pngbin680 -> 594 bytes
-rw-r--r--lib/images/toolbar/italic.pngbin363 -> 322 bytes
-rw-r--r--lib/images/toolbar/link.pngbin574 -> 554 bytes
-rw-r--r--lib/images/toolbar/linkextern.pngbin1138 -> 962 bytes
-rw-r--r--lib/images/toolbar/mono.pngbin426 -> 385 bytes
-rw-r--r--lib/images/toolbar/ol.pngbin435 -> 403 bytes
-rw-r--r--lib/images/toolbar/sig.pngbin606 -> 569 bytes
-rw-r--r--lib/images/toolbar/smiley.pngbin860 -> 730 bytes
-rw-r--r--lib/images/toolbar/spellcheck.pngbin738 -> 709 bytes
-rw-r--r--lib/images/toolbar/strike.pngbin450 -> 415 bytes
-rw-r--r--lib/images/toolbar/ul.pngbin409 -> 383 bytes
-rw-r--r--lib/images/toolbar/underline.pngbin405 -> 375 bytes
-rw-r--r--lib/scripts/edit.js106
-rw-r--r--lib/scripts/script.js126
-rw-r--r--lib/scripts/spellcheck.js8
-rw-r--r--lib/tpl/default/design.css4
24 files changed, 116 insertions, 128 deletions
diff --git a/lib/images/toolbar/bold.png b/lib/images/toolbar/bold.png
index 6ec336262..7ebe99ee9 100644
--- a/lib/images/toolbar/bold.png
+++ b/lib/images/toolbar/bold.png
Binary files differ
diff --git a/lib/images/toolbar/chars.png b/lib/images/toolbar/chars.png
index 83cdadd75..10f9107c0 100644
--- a/lib/images/toolbar/chars.png
+++ b/lib/images/toolbar/chars.png
Binary files differ
diff --git a/lib/images/toolbar/h1.png b/lib/images/toolbar/h1.png
index ffee5c159..9e4d221c7 100644
--- a/lib/images/toolbar/h1.png
+++ b/lib/images/toolbar/h1.png
Binary files differ
diff --git a/lib/images/toolbar/h2.png b/lib/images/toolbar/h2.png
index a2cc7f253..4d3cc51e9 100644
--- a/lib/images/toolbar/h2.png
+++ b/lib/images/toolbar/h2.png
Binary files differ
diff --git a/lib/images/toolbar/h3.png b/lib/images/toolbar/h3.png
index accdaf652..20419c5a0 100644
--- a/lib/images/toolbar/h3.png
+++ b/lib/images/toolbar/h3.png
Binary files differ
diff --git a/lib/images/toolbar/h4.png b/lib/images/toolbar/h4.png
index 8e5767688..a57c4c8c3 100644
--- a/lib/images/toolbar/h4.png
+++ b/lib/images/toolbar/h4.png
Binary files differ
diff --git a/lib/images/toolbar/h5.png b/lib/images/toolbar/h5.png
index 8fe10e99f..161fab356 100644
--- a/lib/images/toolbar/h5.png
+++ b/lib/images/toolbar/h5.png
Binary files differ
diff --git a/lib/images/toolbar/hr.png b/lib/images/toolbar/hr.png
index 6d68d66aa..f86a8ec94 100644
--- a/lib/images/toolbar/hr.png
+++ b/lib/images/toolbar/hr.png
Binary files differ
diff --git a/lib/images/toolbar/image.png b/lib/images/toolbar/image.png
index d1416fae9..ca284eeaf 100644
--- a/lib/images/toolbar/image.png
+++ b/lib/images/toolbar/image.png
Binary files differ
diff --git a/lib/images/toolbar/italic.png b/lib/images/toolbar/italic.png
index ab8943b45..324e7c036 100644
--- a/lib/images/toolbar/italic.png
+++ b/lib/images/toolbar/italic.png
Binary files differ
diff --git a/lib/images/toolbar/link.png b/lib/images/toolbar/link.png
index 453f0d3f1..f2a444d96 100644
--- a/lib/images/toolbar/link.png
+++ b/lib/images/toolbar/link.png
Binary files differ
diff --git a/lib/images/toolbar/linkextern.png b/lib/images/toolbar/linkextern.png
index 780c33533..75afd3dc2 100644
--- a/lib/images/toolbar/linkextern.png
+++ b/lib/images/toolbar/linkextern.png
Binary files differ
diff --git a/lib/images/toolbar/mono.png b/lib/images/toolbar/mono.png
index dd398411e..178cec9f2 100644
--- a/lib/images/toolbar/mono.png
+++ b/lib/images/toolbar/mono.png
Binary files differ
diff --git a/lib/images/toolbar/ol.png b/lib/images/toolbar/ol.png
index 91ce32b9d..3162fa21d 100644
--- a/lib/images/toolbar/ol.png
+++ b/lib/images/toolbar/ol.png
Binary files differ
diff --git a/lib/images/toolbar/sig.png b/lib/images/toolbar/sig.png
index e4aa2943c..ef997b7cd 100644
--- a/lib/images/toolbar/sig.png
+++ b/lib/images/toolbar/sig.png
Binary files differ
diff --git a/lib/images/toolbar/smiley.png b/lib/images/toolbar/smiley.png
index dee8a962a..f5d3a0a94 100644
--- a/lib/images/toolbar/smiley.png
+++ b/lib/images/toolbar/smiley.png
Binary files differ
diff --git a/lib/images/toolbar/spellcheck.png b/lib/images/toolbar/spellcheck.png
index 9aecbad4b..8e62ad2d6 100644
--- a/lib/images/toolbar/spellcheck.png
+++ b/lib/images/toolbar/spellcheck.png
Binary files differ
diff --git a/lib/images/toolbar/strike.png b/lib/images/toolbar/strike.png
index f6dd97647..203aacc2b 100644
--- a/lib/images/toolbar/strike.png
+++ b/lib/images/toolbar/strike.png
Binary files differ
diff --git a/lib/images/toolbar/ul.png b/lib/images/toolbar/ul.png
index 4331bc6c2..471171db4 100644
--- a/lib/images/toolbar/ul.png
+++ b/lib/images/toolbar/ul.png
Binary files differ
diff --git a/lib/images/toolbar/underline.png b/lib/images/toolbar/underline.png
index ee5e0d9fd..bf9665a68 100644
--- a/lib/images/toolbar/underline.png
+++ b/lib/images/toolbar/underline.png
Binary files differ
diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js
index 641124c8f..43e6843b0 100644
--- a/lib/scripts/edit.js
+++ b/lib/scripts/edit.js
@@ -21,7 +21,7 @@ function createToolButton(icon,label,key,id){
btn.title = label;
if(key){
btn.title += ' [ALT+'+key.toUpperCase()+']';
- btn.accesskey = key;
+ btn.accessKey = key;
}
// set IDs if given
@@ -127,6 +127,7 @@ function showPicker(pickerid,btn){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function initToolbar(tbid,edid,tb){
+ if(!document.getElementById) return;
var toolbar = document.getElementById(tbid);
var cnt = tb.length;
for(i=0; i<cnt; i++){
@@ -306,3 +307,106 @@ function insertAtCarret(edid,value){
if (field.createTextRange) field.caretPos = document.selection.createRange().duplicate();
}
+
+/**
+ * global var used for not saved yet warning
+ */
+var textChanged = false;
+
+/**
+ * Check for changes before leaving the page
+ */
+function changeCheck(msg){
+ if(textChanged){
+ return confirm(msg);
+ }else{
+ return true;
+ }
+}
+
+/**
+ * Add changeCheck to all Links and Forms (except those with a
+ * JSnocheck class), add handlers to monitor changes
+ *
+ * Sets focus to the editbox as well
+ */
+function initChangeCheck(msg){
+ if(!document.getElementById) return;
+ // add change check for links
+ var links = document.getElementsByTagName('a');
+ for(var i=0; i < links.length; i++){
+ if(links[i].className.indexOf('JSnocheck') == -1){
+ links[i].onclick = function(){return changeCheck(msg);};
+ links[i].onkeypress = function(){return changeCheck(msg);};
+ }
+ }
+ // add change check for forms
+ var forms = document.forms;
+ for(i=0; i < forms.length; i++){
+ if(forms[i].className.indexOf('JSnocheck') == -1){
+ forms[i].onsubmit = function(){return changeCheck(msg);};
+ }
+ }
+
+ // reset change memory var on submit
+ var btn_save = document.getElementById('edbtn_save');
+ btn_save.onclick = function(){ textChanged = false; };
+ btn_save.onkeypress = function(){ textChanged = false; };
+ var btn_prev = document.getElementById('edbtn_preview');
+ btn_prev.onclick = function(){ textChanged = false; };
+ btn_prev.onkeypress = function(){ textChanged = false; };
+
+ // add change memory setter
+ var edit_text = document.getElementById('wikitext');
+ edit_text.onchange = function(){
+ textChanged = true; //global var
+ summaryCheck();
+ }
+ edit_text.onkeyup = summaryCheck;
+ var summary = document.getElementById('summary');
+ summary.onchange = summaryCheck;
+ summary.onkeyup = summaryCheck;
+
+ // set focus
+ edit_text.focus();
+}
+
+/**
+ * Checks if a summary was entered - if not the style is changed
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function summaryCheck(){
+ var sum = document.getElementById('summary');
+ if(sum.value == ''){
+ sum.className='missing';
+ }else{
+ sum.className='edit';
+ }
+}
+
+
+/**
+ * global variable for the locktimer
+ */
+var locktimerID;
+
+/**
+ * This starts a timer to remind the user of an expiring lock
+ * Accepts the delay in seconds and a text to display.
+ */
+function init_locktimer(delay,txt){
+ txt = escapeQuotes(txt);
+ locktimerID = self.setTimeout("locktimer('"+txt+"')", delay*1000);
+}
+
+/**
+ * This stops the timer and displays a message about the expiring lock
+ */
+function locktimer(txt){
+ clearTimeout(locktimerID);
+ alert(txt);
+}
+
+
+
diff --git a/lib/scripts/script.js b/lib/scripts/script.js
index 490394dfb..44409c712 100644
--- a/lib/scripts/script.js
+++ b/lib/scripts/script.js
@@ -131,102 +131,16 @@ function hideLoadBar(){
}
}
-/**
- * Checks if a summary was entered - if not the style is changed
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-function summaryCheck(){
- if(document.getElementById){
- var sum = document.getElementById('summary');
- if(sum.value == ''){
- sum.className='missing';
- }else{
- sum.className='edit';
- }
- }
-}
-
-/**
- * This function generates the actual toolbar buttons with localized text
- * we use it to avoid creating the toolbar where javascript is not enabled
- * @deprecated
- */
-function formatButton(imageFile, speedTip, tagOpen, tagClose, sampleText, accessKey) {
- speedTip=escapeQuotes(speedTip);
- tagOpen=escapeQuotes(tagOpen);
- tagClose=escapeQuotes(tagClose);
- sampleText=escapeQuotes(sampleText);
-
- document.write("<a ");
- if(accessKey){
- document.write("accesskey=\""+accessKey+"\" ");
- speedTip = speedTip+' [ALT+'+accessKey.toUpperCase()+']';
- }
- document.write("href=\"javascript:insertTags");
- document.write("('"+tagOpen+"','"+tagClose+"','"+sampleText+"');\">");
-
- document.write("<img width=\"24\" height=\"24\" src=\""+
- DOKU_BASE+'lib/images/toolbar/'+imageFile+"\" border=\"0\" alt=\""+
- speedTip+"\" title=\""+speedTip+"\">");
- document.write("</a>");
- return;
-}
-
-/**
- * This function generates the actual toolbar buttons with localized text
- * we use it to avoid creating the toolbar where javascript is not enabled
- * @deprecated
- */
-function insertButton(imageFile, speedTip, value, accessKey) {
- speedTip=escapeQuotes(speedTip);
- value=escapeQuotes(value);
-
- document.write("<a ");
- if(accessKey){
- document.write("accesskey=\""+accessKey+"\" ");
- speedTip = speedTip+' [ALT+'+accessKey.toUpperCase()+']';
- }
- document.write("href=\"javascript:insertAtCarret");
- document.write("(document.editform.wikitext,'"+value+"');\">");
-
- document.write("<img width=\"24\" height=\"24\" src=\""+
- DOKU_BASE+'lib/images/toolbar/'+imageFile+"\" border=\"0\" alt=\""+
- speedTip+"\" title=\""+speedTip+"\">");
- document.write("</a>");
- return;
-}
-
-/**
- * This adds a button for the MediaSelection Popup
- * @deprecated
- */
-function mediaButton(imageFile, speedTip, accessKey, namespace) {
- speedTip=escapeQuotes(speedTip);
- document.write("<a ");
- if(accessKey){
- document.write("accesskey=\""+accessKey+"\" ");
- }
- document.write("href=\"javascript:void(window.open('"+DOKU_BASE+"lib/exe/media.php?ns="+
- namespace+"','mediaselect','width=600,height=320,left=70,top=50,scrollbars=yes,resizable=yes'));\">");
- document.write("<img width=\"24\" height=\"24\" src=\""+
- DOKU_BASE+'lib/images/toolbar/'+imageFile+"\" border=\"0\" alt=\""+
- speedTip+"\" title=\""+speedTip+"\">");
- document.write("</a>");
- return;
-}
-
/*
* Insert the selected filename and close the window
*
* @see http://www.alexking.org/index.php?content=software/javascript/content.php
*/
function mediaSelect(file){
- insertAtCarret(opener.document.editform.wikitext,'{{'+file+'}}');
+ opener.insertAtCarret('wikitext','{{'+file+'}}');
window.close();
}
-
/**
* For the upload Dialog. Prefills the wikiname.
*/
@@ -274,42 +188,6 @@ function toggleToc() {
}
}
-
-/**
- * global var used for not saved yet warning
- */
-var textChanged = false;
-
-function svchk(){
- if(textChanged){
- return confirm(notSavedYet);
- }else{
- return true;
- }
-}
-
-/**
- * global variable for the locktimer
- */
-var locktimerID;
-
-/**
- * This starts a timer to remind the user of an expiring lock
- * Accepts the delay in seconds and a text to display.
- */
-function init_locktimer(delay,txt){
- txt = escapeQuotes(txt);
- locktimerID = self.setTimeout("locktimer('"+txt+"')", delay*1000);
-}
-
-/**
- * This stops the timer and displays a message about the expiring lock
- */
-function locktimer(txt){
- clearTimeout(locktimerID);
- alert(txt);
-}
-
/*
* This sets a cookie by JavaScript
*
@@ -424,6 +302,8 @@ function fnt(id, e, evt) {
* Add the edit window size controls
*/
function initSizeCtl(ctlid,edid){
+ if(!document.getElementById) return;
+
var ctl = document.getElementById(ctlid);
var textarea = document.getElementById(edid);
diff --git a/lib/scripts/spellcheck.js b/lib/scripts/spellcheck.js
index d47430c31..308b3dd1f 100644
--- a/lib/scripts/spellcheck.js
+++ b/lib/scripts/spellcheck.js
@@ -171,25 +171,25 @@ function ajax_spell_class(){
case 'stop':
ajax_spell.buttonObj.onclick = function(){ ajax_spell.resume(); return false; };
ajax_spell.buttonObj.title = ajax_spell.txtStop;
- ajax_spell.buttonObj.accesskey = '';
+ ajax_spell.buttonObj.accessKey = '';
ajax_spell.imageObj.src = DOKU_BASE+'lib/images/toolbar/spellstop.png';
break;
case 'noerr':
ajax_spell.buttonObj.onclick = function(){ajax_spell.setState('start'); return false; };
ajax_spell.buttonObj.title = ajax_spell.txtNoErr;
- ajax_spell.buttonObj.accesskey = '';
+ ajax_spell.buttonObj.accessKey = '';
ajax_spell.imageObj.src = DOKU_BASE+'lib/images/toolbar/spellnoerr.png';
break;
case 'run':
ajax_spell.buttonObj.onclick = function(){return false;};
ajax_spell.buttonObj.title = ajax_spell.txtRun;
- ajax_spell.buttonObj.accesskey = '';
+ ajax_spell.buttonObj.accessKey = '';
ajax_spell.imageObj.src = DOKU_BASE+'lib/images/toolbar/spellwait.gif';
break;
default:
ajax_spell.buttonObj.onclick = function(){ ajax_spell.run(); return false; };
ajax_spell.buttonObj.title = ajax_spell.txtStart+' [ALT-K]';
- ajax_spell.buttonObj.accesskey = 'k';
+ ajax_spell.buttonObj.accessKey = 'k';
ajax_spell.imageObj.src = DOKU_BASE+'lib/images/toolbar/spellcheck.png';
break;
}
diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css
index 7bc6085f2..7b84ea614 100644
--- a/lib/tpl/default/design.css
+++ b/lib/tpl/default/design.css
@@ -637,6 +637,10 @@ div.search_quickhits {
opacity: 1;
}
+#sizectl img {
+ cursor: pointer;
+}
+
/* ---- Admin --- */
div.acladmin label {