bug/bug/bug.js     |   25 ++++++++++++++++++-------
 bug/bug/frame.html |   26 ++++++++++++++++++++++++++
 bug/bug/test.js    |   15 +++++++++++++++
 3 files changed, 59 insertions(+), 7 deletions(-)

New commits:
commit 8bdae74b1e1549aa8ddb1b1c6cbc5de894ee83eb
Author: Loic Dachary <l...@dachary.org>
Date:   Wed Oct 19 17:36:05 2011 +0200

    Fixes https://bugassistant.libreoffice.org/show_bug.cgi?id=41832
    Each bugzilla url is prefixed with $.bug.url which defaults to the empty 
string. That ensures that bug.html keeps working on a virtualhost configured as 
instructed in 
http://wiki.documentfoundation.org/Bug_Submission_Assistant#System_Administration.
 Add the frame() function that sets the $.bug.url string with the content of 
the bugzilla_url variable found in the parent window javascript context, if 
any. The document enclosing the iframe is loaded from the origin server (the 
one used to check for same origin policy) and it therefore knows which URL is 
set as a proxypass to bugzilla. The Bug Submission Assistant itself cannot know 
this because it may be included in a number of different contexts.

diff --git a/bug/bug/bug.js b/bug/bug/bug.js
index fd70b79..30c9b7f 100644
--- a/bug/bug/bug.js
+++ b/bug/bug/bug.js
@@ -18,6 +18,8 @@
 
     $.bug = {
 
+        window: window,
+
         ajax: function(type, url, args) {
             return $.ajax({
                 type: type,
@@ -75,6 +77,8 @@
             $('.error-container').show();
         },
 
+        url: '',
+
         state_signin_error_regexps: ['class="throw_error">([^<]*)'],
         state_signin_success_regexp: 'Log&nbsp;out</a>([^<]*)',
 
@@ -83,7 +87,7 @@
             $('.go', element).click(function() {
                 $("body").css("cursor", "progress");
                 $.bug.error_clear();
-                $.bug.ajax('POST', '/index.cgi', {
+                $.bug.ajax('POST', $.bug.url + '/index.cgi', {
                     Bugzilla_login: $('.user', element).val(),
                     Bugzilla_password: $('.password', element).val()
                 }).pipe(function(data) {
@@ -248,7 +252,7 @@
             $('.submission').hide();
             var element = $('.state_success');
             var bug = $('.state_submit .bug').text();
-            $('.bug', element).attr('href', '/show_bug.cgi?id=' + bug);
+            $('.bug', element).attr('href', $.bug.url + '/show_bug.cgi?id=' + 
bug);
             element.show();
         },
 
@@ -258,7 +262,7 @@
 
         logged_in: function() {
             $("body").css("cursor", "progress");
-            return $.bug.ajax('GET', '/enter_bug.cgi').pipe(function(data) {
+            return $.bug.ajax('GET', $.bug.url + 
'/enter_bug.cgi').pipe(function(data) {
                 $("body").css("cursor", "default");
                 return data.indexOf($.bug.logged_in_false) < 0;
             });
@@ -268,7 +272,7 @@
             $('.related_bugs').empty();
             var component = $('.state_component 
.chosen').attr('data').replace('_','%20');
             var subcomponent = $('.state_subcomponent .active_subcomponent 
.chosen').attr('data');
-            var list = '/buglist.cgi?columnlist=short_desc&component=' + 
component + 
'&product=LibreOffice&query_format=advanced&short_desc_type=allwordssubstr&ctype=csv&short_desc='
 + subcomponent;
+            var list = $.bug.url + 
'/buglist.cgi?columnlist=short_desc&component=' + component + 
'&product=LibreOffice&query_format=advanced&short_desc_type=allwordssubstr&ctype=csv&short_desc='
 + subcomponent;
             $.bug.ajax('GET', list).pipe(function(data) {
                 var lines = data.split('\n');
                 var bug_urls = [];
@@ -283,8 +287,15 @@
             $('.left .step:last-child').addClass('last-child'); // cross 
browser compatibility
         },
 
+        frame: function() {
+            if($.bug.window != $.bug.window.top && 
$.bug.window.parent.bugzilla_url !== undefined) {
+                $.bug.url = $.bug.window.parent.bugzilla_url;
+            }
+        },
+
         main: function() {
             $.bug.compatibility();
+            $.bug.frame();
             $.bug.logged_in().done(function(status) {
                 if(status) {
                     $.bug.state_component();
diff --git a/bug/bug/test.js b/bug/bug/test.js
index cb87f93..576fc7d 100644
--- a/bug/bug/test.js
+++ b/bug/bug/test.js
@@ -16,6 +16,21 @@
 //
 module("bug");
 
+test("frame", function() {
+    expect(2);
+
+    bugzilla_url = 'BUGZILLA_URL';
+
+    $.bug.window = {
+        top: 'something',
+        parent: { bugzilla_url: bugzilla_url }
+    };
+
+    equal($.bug.url, '');
+    $.bug.frame();
+    equal($.bug.url, bugzilla_url);
+});
+
 test("ajax", function() {
     expect(4);
 
commit 00e2742998bb1fd9645f75eeffd5b62f4088efc2
Author: Loic Dachary <l...@dachary.org>
Date:   Wed Oct 19 17:28:19 2011 +0200

    Add a file including bug.html in a frame for testing purposes. It requires 
that the server on which it runs has a proxypass to bugs.freedesktop.org bound 
to /bugzilla

diff --git a/bug/bug/frame.html b/bug/bug/frame.html
new file mode 100644
index 0000000..6f82168
--- /dev/null
+++ b/bug/bug/frame.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd";>
+<html>
+<!--
+     Copyright (C) 2011 Loic Dachary <l...@dachary.org>
+
+     This program is free software: you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published by
+     the Free Software Foundation, either version 3 of the License, or
+     (at your option) any later version.
+
+     This program is distributed in the hope that it will be useful,
+     but WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+     GNU General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with this program.  If not, see <http:www.gnu.org/licenses/>.
+-->
+  <head>
+    <title>Load bug.html in a frame</title>
+  </head>
+  <body>
+    <script>var bugzilla_path = '/bugzilla';</script>
+    <iframe src="bug.html?version=2" width="892" height="1600" 
frameborder="0"> </iframe>
+  </body>
+</html>
commit 96a5f39decae7f9cc2c948b937a8ca0fb0651602
Author: Loic Dachary <l...@dachary.org>
Date:   Wed Oct 19 17:19:10 2011 +0200

    remove unused argument to $.bug.ajax function

diff --git a/bug/bug/bug.js b/bug/bug/bug.js
index 1086288..fd70b79 100644
--- a/bug/bug/bug.js
+++ b/bug/bug/bug.js
@@ -18,12 +18,11 @@
 
     $.bug = {
 
-        ajax: function(type, url, args, callback) {
+        ajax: function(type, url, args) {
             return $.ajax({
                 type: type,
                 url: url,
-                data: args,
-                success: callback
+                data: args
             }).pipe(null, function(error) {
                 var message = url + '(' + $.param(args) + ') XHR error. ';
                 if('status' in error) {
@@ -220,6 +219,7 @@
                     var short_desc = $('.state_subcomponent 
.active_subcomponent .chosen').attr('data') + ': ' + $('.state_description 
.short').val();
                     var comment = $('.state_description .long').val();
                     $("body").css("cursor", "progress");
+                    // 
http://stackoverflow.com/questions/1852518/how-to-get-scrolltop-of-an-iframe
                     $('html, body').animate({scrollTop: '0px'}, 300);
                     $('input[name="component"]', form).val(component);
                     $('input[name="version"]', form).val(version);
_______________________________________________
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to