Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merging from stable

  • Loading branch information...
commit bb9cd4503a8a48c46b76442c3385277b84a3dd75 1 parent 3d05094
authored July 30, 2006

Showing 1 changed file with 12 additions and 70 deletions. Show diff stats Hide diff stats

  1. 82  lib/editor/htmlarea/htmlarea.php
82  lib/editor/htmlarea/htmlarea.php
@@ -1470,26 +1470,21 @@ function (str, l1, l2, l3) {
1470 1470
         }
1471 1471
         var a = link;
1472 1472
         if (!a) {
1473  
-            editor._doc.execCommand("createlink", false, param.f_href);
1474  
-            a = editor.getParentElement();
  1473
+            // Since startContainer check does not work
  1474
+            // very well in Moz use just insertHTML.
1475 1475
             var sel = editor._getSelection();
1476 1476
             var range = editor._createRange(sel);
1477  
-            /// Removed by PJ and Martin, Moodle bug #1455
1478  
-            /// Removed uncommenting since it prevents this function
1479  
-            /// to read given attributes for <a> tag such as target, title etc...
1480  
-            if (!HTMLArea.is_ie) {
1481  
-                try {
1482  
-                    a = range.startContainer;
1483  
-                    if (!/^a$/i.test(a.tagName)) {
1484  
-                        a = a.nextSibling;
1485  
-                        if ( a == null ) {
1486  
-                            a = range.startContainer.parentNode;
1487  
-                        }
1488  
-                    }
1489  
-                } catch (e) {
1490  
-                        alert("Send this message to bug tracker: " + e);
1491  
-                }
  1477
+            var strLink  = '<a href="'+ param.f_href.trim() +'"';
  1478
+            if ( param.f_title != "" ) {
  1479
+                strLink += ' title="'+ param.f_title.trim() +'"';
1492 1480
             }
  1481
+            if ( param.f_target != "" ) {
  1482
+                strLink += ' target="'+ param.f_target.trim() +'"';
  1483
+            }
  1484
+            strLink += '>';
  1485
+            strLink += (!HTMLArea.is_ie) ? sel : range.text;
  1486
+            strLink += '</a>';
  1487
+            editor.insertHTML(strLink);
1493 1488
         } else {
1494 1489
             var href = param.f_href.trim();
1495 1490
             editor.selectNodeContents(a);
@@ -2358,8 +2353,6 @@ function getMozSelection(txtarea) {
2358 2353
         break;      // skip comments, for now.
2359 2354
     }
2360 2355
 
2361  
-    // Still not workin' correctly...
2362  
-    //return HTMLArea.formathtml(html);
2363 2356
     return html;
2364 2357
 };
2365 2358
 
@@ -2484,54 +2477,3 @@ function hex(d) {
2484 2477
             return el;
2485 2478
     return null;
2486 2479
 };
2487  
-
2488  
-HTMLArea.formathtml = function (html) {
2489  
-    // Original idea from FCKeditor
2490  
-    // http://www.fckeditor.net/
2491  
-    // by Frederico Caldeira Knabben
2492  
-
2493  
-    var indentchar = '    ';
2494  
-    var format     = new Object();
2495  
-    format.regex   = new Object();
2496  
-
2497  
-    format.regex.tagopen  = /<[^\/](P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|AREA|OPTION)[^>]*>/gi ;
2498  
-    format.regex.tagclose = /<\/{1}(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|AREA|OPTION)[^>]*>/gi ;
2499  
-    format.regex.newlines = /<(BR|HR)[^>]>/gi ;
2500  
-    format.regex.tagsmain = /<\/?(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR)[^>]*>/gi ;
2501  
-    format.regex.splitter = /\s*\n+\s*/g ;
2502  
-    format.regex.notouchy = /<\/?(span|font)[^>]*>/gi;
2503  
-
2504  
-    format.regex.indent = /^<(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \/>]/i ;
2505  
-    format.regex.unindent = /^<\/(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ >]/i ;
2506  
-    format.regex.inremove = new RegExp( indentchar );
2507  
-
2508  
-    //var formatted  = html.replace( format.regex.tagopen, '\n$&' );
2509  
-    //formatted      = formatted.replace( format.regex.tagclose, '$&\n' );
2510  
-    //formatted      = formatted.replace( format.regex.taglines, '$&\n' );
2511  
-    //formatted      = formatted.replace( format.regex.tagsmain, '\n$&\n' );
2512  
-
2513  
-    var indentation = '';
2514  
-    var tolines = html.split(format.regex.splitter);
2515  
-    var formatted = '';
2516  
-
2517  
-    for (var i = 0; i < tolines.length; i++) {
2518  
-        var line = tolines[i];
2519  
-        if (line.length < 1) {
2520  
-            continue;
2521  
-        }
2522  
-        if (format.regex.unindent.test(line) && !format.regex.notouchy.test(line)) {
2523  
-            indentation = indentation.replace(format.regex.inremove, '') ;
2524  
-        }
2525  
-
2526  
-        line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagopen, '\n$&') : line;
2527  
-        line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagclose, '$&\n'): line;
2528  
-        line = !format.regex.notouchy.test(line) ? line.replace(format.regex.tagsmain, '$&\n'): line;
2529  
-
2530  
-        formatted += indentation + line;
2531  
-
2532  
-        if (format.regex.indent.test(line)) {
2533  
-            indentation += indentchar;
2534  
-        }
2535  
-    }
2536  
-    return formatted;
2537  
-}

0 notes on commit bb9cd45

Please sign in to comment.
Something went wrong with that request. Please try again.