changeset 4000:2fabb1410e10

make edit sibling link(../SomeThing) with gui editor
author Byeongweon [tasyblue@gmail.com]
date Fri, 08 Aug 2008 11:49:24 +0900
parents 5fbdb471fb42
children 5bb18401738b
files wiki/htdocs/applets/moinFCKplugins/moinlink/fck_link.js
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/wiki/htdocs/applets/moinFCKplugins/moinlink/fck_link.js	Fri Aug 08 09:52:49 2008 +0900
+++ b/wiki/htdocs/applets/moinFCKplugins/moinlink/fck_link.js	Fri Aug 08 11:49:24 2008 +0900
@@ -36,6 +36,25 @@
  ShowE('divInfo'  , (tabCode == 'Info'));
 }
 
+// Extends the String object, creating a "EndsWith" method on it.
+// this method is part of fckeditor dialog common library
+String.prototype.EndsWith = function( value, ignoreCase )
+{
+	var L1 = this.length ;
+	var L2 = value.length ;
+
+	if ( L2 > L1 )
+		return false ;
+
+	if ( ignoreCase )
+	{
+		var oRegex = new RegExp( value + '$' , 'i' ) ;
+		return oRegex.test( this ) ;
+	}
+	else
+		return ( L2 == 0 || this.substr( L1 - L2, L2 ) == value ) ;
+}
+
 //#### Regular Expressions library.
 var oRegex = new Object();
 
@@ -179,6 +198,11 @@
   // make links to subpages of own page relative links
   if (sHRef.StartsWith(FCKConfig['WikiPage']))
       sHRef = sHRef.Remove(0, FCKConfig['WikiPage'].length);
+  // relative link ../
+  if (oLink.innerHTML.StartsWith('../') && 
+      sHRef.EndsWith(oLink.innerHTML.substring(3, oLink.innerHTML.length))) {
+    sHRef = oLink.innerHTML;
+  }
   GetE('txtPagename').value = decodeUrl(sHRef);
   firstElement  = 'txtPagename';
  }