← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~danilo/launchpad/remove-mochi-stuff into lp:launchpad

 

Данило Шеган has proposed merging lp:~danilo/launchpad/remove-mochi-stuff into lp:launchpad with lp:~danilo/launchpad/replace-expanders-2 as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~danilo/launchpad/remove-mochi-stuff/+merge/67326

= Summary =

Remove unused code.  activateCollapsibles was replaced long time ago with YUI-based implementation activate_collapsibles.  Remove any trace of it from the source code.

One step closer to getting rid of the mochikit stuff.

There's a million CSS lint warnings (I've snipped them out to reduce the MP size), and a few JS ones, but I am not touching them because this JS needs to die.

== Tests ==

Test suite.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/canonical/launchpad/icing/style-3-0.css
  lib/lp/app/javascript/lp-mochi.js
  lib/lp/app/templates/base-layout.pt

./lib/canonical/launchpad/icing/style-3-0.css
      58: Unknown Property name.: -moz-border-radius
      59: Unknown Property name.: -webkit-border-radius
      60: Unknown Property name.: -khtml-border-radius
[snip]
      38: I003: To few newlines before selectors.
      41: I003: To few newlines before selectors.
      46: I003: To few newlines before selectors.
[snip]
./lib/lp/app/javascript/lp-mochi.js
      21: Expected '!==' and instead saw '!='.
      22: Unexpected 'continue'.
      24: Expected '===' and instead saw '=='.
      25: Unexpected 'continue'.
      27: Expected '===' and instead saw '=='.
      42: Move 'var' declarations to the top of the function.
      42: Stopping.  (18% scanned).
      -1: JSLINT had a fatal error.
make: *** [lint] Error 243
-- 
https://code.launchpad.net/~danilo/launchpad/remove-mochi-stuff/+merge/67326
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~danilo/launchpad/remove-mochi-stuff into lp:launchpad.
=== modified file 'lib/canonical/launchpad/icing/style-3-0.css'
--- lib/canonical/launchpad/icing/style-3-0.css	2011-07-02 14:32:38 +0000
+++ lib/canonical/launchpad/icing/style-3-0.css	2011-07-08 12:55:42 +0000
@@ -921,7 +921,7 @@
 fieldset.collapsible {
     /* Collapsible sections
        Some page sections are hidden by default, expanded by clicking a link.
-       see launchpad.js:activateCollapsibles() */
+       see lp.js:activate_collapsibles() */
     border: none;
     margin: 0;
     padding: 16px 0 0; /* "Add a comment/attachment" form in bug reports */

=== modified file 'lib/lp/app/javascript/lp-mochi.js'
--- lib/lp/app/javascript/lp-mochi.js	2010-11-10 15:33:47 +0000
+++ lib/lp/app/javascript/lp-mochi.js	2011-07-08 12:55:42 +0000
@@ -13,157 +13,6 @@
     return node;
 }
 
-function toggleCollapsible(e) {
-    // this is the function that collapses/expands fieldsets.
-
-    // "this" is the node that the event is attached to
-    var node = this;
-
-    // walk up the node hierarchy until we find the <legend> element
-    while (node.nodeName.toLowerCase() != 'legend') {
-        node = node.parentNode;
-        if (!node) {
-            return false;
-        }
-    }
-
-    // the expander image is legend -> a -> img
-    var icon = node.firstChild.firstChild;
-    var legend = node;
-
-    if (icon.getAttribute('src').indexOf('/@@/treeCollapsed') != -1) {
-        // that was an ugly check, but IE rewrites image sources to
-        // absolute urls from some sick reason....
-        icon.setAttribute('src','/@@/treeExpanded');
-        swapElementClass(
-            legend.parentNode.lastChild, 'collapsed', 'expanded');
-        swapElementClass(
-            legend.parentNode.childNodes[1], 'expanded', 'collapsed');
-    } else {
-        icon.setAttribute('src','/@@/treeCollapsed');
-        swapElementClass(
-            legend.parentNode.lastChild, 'expanded', 'collapsed');
-        swapElementClass(
-            legend.parentNode.childNodes[1], 'collapsed', 'expanded');
-    }
-    return false;
-}
-
-function activateCollapsibles() {
-    // a script that searches for sections that can be (or are
-    // already) collapsed - and enables the collapse-behavior
-
-    // usage : give the class "collapsible" to a fieldset also, give
-    // it a <legend> with some descriptive text.  you can also add the
-    // class "collapsed" amounting to a total of
-    // <fieldset class="collapsible collapsed"> to make the section
-    // pre-collapsed
-
-    // terminate if we hit a non-compliant DOM implementation
-    if (!document.getElementsByTagName) {
-        return false;
-    }
-    if (!document.getElementById) {
-        return false;
-    }
-
-    // only search in the content-area
-    var contentarea = getContentArea();
-    if (!contentarea) {
-        return false;
-    }
-
-    // gather all objects that are to be collapsed
-    // we only do fieldsets for now. perhaps DIVs later...
-    var collapsibles = contentarea.getElementsByTagName('fieldset');
-
-    for (var i = 0; i < collapsibles.length; i++) {
-        if (collapsibles[i].className.indexOf('collapsible') == -1) {
-            continue;
-        }
-
-        var legends = collapsibles[i].getElementsByTagName('LEGEND');
-
-        // get the legend
-        // if there is no legend, we do not touch the fieldset at all.
-        // we assume that if there is a legend, there is only
-        // one. nothing else makes any sense
-        if (!legends.length) {
-            continue;
-        }
-        var legend = legends[0];
-
-        //create an anchor to handle click-events
-        var anchor = document.createElement('a');
-        anchor.href = '#';
-        anchor.onclick = toggleCollapsible;
-
-        // add the icon/button with its functionality to the legend
-        var icon = document.createElement('img');
-        icon.setAttribute('src','/@@/treeExpanded');
-        icon.setAttribute('class','collapseIcon');
-        icon.setAttribute('height','14');
-        icon.setAttribute('width','14');
-
-        // insert the icon icon at the start of the anchor
-        anchor.appendChild(icon);
-
-        // reparent all the legend's children into a span, and the span
-        // into an anchor. The span is used to underline the legend
-        // text; because the img is inside the anchor, we can't
-        // underline the whole anchor.
-        var span = document.createElement('span');
-        while (legend.hasChildNodes()) {
-            var child = legend.firstChild;
-            legend.removeChild(child);
-            span.appendChild(child);
-        }
-        anchor.appendChild(span);
-
-        // add the anchor to the legend
-        legend.appendChild(anchor);
-
-        // wrap the contents inside a div to make turning them on and
-        // off simpler.  unless something very strange happens, this
-        // new div should always be the last childnode we'll give it a
-        // class to make sure.
-
-        var hiderWrapper = document.createElement('div');
-        hiderWrapper.setAttribute('class','collapseWrapper');
-
-        // also add a new div describing that the element is collapsed.
-        var collapsedDescription = document.createElement('div');
-        collapsedDescription.setAttribute('class','collapsedText');
-        collapsedDescription.style.display = 'none';
-
-        // if the fieldset has the class of "collapsed", pre-collapse
-        // it. This can be used to preserve valuable UI-space
-        if (collapsibles[i].className.indexOf('collapsed') != -1 ) {
-            icon.setAttribute('src','/@@/treeCollapsed');
-            collapsedDescription.style.display = 'block';
-            setElementClass(hiderWrapper, 'collapsed');
-            // Unhide the fieldset, now that all of its children are hidden:
-            removeElementClass(collapsibles[i], 'collapsed');
-        }
-
-        // now we have the wrapper div.. Stuff all the contents inside it
-        var nl = collapsibles[i].childNodes.length;
-        for (var j = 0; j < nl; j++){
-            var node = collapsibles[i].childNodes[0];
-            if (node.nodeName == 'LEGEND') {
-                if (collapsibles[i].childNodes.length > 1) {
-                    hiderWrapper.appendChild(collapsibles[i].childNodes[1]);
-                }
-            } else {
-                hiderWrapper.appendChild(collapsibles[i].childNodes[0]);
-            }
-        }
-        // and add it to the document
-        collapsibles[i].appendChild(hiderWrapper);
-        collapsibles[i].insertBefore(collapsedDescription, hiderWrapper);
-    }
-}
-
 function toggleFoldable(e) {
     var ELEMENT_NODE = 1;
     var node = this;

=== modified file 'lib/lp/app/templates/base-layout.pt'
--- lib/lp/app/templates/base-layout.pt	2011-04-05 11:47:15 +0000
+++ lib/lp/app/templates/base-layout.pt	2011-07-08 12:55:42 +0000
@@ -43,21 +43,6 @@
       html, body {background-image: url(/@@/demo) !important;}
     </style>
 
-    <tal:comment condition="nothing">
-      This CSS collapses the contents of collapsible fieldsets,
-      without the flashing that would result from doing it in JavaScript.
-      activateCollapsibles() removes the class="collapsed" from fieldsets, to
-      re-show their divs, once the children themselves have been collapsed.
-    </tal:comment>
-    <style type="text/css">
-      fieldset.collapsed div, fieldset div.collapsed {display: none;}
-    </style>
-    <noscript>
-      <style type="text/css">
-        fieldset.collapsible div, fieldset div.collapsed {display: block;}
-      </style>
-    </noscript>
-
     <metal:page-javascript
         use-macro="context/@@+base-layout-macros/page-javascript" />
     <metal:block define-slot="head_epilogue"></metal:block>


Follow ups