~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/javascript/lp.js

  • Committer: j.c.sackett
  • Date: 2011-11-04 18:12:47 UTC
  • mfrom: (14253 devel)
  • mto: This revision was merged to the branch mainline in revision 14287.
  • Revision ID: jonathan.sackett@canonical.com-20111104181247-5p1rmwj734n4onis
Merged in devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
         * @return {string} the value of the key.
48
48
         */
49
49
        get: function(key) {
50
 
            // The default is true, only values explicitly set to false
 
50
            // The default is true.  Only values explicitly set to false
51
51
            // are false.
52
 
            return (Y.Cookie.getSub('launchpad_views', key) != 'false');
 
52
            return (Y.Cookie.getSub('launchpad_views', key) !== 'false');
53
53
            }
54
54
    };
55
55
 
64
64
            '.collapsible', 'legend', 'legend + *', true);
65
65
    };
66
66
 
 
67
    /**
 
68
     * Return a hyperlink with the specified URL.
 
69
     */
 
70
    var get_hyperlink  = function(url){
 
71
        var link =  Y.Node.create('<a>junk</a>');
 
72
        link.set('href', url);
 
73
        return link;
 
74
    };
 
75
 
 
76
    /**
 
77
     * Return the path portion of the specified URL.
 
78
     */
67
79
    Y.lp.get_url_path = function(url) {
68
 
         return Y.Node.create('<a>junk</a>').set('href', url).get('pathname');
69
 
    };
70
 
}, "0.1", {"requires":["cookie", "lazr.effects", "lp.app.widgets.expander"]});
 
80
        return get_hyperlink(url).get('pathname');
 
81
    };
 
82
 
 
83
    /**
 
84
     * Return the query string of the specified URL.
 
85
     */
 
86
    Y.lp.get_url_query = function(url){
 
87
        var link = get_hyperlink(url);
 
88
        var query = link.get('search');
 
89
        if (query.length > 0) {
 
90
            query = query.slice(1);
 
91
        }
 
92
        return query;
 
93
    };
 
94
}, "0.1", {"requires":["cookie", "lp.app.widgets.expander"]});
71
95
 
72
96
 
73
97
// Lint-safe scripting URL.
105
129
function setFocusByName(name) {
106
130
    // Focus the first element matching the given name which can be focused.
107
131
    var nodes = document.getElementsByName(name);
108
 
    for (var i = 0; i < nodes.length; i++) {
109
 
        var node = nodes[i];
 
132
    var i, node;
 
133
    for (i = 0; i < nodes.length; i++) {
 
134
        node = nodes[i];
110
135
        if (node.focus) {
111
136
            try {
112
137
                // Trying to focus a hidden element throws an error in IE8.
126
151
 
127
152
function popup_window(url, name, width, height) {
128
153
    var iframe = document.getElementById('popup_iframe_' + name);
129
 
    if (!iframe.src || iframe.src == VOID_URL) {
 
154
    if (!iframe.src || iframe.src === VOID_URL) {
130
155
        // The first time this handler runs the window may not have been
131
156
        // set up yet; sort that out.
132
157
        iframe.style.width = width + 'px';
143
168
}
144
169
 
145
170
function selectWidget(widget_name, event) {
146
 
  if (event && (event.keyCode == 9 || event.keyCode == 13)) {
 
171
  if (event && (event.keyCode === 9 || event.keyCode === 13)) {
147
172
      // Avoid firing if user is tabbing through or simply pressing
148
173
      // enter to submit the form.
149
174
      return;
155
180
    var div = document.getElementById('bugbranch' + id);
156
181
    var wb = document.getElementById('bugbranch' + id + '-wb');
157
182
 
158
 
    if (div.style.display == "none") {
 
183
    if (div.style.display === "none") {
159
184
        /* Expanding the form */
160
185
        if (wb !== null) {
161
186
            wb.style.display = "none";
185
210
    var div = document.getElementById('specbranch' + id);
186
211
    var wb = document.getElementById('specbranch' + id + '-summary');
187
212
 
188
 
    if (div.style.display == "none") {
 
213
    if (div.style.display === "none") {
189
214
        /* Expanding the form */
190
215
        if (wb !== null) {
191
216
            wb.style.display = "none";