8687.15.23
by Karl Fogel
Add the copyright header block to more files. |
1 |
/* Copyright 2009 Canonical Ltd. This software is licensed under the
|
2 |
* GNU Affero General Public License version 3 (see the file LICENSE).
|
|
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
3 |
*
|
4 |
* A milestone form overlay that can create a milestone within any page.
|
|
5 |
*
|
|
10785.1.2
by Brad Crittenden
Move registry JS to lp.registry namespace |
6 |
* @module Y.lp.registry.milestoneoverlay
|
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
7 |
* @requires dom, node, io-base, lazr.anim, lazr.formoverlay
|
8 |
*/
|
|
10785.1.2
by Brad Crittenden
Move registry JS to lp.registry namespace |
9 |
YUI.add('lp.registry.milestoneoverlay', function(Y) { |
10 |
Y.log('loading lp.registry.milestoneoverlay'); |
|
11 |
var module = Y.namespace('lp.registry.milestoneoverlay'); |
|
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
12 |
|
13 |
var milestone_form; |
|
14 |
var milestone_form_uri; |
|
15 |
var series_uri; |
|
16 |
var next_step; |
|
17 |
||
18 |
var save_new_milestone = function(data) { |
|
19 |
||
20 |
var parameters = { |
|
21 |
name: data['field.name'][0].toLowerCase(), |
|
22 |
code_name: data['field.code_name'][0], |
|
23 |
summary: data['field.summary'][0] |
|
24 |
};
|
|
25 |
||
26 |
var date_targeted = Y.Lang.trim(data['field.dateexpected'][0]); |
|
8602.1.3
by Curtis Hovey
Fixed lint issues in javascript. |
27 |
if (date_targeted !== '') { |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
28 |
parameters.date_targeted = date_targeted; |
29 |
}
|
|
30 |
||
31 |
var finish_new_milestone = function(ignore) { |
|
9087.3.5
by Bjorn Tillenius
Make the milestone overlay use the standard showError(). |
32 |
milestone_form.clearError(); |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
33 |
milestone_form.hide(); |
34 |
// Reset the HTML form inside the widget.
|
|
9778.1.16
by Maris Fogels
Renamed deprecated Node.query() to Node.one(). |
35 |
milestone_form.get('contentBox').one('form').reset(); |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
36 |
next_step(parameters); |
37 |
};
|
|
38 |
||
12421.1.12
by Tim Penhey
Fix up references to methods now in Y.lp.client instead of LP.client. |
39 |
var client = new Y.lp.client.Launchpad(); |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
40 |
client.named_post(series_uri, 'newMilestone', { |
41 |
parameters: parameters, |
|
42 |
on: { |
|
43 |
success: finish_new_milestone, |
|
44 |
failure: function (ignore, response, args) { |
|
9778.1.12
by Maris Fogels
Update deprecated Y.get() for Y.one() |
45 |
var error_box = Y.one('#milestone-error'); |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
46 |
var error_message = '<strong>' + response.statusText + |
47 |
'</strong><p>' + |
|
48 |
response.responseText + |
|
49 |
'</p>'; |
|
9087.3.5
by Bjorn Tillenius
Make the milestone overlay use the standard showError(). |
50 |
milestone_form.showError(error_message); |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
51 |
}
|
52 |
}
|
|
53 |
});
|
|
54 |
};
|
|
55 |
||
56 |
||
57 |
var setup_milestone_form = function () { |
|
9087.3.6
by Bjorn Tillenius
Use loadFormContentAndRender() in milestoneoverlay.js |
58 |
var form_submit_button = Y.Node.create( |
59 |
'<input type="submit" name="field.actions.register" ' + |
|
60 |
'id="formoverlay-add-milestone" value="Create Milestone"/>'); |
|
61 |
milestone_form = new Y.lazr.FormOverlay({ |
|
62 |
headerContent: '<h2>Create Milestone</h2>', |
|
63 |
form_submit_button: form_submit_button, |
|
64 |
centered: true, |
|
65 |
form_submit_callback: save_new_milestone, |
|
66 |
visible: false |
|
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
67 |
});
|
9087.3.6
by Bjorn Tillenius
Use loadFormContentAndRender() in milestoneoverlay.js |
68 |
milestone_form.render(); |
69 |
milestone_form.loadFormContentAndRender(milestone_form_uri); |
|
11090.5.8
by Tim Penhey
Fix some more namespace issues. |
70 |
Y.lp.app.calendar.add_calendar_widgets(); |
9087.3.6
by Bjorn Tillenius
Use loadFormContentAndRender() in milestoneoverlay.js |
71 |
milestone_form.show(); |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
72 |
};
|
73 |
||
11009.1.2
by Edwin Grubbs
Made formoverlay appear correctly with textareas that are wider than normal. |
74 |
var show_milestone_form = function(e) { |
75 |
e.preventDefault(); |
|
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
76 |
if (milestone_form) { |
77 |
milestone_form.show(); |
|
78 |
} else { |
|
79 |
// This function call is asynchronous, so we can move
|
|
80 |
// milestone_form.show() below it.
|
|
81 |
setup_milestone_form(); |
|
82 |
}
|
|
83 |
};
|
|
84 |
||
85 |
/**
|
|
86 |
* Attaches a milestone form overlay widget to an element.
|
|
87 |
*
|
|
88 |
* @method attach_widget
|
|
89 |
* @param {Object} config Object literal of config name/value pairs.
|
|
90 |
* config.milestone_form_uri is the URI of the
|
|
91 |
* milestone form to display.
|
|
92 |
* config.series_uri is the URI to post the
|
|
93 |
* form data to create the milestone.
|
|
94 |
* activate_node is the node that shows the form
|
|
95 |
* when it is clicked.
|
|
96 |
* next_step is the function to be called after
|
|
97 |
* the milestone is created.
|
|
98 |
*/
|
|
10293.2.1
by Edwin Grubbs
Fixed registry js module names. |
99 |
module.attach_widget = function(config) { |
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
100 |
if (Y.UA.ie) { |
101 |
return; |
|
102 |
}
|
|
8602.1.5
by Curtis Hovey
Moved miletoneoverlay to the registry directory and added some asserts the ensure it is passed a valid config. |
103 |
if (config === undefined) { |
104 |
throw new Error( |
|
105 |
"Missing attach_widget config for milestoneoverlay."); |
|
106 |
}
|
|
107 |
if (config.milestone_form_uri === undefined || |
|
108 |
config.series_uri === undefined || |
|
109 |
config.next_step === undefined) { |
|
110 |
throw new Error( |
|
111 |
"attach_widget config for milestoneoverlay has " + |
|
112 |
"undefined properties."); |
|
113 |
}
|
|
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
114 |
milestone_form_uri = config.milestone_form_uri; |
115 |
series_uri = config.series_uri; |
|
116 |
next_step = config.next_step; |
|
117 |
config.activate_node.on('click', show_milestone_form); |
|
8602.1.3
by Curtis Hovey
Fixed lint issues in javascript. |
118 |
};
|
8602.1.1
by Curtis Hovey
Extracted the milestoneoverlay javasscript, and refactored it to accept work with other use cases. Fixed a broken windmill tests -- it was broken a few weeks ago when the series page changed. |
119 |
|
12421.1.12
by Tim Penhey
Fix up references to methods now in Y.lp.client instead of LP.client. |
120 |
}, "0.1", {"requires": ["dom", |
121 |
"node", |
|
122 |
"io-base", |
|
123 |
"lazr.anim", |
|
124 |
"lazr.formoverlay", |
|
125 |
"lp.app.calendar", |
|
126 |
"lp.client"
|
|
127 |
]});
|