Merge lp:~edwin-grubbs/launchpad/bug-513260-registry-js-module-names into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Edwin Grubbs
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~edwin-grubbs/launchpad/bug-513260-registry-js-module-names
Merge into: lp:launchpad
Diff against target: 937 lines (+240/-224)
18 files modified
lib/canonical/launchpad/javascript/lp/dragscroll.js (+132/-122)
lib/canonical/launchpad/javascript/lp/mapping.js (+34/-34)
lib/canonical/launchpad/javascript/lp/picker.js (+4/-4)
lib/canonical/launchpad/javascript/registry/milestoneoverlay.js (+5/-5)
lib/canonical/launchpad/javascript/registry/milestonetable.js (+35/-27)
lib/canonical/launchpad/javascript/registry/tests/milestone_table.html (+5/-5)
lib/canonical/launchpad/javascript/registry/tests/test_milestone_table.js (+3/-3)
lib/canonical/launchpad/javascript/registry/tests/timeline-iframe.html (+4/-4)
lib/canonical/launchpad/javascript/registry/tests/timeline.html (+2/-1)
lib/canonical/launchpad/javascript/registry/tests/timeline.js (+1/-1)
lib/lp/app/templates/base-layout-macros.pt (+2/-0)
lib/lp/registry/browser/__init__.py (+4/-4)
lib/lp/registry/browser/tests/productrelease-views.txt (+1/-1)
lib/lp/registry/browser/tests/productseries-views.txt (+3/-3)
lib/lp/registry/templates/distroseries-index.pt (+0/-3)
lib/lp/registry/templates/object-timeline-graph.pt (+3/-2)
lib/lp/registry/templates/productrelease-add-from-series.pt (+2/-2)
lib/lp/registry/templates/productseries-index.pt (+0/-3)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-513260-registry-js-module-names
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+19142@code.launchpad.net

Commit message

Fixed conflicts between YUI module names, namespaces, and filenames.

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :
Download full text (4.8 KiB)

Summary
-------

Fixed conflicts between YUI module names, namespaces, and filenames.

Implementation details
----------------------

The DragScrollEventHandler was declared as a global instead of
in a YUI module, since it doesn't any YUI code. For consistency and
to avoid polluting the global namespace, I moved it into a YUI module.
This involved indenting all the code, so I have also provided a separate
diff at the bottom which shows the non-whitespace changes to the file.
    lib/canonical/launchpad/javascript/lp/dragscroll.js

The milestonetable.js file was being loaded by the productseries-index.pt
and distroseriesindex.pt files directly instead of the base layout. This
is bad since it prevents the js files from being combined.
    lib/lp/app/templates/base-layout-macros.pt
    lib/lp/registry/templates/distroseries-index.pt
    lib/lp/registry/templates/productseries-index.pt

Just renaming modules, namespaces, or files. The yui directory was
also moved from icing/yui/current/build to icing/yui a while ago, and
these tests had not been run since then, so I fixed that also.
    lib/canonical/launchpad/javascript/lp/mapping.js
    lib/canonical/launchpad/javascript/lp/picker.js
    lib/canonical/launchpad/javascript/registry/milestoneoverlay.js
    lib/canonical/launchpad/javascript/registry/milestonetable.js
    lib/canonical/launchpad/javascript/registry/tests/milestone_table.html
    lib/canonical/launchpad/javascript/registry/tests/test_milestone_table.js
    lib/canonical/launchpad/javascript/registry/tests/timeline-iframe.html
    lib/canonical/launchpad/javascript/registry/tests/timeline.html
    lib/canonical/launchpad/javascript/registry/tests/timeline.js
    lib/lp/registry/browser/__init__.py
    lib/lp/registry/browser/tests/productrelease-views.txt
    lib/lp/registry/browser/tests/productseries-views.txt
    lib/lp/registry/templates/object-timeline-graph.pt
    lib/lp/registry/templates/productrelease-add-from-series.pt

Tests
-----

./bin/test -vv --layer RegistryWindmillLayer
file:///./lib/canonical/launchpad/javascript/registry/tests/milestone_table.html
file:///./lib/canonical/launchpad/javascript/registry/tests/timeline.html

Demo and Q/A
------------

* Open https://launchpad.dev/firefox
    * Ensure that timeline graph still shows up and that it can be
      dragged if you zoom in until it doesn't fit.
* Open https://launchpad.dev/firefox/trunk
    * The "Create milestone" link should bring up a form overlay,
      and submitting the form should cause the milestone to appear
      in the table with a green flash.
* Open https://launchpad.dev/ubuntu/warty
    * Same test as for the firefox/trunk product series.
* Open https://launchpad.dev/people/+me/+editlocation
    * The map should appear and it should be possible to edit the
      location.
* Open https://bugs.launchpad.dev/bugs/3
    * The "Subscribe someone else" link should bring up a working picker.

Dragscroll diff without whitespace
----------------------------------

=== modified file 'lib/canonical/launchpad/javascript/lp/dragscroll.js'
--- lib/canonical/launchpad/javascript/lp/dragscroll.js 2009-10-08 17:13:13 +0000
+++ lib/canonical/launchpad/javascrip...

Read more...

Revision history for this message
Abel Deuring (adeuring) wrote :

Hi Edwin,

nice change. I think you should s/Copyright 2009/Copyright 2010/ in milestone_table.js and dragscroll.js.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/javascript/lp/dragscroll.js'
2--- lib/canonical/launchpad/javascript/lp/dragscroll.js 2009-10-08 17:13:13 +0000
3+++ lib/canonical/launchpad/javascript/lp/dragscroll.js 2010-02-12 16:34:16 +0000
4@@ -1,4 +1,10 @@
5-/*
6+/* Copyright 2010 Canonical Ltd. This software is licensed under the
7+ * GNU Affero General Public License version 3 (see the file LICENSE).
8+ *
9+ * A milestone form overlay that can create a milestone within any page.
10+ *
11+ * @module Y.lp.dragscroll
12+ *
13 * Based on dragscroll script by Nicolas Mendoza <nicolasm@opera.com>.
14 * http://people.opera.com/nicolasm/userjs/dragscroll
15 */
16@@ -9,126 +15,130 @@
17 * @class DragScrollEventHandler
18 * @constructor
19 */
20-DragScrollEventHandler = function() {
21- this.dragging = false;
22- this.last_position = null;
23- this.event_listeners = [];
24-}
25-
26-DragScrollEventHandler.prototype = {
27- /**
28- * Add the event handlers and change the cursor to indicate
29- * that drag scrolling is active.
30- *
31- * @method activate
32- */
33- activate: function() {
34- this._addEventListener("mousedown", this._startDragScroll);
35- this._addEventListener("mouseup", this._stopDragScroll);
36- this._addEventListener("mouseout", this._stopDragScroll);
37- this._addEventListener("mousemove", this._dragScroll);
38- this._setGrabCursor();
39- },
40-
41- /**
42- * Remove the event handlers and change the cursor to indicate
43- * that drag scrolling is inactive.
44- *
45- * @method deactivate
46- */
47- deactivate: function() {
48- document.removeEventListener(
49- "mousedown", this._startDragScroll, false);
50- this._removeEventListeners();
51- this._unsetCursor();
52- },
53-
54- _addEventListener: function(event_type, action) {
55- // Wrap the method in a different function that forces
56- // `this` to be the `DragScrollEventHandler` object.
57- var self = this;
58- var event_listener = function(e) {
59- action.call(self, e)
60- };
61- var event_args = [event_type, event_listener, false];
62- this.event_listeners.push(event_args);
63- document.addEventListener.apply(document, event_args);
64- },
65-
66- _removeEventListeners: function() {
67- for (var i=0; i<this.event_listeners.length; i++) {
68- var event_args = this.event_listeners[i];
69- document.removeEventListener.apply(document, event_args);
70- }
71- },
72-
73- _unsetCursor: function() {
74- document.body.style.cursor = '';
75- },
76-
77- _setGrabCursor: function() {
78- // Styles for W3C, IE, Mozilla, Webkit.
79- // Unknown styles will fail to change the value.
80- document.body.style.cursor = 'move';
81- document.body.style.cursor = 'grab';
82- document.body.style.cursor = '-moz-grab';
83- document.body.style.cursor = '-webkit-grab';
84- },
85-
86- _setGrabbingCursor: function() {
87- // Styles for IE, Mozilla, and Webkit.
88- // Unknown styles will fail to change the value.
89- document.body.style.cursor = 'grabbing';
90- document.body.style.cursor = '-moz-grabbing';
91- document.body.style.cursor = '-webkit-grabbing';
92- },
93-
94- /**
95- * MouseDown event handler that causes _dragScroll to
96- * take action when it receives a MouseMove event.
97- *
98- * @method _startDragScroll
99- */
100- _startDragScroll: function(e) {
101- if (e.button == 0) {
102- this.dragging = true;
103- this.last_position = e;
104- this._setGrabbingCursor();
105- }
106- e.preventDefault();
107- e.stopPropagation();
108- },
109-
110- /**
111- * MouseUp & MouseOut event handler that causes _dragScroll to
112- * once again ignore MouseMove events. Stopping dragging when
113- * the MouseOut event occurs is helpful, since the MouseUp event
114- * is not reliable, when the mouse is outside the window.
115- *
116- * @method _stopDragScroll
117- */
118- _stopDragScroll: function(e) {
119+YUI.add('lp.dragscroll', function(Y) {
120+ var module = Y.namespace('lp.dragscroll');
121+
122+ module.DragScrollEventHandler = function() {
123 this.dragging = false;
124- this._setGrabCursor();
125- e.preventDefault();
126- e.stopPropagation();
127- },
128-
129- /**
130- * MouseMove event handler that calculates the movement
131- * by comparing the mouse positions in the current event and
132- * the previous event.
133- *
134- * @method _dragScroll
135- */
136- _dragScroll: function(e) {
137- if (this.dragging) {
138- window.scrollBy(
139- this.last_position.clientX - e.clientX,
140- this.last_position.clientY - e.clientY);
141- this.last_position = e;
142- e.preventDefault();
143- e.stopPropagation();
144+ this.last_position = null;
145+ this.event_listeners = [];
146+ };
147+
148+ module.DragScrollEventHandler.prototype = {
149+ /**
150+ * Add the event handlers and change the cursor to indicate
151+ * that drag scrolling is active.
152+ *
153+ * @method activate
154+ */
155+ activate: function() {
156+ this._addEventListener("mousedown", this._startDragScroll);
157+ this._addEventListener("mouseup", this._stopDragScroll);
158+ this._addEventListener("mouseout", this._stopDragScroll);
159+ this._addEventListener("mousemove", this._dragScroll);
160+ this._setGrabCursor();
161+ },
162+
163+ /**
164+ * Remove the event handlers and change the cursor to indicate
165+ * that drag scrolling is inactive.
166+ *
167+ * @method deactivate
168+ */
169+ deactivate: function() {
170+ document.removeEventListener(
171+ "mousedown", this._startDragScroll, false);
172+ this._removeEventListeners();
173+ this._unsetCursor();
174+ },
175+
176+ _addEventListener: function(event_type, action) {
177+ // Wrap the method in a different function that forces
178+ // `this` to be the `DragScrollEventHandler` object.
179+ var self = this;
180+ var event_listener = function(e) {
181+ action.call(self, e);
182+ };
183+ var event_args = [event_type, event_listener, false];
184+ this.event_listeners.push(event_args);
185+ document.addEventListener.apply(document, event_args);
186+ },
187+
188+ _removeEventListeners: function() {
189+ for (var i=0; i<this.event_listeners.length; i++) {
190+ var event_args = this.event_listeners[i];
191+ document.removeEventListener.apply(document, event_args);
192+ }
193+ },
194+
195+ _unsetCursor: function() {
196+ document.body.style.cursor = '';
197+ },
198+
199+ _setGrabCursor: function() {
200+ // Styles for W3C, IE, Mozilla, Webkit.
201+ // Unknown styles will fail to change the value.
202+ document.body.style.cursor = 'move';
203+ document.body.style.cursor = 'grab';
204+ document.body.style.cursor = '-moz-grab';
205+ document.body.style.cursor = '-webkit-grab';
206+ },
207+
208+ _setGrabbingCursor: function() {
209+ // Styles for IE, Mozilla, and Webkit.
210+ // Unknown styles will fail to change the value.
211+ document.body.style.cursor = 'grabbing';
212+ document.body.style.cursor = '-moz-grabbing';
213+ document.body.style.cursor = '-webkit-grabbing';
214+ },
215+
216+ /**
217+ * MouseDown event handler that causes _dragScroll to
218+ * take action when it receives a MouseMove event.
219+ *
220+ * @method _startDragScroll
221+ */
222+ _startDragScroll: function(e) {
223+ if (e.button === 0) {
224+ this.dragging = true;
225+ this.last_position = e;
226+ this._setGrabbingCursor();
227+ }
228+ e.preventDefault();
229+ e.stopPropagation();
230+ },
231+
232+ /**
233+ * MouseUp & MouseOut event handler that causes _dragScroll to
234+ * once again ignore MouseMove events. Stopping dragging when
235+ * the MouseOut event occurs is helpful, since the MouseUp event
236+ * is not reliable, when the mouse is outside the window.
237+ *
238+ * @method _stopDragScroll
239+ */
240+ _stopDragScroll: function(e) {
241+ this.dragging = false;
242+ this._setGrabCursor();
243+ e.preventDefault();
244+ e.stopPropagation();
245+ },
246+
247+ /**
248+ * MouseMove event handler that calculates the movement
249+ * by comparing the mouse positions in the current event and
250+ * the previous event.
251+ *
252+ * @method _dragScroll
253+ */
254+ _dragScroll: function(e) {
255+ if (this.dragging) {
256+ window.scrollBy(
257+ this.last_position.clientX - e.clientX,
258+ this.last_position.clientY - e.clientY);
259+ this.last_position = e;
260+ e.preventDefault();
261+ e.stopPropagation();
262+ }
263 }
264- }
265-};
266+ };
267+}, "0.1", {"requires": []});
268
269=== modified file 'lib/canonical/launchpad/javascript/lp/mapping.js'
270--- lib/canonical/launchpad/javascript/lp/mapping.js 2009-11-24 09:30:01 +0000
271+++ lib/canonical/launchpad/javascript/lp/mapping.js 2010-02-12 16:34:16 +0000
272@@ -8,19 +8,19 @@
273 * @required Google GMap2
274 */
275 YUI.add('lp.mapping', function(Y) {
276- var mapping = Y.namespace('lp.mapping');
277+ var module = Y.namespace('lp.mapping');
278
279- mapping.RETURN_FALSE = function() {return false;};
280- mapping.RETURN_NULL = function() {return null;};
281+ module.RETURN_FALSE = function() {return false;};
282+ module.RETURN_NULL = function() {return null;};
283
284 // Replace the crucial GMap functions so that the supporting functions
285 // will work if the GMap script is not loaded.
286- var gBrowserIsCompatible = mapping.RETURN_FALSE;
287- var gDownloadUrl = mapping.RETURN_NULL;
288-
289- mapping.has_gmaps = (typeof(GBrowserIsCompatible) == 'function');
290-
291- if (mapping.has_gmaps) {
292+ var gBrowserIsCompatible = module.RETURN_FALSE;
293+ var gDownloadUrl = module.RETURN_NULL;
294+
295+ module.has_gmaps = (typeof(GBrowserIsCompatible) == 'function');
296+
297+ if (module.has_gmaps) {
298 // The GMap2 is is loaded; use the real functions.
299 // jslint does not like functions that look like classes.
300 gBrowserIsCompatible = GBrowserIsCompatible;
301@@ -37,7 +37,7 @@
302 * @param {GLatLngBounds} required_bounds the boundaries or null.
303 * @param {limit} optional max number of markers to set.
304 */
305- mapping.setMarkersInfoWindow = function(data, map, required_bounds,
306+ module.setMarkersInfoWindow = function(data, map, required_bounds,
307 limit) {
308 var xml = GXml.parse(data);
309 var markers = xml.documentElement.getElementsByTagName("participant");
310@@ -79,9 +79,9 @@
311 * @param {GMap2} map the Google map to add the markers to.
312 * @param {limit} optional max number of markers to set.
313 */
314- mapping.setMarkersInfoWindowForSmallMap = function(data, map, limit) {
315+ module.setMarkersInfoWindowForSmallMap = function(data, map, limit) {
316 var required_bounds = new GLatLngBounds();
317- mapping.setMarkersInfoWindow(data, map, required_bounds, limit);
318+ module.setMarkersInfoWindow(data, map, required_bounds, limit);
319 var zoom_level = map.getBoundsZoomLevel(required_bounds);
320 // Some browsers do not display the map when the zoom_level is at the
321 // end of the range, reduce the zoom_level by 1.
322@@ -100,7 +100,7 @@
323 * @param {String} lat_name the id of the latitude field.
324 * @param {String} lng_name the id of the longitude field.
325 */
326- mapping.setLocation = function(lat, lng, geoname,
327+ module.setLocation = function(lat, lng, geoname,
328 tz_name, lat_name, lng_name) {
329 Y.one(Y.DOM.byId(lat_name)).set('value', lat);
330 Y.one(Y.DOM.byId(lng_name)).set('value', lng);
331@@ -134,13 +134,13 @@
332 * @function toggleShowSmallMaps
333 * @param {Event} e the event for this callback.
334 */
335- mapping.toggleShowSmallMaps = function (checkbox) {
336+ module.toggleShowSmallMaps = function (checkbox) {
337 var is_shown = checkbox.get('checked');
338 Y.lp.launchpad_views.set('small_maps', is_shown);
339 var display = is_shown ? 'block' : 'none';
340 var maps = Y.all('.small-map');
341 maps.each(function(map) {map.setStyle('display', display);});
342- if (is_shown && !mapping.has_gmaps) {
343+ if (is_shown && !module.has_gmaps) {
344 // The server must add the Google GMap2 dependencies to the page.
345 window.location.reload();
346 }
347@@ -152,14 +152,14 @@
348 * @function setupShowSmallMapsControl
349 * @param {String} div_id the CSS3 id of the div that controls the map.
350 */
351- mapping.setupShowSmallMapsControl = function (div_id) {
352+ module.setupShowSmallMapsControl = function (div_id) {
353 var show_small_maps = Y.lp.launchpad_views.get('small_maps');
354 var checkbox = Y.Node.create(
355 '<input type="checkbox" name="show_small_maps" />');
356 checkbox.set(
357 'checked', show_small_maps);
358 checkbox.on(
359- 'click', function(e) {mapping.toggleShowSmallMaps(checkbox);});
360+ 'click', function(e) {module.toggleShowSmallMaps(checkbox);});
361 var label_text = Y.Node.create('Display map');
362 var label = Y.Node.create('<label></label>');
363 label.appendChild(checkbox);
364@@ -167,7 +167,7 @@
365 var action_div = Y.one(div_id);
366 action_div.appendChild(label);
367 if (!show_small_maps) {
368- mapping.toggleShowSmallMaps(checkbox);
369+ module.toggleShowSmallMaps(checkbox);
370 }
371 };
372
373@@ -180,7 +180,7 @@
374 * @param {Number} center_lng a GLatLng.lng bounded number.
375 * @return {GMap2} the Google map
376 */
377- mapping.getSmallMap = function(div_id, center_lat, center_lng) {
378+ module.getSmallMap = function(div_id, center_lat, center_lng) {
379 var mapdiv = Y.DOM.byId(div_id);
380 mapdiv.style.width = '400px';
381 var map = new GMap2(mapdiv);
382@@ -197,12 +197,12 @@
383 * @param {Number} center_lat a GLatLng.lat bounded number.
384 * @param {Number} center_lng a GLatLng.lng bounded number.
385 */
386- mapping.renderPersonMapSmall = function(center_lat, center_lng) {
387- mapping.setupShowSmallMapsControl('#person_map_actions');
388+ module.renderPersonMapSmall = function(center_lat, center_lng) {
389+ module.setupShowSmallMapsControl('#person_map_actions');
390 if (!gBrowserIsCompatible()) {
391 return;
392 }
393- var map = mapping.getSmallMap(
394+ var map = module.getSmallMap(
395 'person_map_div', center_lat, center_lng);
396 map.addControl(new GSmallZoomControl());
397 var center = new GLatLng(center_lat, center_lng);
398@@ -218,15 +218,15 @@
399 * @param {Number} center_lat a GLatLng.lat bounded number.
400 * @param {Number} center_lng a GLatLng.lng bounded number.
401 */
402- mapping.renderTeamMapSmall = function(center_lat, center_lng) {
403- mapping.setupShowSmallMapsControl('#team_map_actions');
404+ module.renderTeamMapSmall = function(center_lat, center_lng) {
405+ module.setupShowSmallMapsControl('#team_map_actions');
406 if (!gBrowserIsCompatible()) {
407 return;
408 }
409- var team_map = mapping.getSmallMap(
410+ var team_map = module.getSmallMap(
411 'team_map_div', center_lat, center_lng);
412 gDownloadUrl("+mapdataltd", function(data) {
413- mapping.setMarkersInfoWindowForSmallMap(data, team_map);
414+ module.setMarkersInfoWindowForSmallMap(data, team_map);
415 });
416 };
417
418@@ -237,7 +237,7 @@
419 * @param {String} div_id the id of the map div.
420 * @return {GMap2} The Google map
421 */
422- mapping.getLargeMap = function(div_id) {
423+ module.getLargeMap = function(div_id) {
424 var mapdiv = Y.DOM.byId(div_id);
425 var mapheight = (parseInt(mapdiv.offsetWidth, 10) / 16 * 9);
426 mapheight = Math.min(mapheight, Y.DOM.winHeight() - 180);
427@@ -276,12 +276,12 @@
428 * @param {Number} center_lat a GLatLng.lat bounded number.
429 * @param {Number} center_lng a GLatLng.lng bounded number.
430 */
431- mapping.renderTeamMap = function(min_lat, max_lat, min_lng, max_lng,
432+ module.renderTeamMap = function(min_lat, max_lat, min_lng, max_lng,
433 center_lat, center_lng) {
434 if (!gBrowserIsCompatible()) {
435 return;
436 }
437- var team_map = mapping.getLargeMap("team_map_div");
438+ var team_map = module.getLargeMap("team_map_div");
439 var center = new GLatLng(center_lat, center_lng);
440 team_map.setCenter(center, 0);
441 var sw = new GLatLng(min_lat, min_lng);
442@@ -294,7 +294,7 @@
443 G_HYBRID_MAP.getMaximumResolution(), zoom_level - 1);
444 team_map.setZoom(zoom_level);
445 gDownloadUrl("+mapdata", function(data) {
446- mapping.setMarkersInfoWindow(data, team_map);
447+ module.setMarkersInfoWindow(data, team_map);
448 });
449 };
450
451@@ -314,13 +314,13 @@
452 * @param {number} zoom the initial zoom-level.
453 * @param {Boolean} show_marker Show the marker for the person.
454 */
455- mapping.renderPersonMap = function(center_lat, center_lng, displayname,
456+ module.renderPersonMap = function(center_lat, center_lng, displayname,
457 name, logo_html, geoname, lat_name,
458 lng_name, tz_name, zoom, show_marker) {
459 if (!gBrowserIsCompatible()) {
460 return;
461 }
462- var map = mapping.getLargeMap('map_div');
463+ var map = module.getLargeMap('map_div');
464 var center = new GLatLng(center_lat, center_lng);
465 map.setCenter(center, zoom);
466 var marker = new GMarker(center, {draggable: true});
467@@ -333,7 +333,7 @@
468
469 GEvent.addListener(marker, "dragend", function() {
470 var point = marker.getLatLng();
471- mapping.setLocation(
472+ module.setLocation(
473 point.lat(), point.lng(), geoname,
474 tz_name, lat_name, lng_name);
475 });
476@@ -357,7 +357,7 @@
477 marker.show();
478 map.panTo(point);
479 }
480- mapping.setLocation(
481+ module.setLocation(
482 point.lat(), point.lng(), geoname,
483 tz_name, lat_name, lng_name);
484 });
485
486=== modified file 'lib/canonical/launchpad/javascript/lp/picker.js'
487--- lib/canonical/launchpad/javascript/lp/picker.js 2010-01-29 10:52:58 +0000
488+++ lib/canonical/launchpad/javascript/lp/picker.js 2010-02-12 16:34:16 +0000
489@@ -2,7 +2,7 @@
490
491 Y.log('loading lp.picker');
492
493-Y.namespace('lp.picker');
494+var module = Y.namespace('lp.picker');
495
496 var BATCH_SIZE = 6;
497 var MAX_BATCHES = 20;
498@@ -24,7 +24,7 @@
499 * config.step_title overrides the subtitle.
500 * description strings.
501 */
502-Y.lp.picker.addPickerPatcher = function (
503+module.addPickerPatcher = function (
504 vocabulary, resource_uri, attribute_name,
505 content_box_id, show_remove_button, show_assign_me_button, config) {
506
507@@ -151,7 +151,7 @@
508 };
509
510 config.save = save;
511- var picker = Y.lp.picker.create(vocabulary, config);
512+ var picker = module.create(vocabulary, config);
513 picker._resource_uri = resource_uri;
514 var extra_buttons = Y.Node.create(
515 '<div style="text-align: center; height: 3em; ' +
516@@ -200,7 +200,7 @@
517 * config.save is a Function (optional) which takes
518 * a single string argument.
519 */
520-Y.lp.picker.create = function (vocabulary, config) {
521+module.create = function (vocabulary, config) {
522 if (Y.UA.ie) {
523 return;
524 }
525
526=== modified file 'lib/canonical/launchpad/javascript/registry/milestoneoverlay.js'
527--- lib/canonical/launchpad/javascript/registry/milestoneoverlay.js 2009-11-24 09:30:01 +0000
528+++ lib/canonical/launchpad/javascript/registry/milestoneoverlay.js 2010-02-12 16:34:16 +0000
529@@ -3,12 +3,12 @@
530 *
531 * A milestone form overlay that can create a milestone within any page.
532 *
533- * @module Y.lp.milestoneoverlay
534+ * @module Y.registry.milestoneoverlay
535 * @requires dom, node, io-base, lazr.anim, lazr.formoverlay
536 */
537-YUI.add('lp.milestoneoverlay', function(Y) {
538- Y.log('loading lp.milestoneoverlay');
539- var milestoneoverlay = Y.namespace('lp.milestoneoverlay');
540+YUI.add('registry.milestoneoverlay', function(Y) {
541+ Y.log('loading registry.milestoneoverlay');
542+ var module = Y.namespace('registry.milestoneoverlay');
543
544 var milestone_form;
545 var milestone_form_uri;
546@@ -96,7 +96,7 @@
547 * next_step is the function to be called after
548 * the milestone is created.
549 */
550- milestoneoverlay.attach_widget = function(config) {
551+ module.attach_widget = function(config) {
552 if (Y.UA.ie) {
553 return;
554 }
555
556=== renamed file 'lib/canonical/launchpad/javascript/registry/milestone_table.js' => 'lib/canonical/launchpad/javascript/registry/milestonetable.js'
557--- lib/canonical/launchpad/javascript/registry/milestone_table.js 2009-11-25 18:16:41 +0000
558+++ lib/canonical/launchpad/javascript/registry/milestonetable.js 2010-02-12 16:34:16 +0000
559@@ -1,13 +1,21 @@
560-YUI.add('lp.milestonetable', function(Y) {
561- Y.log('loading lp.milestonetable');
562- var self = Y.namespace('lp.milestonetable');
563+/* Copyright 2010 Canonical Ltd. This software is licensed under the
564+ * GNU Affero General Public License version 3 (see the file LICENSE).
565+ *
566+ * Dynamically add milestones to an HTML table.
567+ *
568+ * @module Y.registry.milestonetable
569+ * @requires node, io-base, substitute, lazr.anim
570+ */
571+YUI.add('registry.milestonetable', function(Y) {
572+ Y.log('loading registry.milestonetable');
573+ var module = Y.namespace('registry.milestonetable');
574
575 // get_milestone_row() needs these when it is called. Other methods
576 // should get this information passed as an argument.
577- self._milestone_row_uri_template = null;
578- self._tbody = null;
579+ module._milestone_row_uri_template = null;
580+ module._tbody = null;
581
582- self._prepend_node = function(parent_node, child_node) {
583+ module._prepend_node = function(parent_node, child_node) {
584 // Add the child_node to the parent_node as the first item.
585 var children = parent_node.get('children');
586 if (children === null) {
587@@ -17,13 +25,13 @@
588 }
589 };
590
591- self._ensure_table_is_seen = function(tbody) {
592+ module._ensure_table_is_seen = function(tbody) {
593 // Remove the 'unseen' class from the table to ensure it is visible.
594 table = tbody.ancestor();
595 table.removeClass('unseen');
596 };
597
598- self._clear_add_handlers = function(data) {
599+ module._clear_add_handlers = function(data) {
600 // Detach the callback and errorback functions from the Y.io events.
601 // The data has been used. If they are not detached, there will be
602 // multiple adds for each use of the Create milestone link.
603@@ -31,36 +39,36 @@
604 data.failure_handle.detach();
605 };
606
607- self._on_add_success = function(id, response, data) {
608+ module._on_add_success = function(id, response, data) {
609 // Add the milestone to the milestone table on Y.io success.
610 var row = Y.Node.create(Y.Lang.trim(response.responseText));
611- self._ensure_table_is_seen(data.tbody);
612- self._prepend_node(data.tbody, row);
613+ module._ensure_table_is_seen(data.tbody);
614+ module._prepend_node(data.tbody, row);
615 Y.lazr.anim.green_flash({node: row}).run();
616- self._clear_add_handlers(data);
617+ module._clear_add_handlers(data);
618 };
619
620- self._on_add_failure = function(id, response, data) {
621+ module._on_add_failure = function(id, response, data) {
622 // Add the failure message to the milestone table on Y.io failure.
623 var row = Y.Node.create(Y.substitute(
624 '<tr><td colspan="0">' +
625 'Could not retrieve milestone {name}</td></tr>', data));
626- self._ensure_table_is_seen(data.tbody);
627- self._prepend_node(data.tbody, row);
628+ module._ensure_table_is_seen(data.tbody);
629+ module._prepend_node(data.tbody, row);
630 Y.lazr.anim.red_flash({node: row}).run();
631- self._clear_add_handlers(data);
632+ module._clear_add_handlers(data);
633 };
634
635- self._setup_milestone_event_data = function(parameters, tbody) {
636+ module._setup_milestone_event_data = function(parameters, tbody) {
637 // Attach the callback to the Y.io event and return their data
638 var data = {
639 name: parameters.name,
640 tbody: tbody
641 };
642 data.success_handle = Y.on(
643- 'io:success', self._on_add_success, this, data);
644+ 'io:success', module._on_add_success, this, data);
645 data.failure_handle = Y.on(
646- 'io:failure', self._on_add_failure, this, data);
647+ 'io:failure', module._on_add_failure, this, data);
648 return data;
649 };
650
651@@ -73,24 +81,24 @@
652 * @param {Object} parameters Object literal of config name/value pairs.
653 * The form parameters that were submitted to create the milestone.
654 */
655- self.get_milestone_row = function(parameters) {
656- self._setup_milestone_event_data(parameters, self._tbody);
657+ module.get_milestone_row = function(parameters) {
658+ module._setup_milestone_event_data(parameters, module._tbody);
659 var milestone_row_uri = Y.substitute(
660- self._milestone_row_uri_template, parameters);
661+ module._milestone_row_uri_template, parameters);
662 Y.io(milestone_row_uri);
663 };
664
665 /**
666 * Setup the URL to get the milestone and the table it will be added too.
667 *
668- * @method get_milestone_row
669+ * @method setup
670 * @param {Object} parameters Object literal of config name/value pairs.
671 * config.milestone_row_uri_template is the Y.substitute template
672 * that is used to create the URL to get the milestone row.
673 * config.milestone_rows_id is the id the the tbody that the
674 * milestone row will be added too.
675 */
676- self.setup = function(config) {
677+ module.setup = function(config) {
678 if (config === undefined) {
679 throw new Error(
680 "Missing setup config for milestonetable.");
681@@ -100,9 +108,9 @@
682 throw new Error(
683 "Undefined properties in setup config for milestonetable.");
684 }
685- self._milestone_row_uri_template = config.milestone_row_uri_template;
686- self._tbody = Y.one(config.milestone_rows_id);
687- if (self._tbody === null) {
688+ module._milestone_row_uri_template = config.milestone_row_uri_template;
689+ module._tbody = Y.one(config.milestone_rows_id);
690+ if (module._tbody === null) {
691 throw new Error(
692 Y.substitute("'{milestone_rows_id}' not in page.", config));
693 }
694
695=== modified file 'lib/canonical/launchpad/javascript/registry/tests/milestone_table.html'
696--- lib/canonical/launchpad/javascript/registry/tests/milestone_table.html 2009-09-14 15:03:45 +0000
697+++ lib/canonical/launchpad/javascript/registry/tests/milestone_table.html 2010-02-12 16:34:16 +0000
698@@ -4,15 +4,15 @@
699 <title>Launchpad milestonetable</title>
700
701 <!-- YUI 3.0 Setup -->
702- <script type="text/javascript" src="../../../icing/yui/current/build/yui/yui.js"></script>
703+ <script type="text/javascript" src="../../../icing/yui/yui/yui.js"></script>
704 <script type="text/javascript" src="../../../icing/lazr/build/lazr.js"></script>
705- <link rel="stylesheet" href="../../../icing/yui/current/build/cssreset/reset.css"/>
706- <link rel="stylesheet" href="../../../icing/yui/current/build/cssfonts/fonts.css"/>
707- <link rel="stylesheet" href="../../../icing/yui/current/build/cssbase/base.css"/>
708+ <link rel="stylesheet" href="../../../icing/yui/cssreset/reset.css"/>
709+ <link rel="stylesheet" href="../../../icing/yui/cssfonts/fonts.css"/>
710+ <link rel="stylesheet" href="../../../icing/yui/cssbase/base.css"/>
711 <link rel="stylesheet" href="../../test.css" />
712
713 <!-- The module under test -->
714- <script type="text/javascript" src="../milestone_table.js"></script>
715+ <script type="text/javascript" src="../milestonetable.js"></script>
716
717 <!-- The test suite -->
718 <script type="text/javascript" src="test_milestone_table.js"></script>
719
720=== modified file 'lib/canonical/launchpad/javascript/registry/tests/test_milestone_table.js'
721--- lib/canonical/launchpad/javascript/registry/tests/test_milestone_table.js 2009-11-25 19:21:59 +0000
722+++ lib/canonical/launchpad/javascript/registry/tests/test_milestone_table.js 2010-02-12 16:34:16 +0000
723@@ -1,11 +1,11 @@
724 /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
725
726 YUI({
727- base: '../../../icing/yui/current/build/',
728+ base: '../../../icing/yui/',
729 filter: 'raw', combine: false
730- }).use('test', 'console', 'lp.milestonetable', function(Y) {
731+ }).use('test', 'console', 'registry.milestonetable', function(Y) {
732
733- var milestonetable = Y.lp.milestonetable;
734+ var milestonetable = Y.registry.milestonetable;
735 var suite = new Y.Test.Suite("milestonetable Tests");
736
737 suite.add(new Y.Test.Case({
738
739=== modified file 'lib/canonical/launchpad/javascript/registry/tests/timeline-iframe.html'
740--- lib/canonical/launchpad/javascript/registry/tests/timeline-iframe.html 2009-10-08 22:52:35 +0000
741+++ lib/canonical/launchpad/javascript/registry/tests/timeline-iframe.html 2010-02-12 16:34:16 +0000
742@@ -4,10 +4,10 @@
743 <title>Launchpad TimelineGraph Widget</title>
744
745 <!-- YUI 3.0 Setup -->
746- <script type="text/javascript" src="../../../icing/yui/current/build/yui/yui.js"></script>
747- <link rel="stylesheet" href="../../../icing/yui/current/build/cssreset/reset.css"/>
748- <link rel="stylesheet" href="../../../icing/yui/current/build/cssfonts/fonts.css"/>
749- <link rel="stylesheet" href="../../../icing/yui/current/build/cssbase/base.css"/>
750+ <script type="text/javascript" src="../../../icing/yui/yui/yui.js"></script>
751+ <link rel="stylesheet" href="../../../icing/yui/cssreset/reset.css"/>
752+ <link rel="stylesheet" href="../../../icing/yui/cssfonts/fonts.css"/>
753+ <link rel="stylesheet" href="../../../icing/yui/cssbase/base.css"/>
754
755 <!-- The module under test -->
756 <script type="text/javascript" src="../timeline.js"></script>
757
758=== modified file 'lib/canonical/launchpad/javascript/registry/tests/timeline.html'
759--- lib/canonical/launchpad/javascript/registry/tests/timeline.html 2009-07-01 02:25:33 +0000
760+++ lib/canonical/launchpad/javascript/registry/tests/timeline.html 2010-02-12 16:34:16 +0000
761@@ -7,6 +7,7 @@
762 name="timeline-iframe"
763 src="timeline-iframe.html"
764 height="100%"
765- width="100%" />
766+ width="100%">
767+</iframe>
768 </body>
769 </html>
770
771=== modified file 'lib/canonical/launchpad/javascript/registry/tests/timeline.js'
772--- lib/canonical/launchpad/javascript/registry/tests/timeline.js 2009-11-25 19:21:59 +0000
773+++ lib/canonical/launchpad/javascript/registry/tests/timeline.js 2010-02-12 16:34:16 +0000
774@@ -1,7 +1,7 @@
775 /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
776
777 YUI({
778- base: '../../../icing/yui/current/build/',
779+ base: '../../../icing/yui/',
780 filter: 'raw',
781 combine: false
782 }).use('test', 'console', 'registry.timeline', function(Y) {
783
784=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
785--- lib/lp/app/templates/base-layout-macros.pt 2010-02-08 18:21:24 +0000
786+++ lib/lp/app/templates/base-layout-macros.pt 2010-02-12 16:34:16 +0000
787@@ -176,6 +176,8 @@
788 <script type="text/javascript"
789 tal:attributes="src string:${lp_js}/registry/milestoneoverlay.js"></script>
790 <script type="text/javascript"
791+ tal:attributes="src string:${lp_js}/registry/milestonetable.js"></script>
792+ <script type="text/javascript"
793 tal:attributes="src string:${lp_js}/registry/timeline.js"></script>
794 <script type="text/javascript"
795 tal:attributes="src string:${lp_js}/sorttable/sorttable.js"></script>
796
797=== modified file 'lib/lp/registry/browser/__init__.py'
798--- lib/lp/registry/browser/__init__.py 2009-10-05 16:41:55 +0000
799+++ lib/lp/registry/browser/__init__.py 2010-02-12 16:34:16 +0000
800@@ -101,7 +101,7 @@
801 }
802 return """
803 YUI().use(
804- 'node', 'lp.milestoneoverlay', 'lp.milestonetable',
805+ 'node', 'registry.milestoneoverlay', 'registry.milestonetable',
806 function (Y) {
807
808 var series_uri = '%(series_api_uri)s';
809@@ -116,15 +116,15 @@
810 var config = {
811 milestone_form_uri: milestone_form_uri,
812 series_uri: series_uri,
813- next_step: Y.lp.milestonetable.get_milestone_row,
814+ next_step: Y.registry.milestonetable.get_milestone_row,
815 activate_node: create_milestone_link
816 };
817- Y.lp.milestoneoverlay.attach_widget(config);
818+ Y.registry.milestoneoverlay.attach_widget(config);
819 var table_config = {
820 milestone_row_uri_template: milestone_row_uri,
821 milestone_rows_id: milestone_rows_id
822 }
823- Y.lp.milestonetable.setup(table_config);
824+ Y.registry.milestonetable.setup(table_config);
825 });
826 });
827 """ % uris
828
829=== modified file 'lib/lp/registry/browser/tests/productrelease-views.txt'
830--- lib/lp/registry/browser/tests/productrelease-views.txt 2010-01-22 03:01:19 +0000
831+++ lib/lp/registry/browser/tests/productrelease-views.txt 2010-02-12 16:34:16 +0000
832@@ -124,7 +124,7 @@
833 >>> script = find_tag_by_id(view.render(), 'milestone-script')
834 >>> print script
835 <script id="milestone-script" type="text/javascript">
836- LPS.use(... 'lp.milestoneoverlay'...
837+ LPS.use(... 'registry.milestoneoverlay'...
838 var milestone_form_uri = '.../app/simple/+addmilestone/++form++';
839 var series_uri = '/app/simple';
840 ...
841
842=== modified file 'lib/lp/registry/browser/tests/productseries-views.txt'
843--- lib/lp/registry/browser/tests/productseries-views.txt 2010-01-20 15:41:25 +0000
844+++ lib/lp/registry/browser/tests/productseries-views.txt 2010-02-12 16:34:16 +0000
845@@ -33,7 +33,7 @@
846 >>> script = find_tag_by_id(view.render(), 'milestone-script')
847 >>> print script
848 <script id="milestone-script" type="text/javascript">
849- YUI().use(... 'lp.milestoneoverlay', 'lp.milestonetable'...
850+ YUI().use(... 'registry.milestoneoverlay', 'registry.milestonetable'...
851 var series_uri = '/app/simple';
852 var milestone_form_uri = '.../app/simple/+addmilestone/++form++';
853 var milestone_row_uri =
854@@ -43,8 +43,8 @@
855 var create_milestone_link = Y.get(
856 '.menu-link-create_milestone');
857 create_milestone_link.addClass('js-action');...
858- Y.lp.milestoneoverlay.attach_widget(config);...
859- Y.lp.milestonetable.setup(table_config);...
860+ Y.registry.milestoneoverlay.attach_widget(config);...
861+ Y.registry.milestonetable.setup(table_config);...
862
863 If the Create milestone link is not enabled, the script is not present.
864
865
866=== modified file 'lib/lp/registry/templates/distroseries-index.pt'
867--- lib/lp/registry/templates/distroseries-index.pt 2009-12-04 00:15:41 +0000
868+++ lib/lp/registry/templates/distroseries-index.pt 2010-02-12 16:34:16 +0000
869@@ -9,9 +9,6 @@
870 <metal:block fill-slot="head_epilogue">
871 <metal:yui-dependencies
872 use-macro="context/@@launchpad_widget_macros/yui2calendar-dependencies" />
873- <script type="text/javascript"
874- tal:define="lp_js string:${icingroot}/build"
875- tal:attributes="src string:${lp_js}/registry/milestone_table.js"></script>
876 <script id="milestone-script" type="text/javascript"
877 tal:condition="context/menu:overview/create_milestone/enabled"
878 tal:content="view/register_milestone_script"></script>
879
880=== modified file 'lib/lp/registry/templates/object-timeline-graph.pt'
881--- lib/lp/registry/templates/object-timeline-graph.pt 2009-12-19 18:50:39 +0000
882+++ lib/lp/registry/templates/object-timeline-graph.pt 2010-02-12 16:34:16 +0000
883@@ -34,7 +34,7 @@
884 include_inactive = false;
885 }
886
887- LPS.use('registry.timeline', 'node', function(Y) {
888+ LPS.use('registry.timeline', 'node', 'lp.dragscroll', function(Y) {
889 Y.on('domready', function(e) {
890 if (Y.UA.ie) {
891 return;
892@@ -88,7 +88,8 @@
893 }
894 });
895
896- var drag_scroll_handler = new DragScrollEventHandler();
897+ var drag_scroll_handler =
898+ new Y.lp.dragscroll.DragScrollEventHandler();
899 drag_scroll_handler.activate();
900 });
901 });
902
903=== modified file 'lib/lp/registry/templates/productrelease-add-from-series.pt'
904--- lib/lp/registry/templates/productrelease-add-from-series.pt 2009-12-03 18:33:22 +0000
905+++ lib/lp/registry/templates/productrelease-add-from-series.pt 2010-02-12 16:34:16 +0000
906@@ -14,7 +14,7 @@
907 <tal:script
908 replace="structure
909 string:&lt;script id='milestone-script' type='text/javascript'&gt;" />
910- LPS.use('node', 'lp.milestoneoverlay', function (Y) {
911+ LPS.use('node', 'registry.milestoneoverlay', function (Y) {
912
913 // This is a value for the SELECT OPTION which is passed with
914 // the SELECT's "change" event. It includes some symbols that are not
915@@ -57,7 +57,7 @@
916 activate_node: create_milestone_link
917 };
918 if (!Y.UA.ie) {
919- Y.lp.milestoneoverlay.attach_widget(config);
920+ Y.registry.milestoneoverlay.attach_widget(config);
921 }
922 });
923 });
924
925=== modified file 'lib/lp/registry/templates/productseries-index.pt'
926--- lib/lp/registry/templates/productseries-index.pt 2009-11-25 18:04:43 +0000
927+++ lib/lp/registry/templates/productseries-index.pt 2010-02-12 16:34:16 +0000
928@@ -11,9 +11,6 @@
929 <metal:block fill-slot="head_epilogue">
930 <metal:yui-dependencies
931 use-macro="context/@@launchpad_widget_macros/yui2calendar-dependencies" />
932- <script type="text/javascript"
933- tal:define="lp_js string:${icingroot}/build"
934- tal:attributes="src string:${lp_js}/registry/milestone_table.js"></script>
935 <script id="milestone-script" type="text/javascript"
936 tal:condition="context/menu:overview/create_milestone/enabled"
937 tal:content="view/register_milestone_script"></script>