~ubuntu-branches/ubuntu/precise/ubufox/precise-proposed

« back to all changes in this revision

Viewing changes to content/alternatePlugins.js

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2011-07-29 08:14:18 UTC
  • mfrom: (1.1.24 upstream)
  • Revision ID: james.westby@ubuntu.com-20110729081418-jp47q22u7kfr6y01
Tags: 1.0~b1-0ubuntu1
* New upstream release
  - Refactor the update restart notify functionality. The scheduling for
    checking if an update has occurred has been moved in to a JS module shared
    between windows, rather than having every window set up its own timer
    and doing its own checking. Each window registers as a listener on the
    new module
  - Drop all of the ubuntuAltPlugins overlay stuff. We still retain the
    dialog for configuring plugins, but the listeners that fired everytime
    a document was loaded or tab was switched have gone. Instead, the
    information required by the dialog is created when it is launched, rather
    than maintaining a bunch of state on each content document.
  - Clean up the variables that are added to the main window global scope.
    The only variables added now are functions called by menuitem oncommand
    handlers, and these are all namespaced org.ubuntu.Ubufox
  - Hide the translate menuitem in the help menu. It makes no sense to show
    this whilst we aren't using Launchpad for translations
  - Bump maxVersion to 8.0a1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 
 *
4
 
 * The contents of this file are subject to the Mozilla Public License Version
5
 
 * 1.1 (the "License"); you may not use this file except in compliance with
6
 
 * the License. You may obtain a copy of the License at
7
 
 * http://www.mozilla.org/MPL/
8
 
 *
9
 
 * Software distributed under the License is distributed on an "AS IS" basis,
10
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 
 * for the specific language governing rights and limitations under the
12
 
 * License.
13
 
 *
14
 
 * The Original Code is ubufox.
15
 
 *
16
 
 * The Initial Developer of the Original Code is
17
 
 * Canonical Ltd.
18
 
 * Portions created by the Initial Developer are Copyright (C) 2008
19
 
 * the Initial Developer. All Rights Reserved.
20
 
 *
21
 
 * Contributor(s):
22
 
 *   Doron Rosenberg <doronr@us.ibm.com>
23
 
 *   Alexander Sack <asac@jwsdot.com> - Canonical Ltd.
24
 
 *   Arzhel Younsi <xionox@gmail.com>
25
 
 *
26
 
 * Alternatively, the contents of this file may be used under the terms of
27
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
28
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
30
 
 * of those above. If you wish to allow use of your version of this file only
31
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
32
 
 * use your version of this file under the terms of the MPL, indicate your
33
 
 * decision by deleting the provisions above and replace them with the notice
34
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
35
 
 * the provisions above, a recipient may use your version of this file under
36
 
 * the terms of any one of the MPL, the GPL or the LGPL.
37
 
 *
38
 
 * ***** END LICENSE BLOCK ***** */
39
 
 
40
 
var gAltPluginWizard = null;
41
 
 
42
 
altPluginWizard.prototype.pluginUsed = function(pluginElement){
43
 
 
44
 
  var pluginsArray = pluginElement.ownerDocument.mimeContent;
45
 
  if (!pluginsArray)
46
 
    pluginsArray = {};
47
 
 
48
 
  var pluginInfo = getPluginInfo(pluginElement);
49
 
  pluginsArray[pluginInfo.mimetype] = pluginInfo;
50
 
  var thisTab = pluginElement.ownerDocument;
51
 
  thisTab.mimeContent = pluginsArray;
52
 
 
53
 
  if (gBrowser.selectedBrowser.contentDocument != pluginElement.ownerDocument)
54
 
      return;
55
 
 
56
 
  var iconAltPlugins = document.getElementById("iconAltPlugins");
57
 
  iconAltPlugins.hidden = false;
58
 
  var menuAltPlugins = document.getElementById("menuAltPlugins");
59
 
  menuAltPlugins.disabled = false;
60
 
}
61
 
 
62
 
altPluginWizard.prototype.tabSelected = function(aEvent){
63
 
 
64
 
  if(gBrowser.selectedBrowser.contentDocument.mimeContent){
65
 
    var iconAltPlugins = document.getElementById("iconAltPlugins");
66
 
    iconAltPlugins.hidden = false;
67
 
    var menuAltPlugins = document.getElementById("menuAltPlugins");
68
 
    menuAltPlugins.disabled = false;
69
 
  }else{
70
 
    var iconAltPlugins = document.getElementById("iconAltPlugins");
71
 
    iconAltPlugins.hidden = true;
72
 
    var menuAltPlugins = document.getElementById("menuAltPlugins");
73
 
    menuAltPlugins.disabled = false;
74
 
  }
75
 
}
76
 
 
77
 
altPluginWizard.prototype.domContentLoaded = function(aEvent){
78
 
    var elements = aEvent.target.getElementsByTagName("embed");
79
 
    for (let a = 0; a< elements.length; a++) {
80
 
        gAltPluginWizard.pluginUsed (elements[a]);
81
 
    }
82
 
}
83
 
 
84
 
function altPluginWizard(){
85
 
}
86
 
 
87
 
function openPluginFinder(contentMimeArray){
88
 
    
89
 
  var iconAltPlugins = document.getElementById("iconAltPlugins");
90
 
  window.openDialog("chrome://ubufox/content/pluginAlternativeOverlay.xul",
91
 
                   "PFSWindow", "chrome,centerscreen,resizable=yes",
92
 
                   {plugins: contentMimeArray, browser: gBrowser.selectedBrowser, pluginsOnTab: !iconAltPlugins.hidden});
93
 
}
94
 
 
95
 
 
96
 
window.addEventListener("load", function() {
97
 
 
98
 
  gAltPluginWizard = new altPluginWizard();
99
 
  gBrowser.tabContainer.addEventListener("TabSelect", gAltPluginWizard.tabSelected, false);
100
 
  gBrowser.addEventListener("DOMContentLoaded", gAltPluginWizard.domContentLoaded, false);
101
 
  window.removeEventListener("load", arguments.callee, false);
102
 
 
103
 
}, false);
104