home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
- <!DOCTYPE window [
- <!ENTITY % sitecontrolsDTD SYSTEM "chrome://browser/locale/sitecontrols.dtd" >
- %sitecontrolsDTD;
- ]>
-
- <bindings id="siteControlsBindings"
- xmlns="http://www.mozilla.org/xbl"
- xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:xbl="http://www.mozilla.org/xbl">
-
- <binding id="sitecontrols-tree">
- <implementation>
- <constructor><![CDATA[
- this.debug('CONSTRUCTOR');
- // This function only reads in the sitecontrols from disk if they have not already been read.
- sitecontrols.initServices();
-
- // Load column settings from persisted attribute
- var colinfostr = this.getAttribute("colinfo");
- var colinfo = colinfostr.split(" ");
- for (var i = 0; i < colinfo.length; ++i) {
- if (colinfo[i] == "") continue;
-
- var querymarker = colinfo[i].indexOf("?");
- var anonid = colinfo[i].substring(4, querymarker);
- var col = document.getAnonymousElementByAttribute(this, "id", anonid);
-
- if (!anonid || !col) break;
-
- var attrstring = colinfo[i].substr(querymarker + 1);
-
- var attrpairs = attrstring.split("&");
- for (var j = 0; j < attrpairs.length; ++j) {
- var pair = attrpairs[j].split("=");
- col.setAttribute(pair[0], pair[1]);
- }
- }
- ]]></constructor>
-
-
- <property name="db">
- <getter><![CDATA[
- return this.tree.database;
- ]]></getter>
- </property>
-
-
- <field name="sorted">false</field>
-
-
- <method name="refreshSort">
- <body>
- <![CDATA[
- //return;
- this.debug('refreshSort()');
-
- // This ensures that we don't sort twice in the tree that is clicked on
- // as a result of 1) the click and 2) the pref listener.
- if (!this.sorted) {
- try {
- var sortColumn = 'siteName';
- var sortDirection = 'ascending';
-
- // Walk the columns, when we find a column with a sort resource that matches the supplied
- // data, stop and make sure it's sort active.
- var treecols = document.getAnonymousElementByAttribute(this, "anonid", "treecols");
- var child = treecols.firstChild;
- while (child) {
- if (child.localName != "splitter") {
- if (child.getAttribute("id") == sortColumn) {
- child.setAttribute("sortActive", "true");
- child.setAttribute("sortDirection", sortDirection);
- this.treeBuilder.sort(child, false);
- break;
- }
- }
- child = child.nextSibling;
- }
- }
- catch (e) {
- dump("error in refresh sort:"+e)
- }
- }
- this.sorted = false;
- ]]>
- </body>
- </method>
-
-
- <property name="columns">
- <getter>
- <![CDATA[
- var cols = [];
- var treecols = document.getAnonymousElementByAttribute(this, "anonid", "treecols");
- var child = treecols.firstChild;
- while (child) {
- if (child.localName != "splitter") {
- var obj = {
- label: child.getAttribute("label"),
- accesskey: child.getAttribute("accesskey"),
- resource: child.getAttribute("sort"),
- sortActive: child.getAttribute("sortActive") == "true",
- hidden: child.getAttribute("hidden")
- }
- cols.push(obj);
- }
- child = child.nextSibling;
- }
- return cols;
- ]]>
- </getter>
- </property>
-
-
- <property name="tree">
- <getter><![CDATA[
- return document.getAnonymousElementByAttribute(this, "anonid", "sitecontrols-tree");
- ]]></getter>
- </property>
-
-
- <property name="treeChildren">
- <getter><![CDATA[
- return document.getAnonymousElementByAttribute(this, "anonid", "sitecontrols-treechildren");
- ]]></getter>
- </property>
-
-
- <property name="treeBoxObject">
- <getter><![CDATA[
- return this.tree.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject);
- ]]></getter>
- </property>
-
-
- <property name="treeBuilder">
- <getter><![CDATA[
- return this.tree.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
- ]]></getter>
- </property>
-
-
- <property name="type">
- <getter><![CDATA[
- if (!this._type) {
- var type = this.getAttribute("type");
- if (!type)
- type = "multi-column";
- this._type = type;
- }
- return this._type;
- ]]></getter>
- </property>
-
-
- <property name="currentIndex">
- <getter><![CDATA[
- return this.treeBoxObject.selection.currentIndex;
- ]]></getter>
- </property>
-
-
- <property name="currentResource">
- <getter><![CDATA[
- return this.treeBuilder.getResourceAtIndex(this.currentIndex);
- ]]></getter>
- </property>
-
-
- <method name="getRowResource">
- <parameter name="aRow"/>
- <body><![CDATA[
- this.debug('getRowResource(...)');
- if (aRow != -1)
- return this.treeBuilder.getResourceAtIndex(aRow);
- else
- return this.getRootResource();
- ]]></body>
- </method>
-
-
- <method name="getParentResource">
- <parameter name="aRow"/>
- <body><![CDATA[
- this.debug('getParentResource(...)');
- if (aRow != -1) {
- var parentIndex = this.treeBoxObject.view.getParentIndex(aRow);
- return this.getRowResource(parentIndex);
- }
- return this.getRootResource(); // assume its parent is the root
- ]]></body>
- </method>
-
-
- <method name="getRootResource">
- <body><![CDATA[
- this.debug('getRootResource()');
- var tree = document.getAnonymousElementByAttribute(this, "anonid", "sitecontrols-tree");
- return RDF.GetResource(tree.ref);
- ]]></body>
- </method>
-
-
- <method name="focus">
- <body>
- this.debug('focus()');
- this.tree.focus();
- </body>
- </method>
-
-
- <method name="removeItemConfirm">
- <body><![CDATA[
- this.debug('removeItemConfirm()');
-
- // Bail if nothing is selected
- var siteRes = this.tree.view.getResourceAtIndex(this.tree.currentIndex);
- if (!siteRes) return;
-
- // Bail if it's one of the "Default"s or "Local Files" site
- var titleProp = sitecontrols.RDF.GetResource(sitecontrols.SC_NS+'title');
- var titleRes = sitecontrols.SCDS.GetTarget(siteRes, titleProp, true);
- var titleLit = titleRes.QueryInterface(Components.interfaces.nsIRDFLiteral);
- if (titleLit.Value == 'Local Files' ||
- titleLit.Value == 'Verified Default' ||
- titleLit.Value == 'Not Verified Default' ||
- titleLit.Value == 'Warning Default') return;
-
- // Prompt for confirmation
- const IPS = Components.interfaces.nsIPromptService;
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(IPS);
- var promptMessage = 'Remove this site from your list of controlled sites?';
- var checkEveryTime = { value: null };
- // xxxTODO: i18n
- var rv = ps.confirmEx(window, 'Remove Site', promptMessage,
- (IPS.BUTTON_TITLE_YES * IPS.BUTTON_POS_0) +
- (IPS.BUTTON_TITLE_NO * IPS.BUTTON_POS_1),
- null, null, null, null, checkEveryTime);
- if (rv == 0) {
- this.debug('removing...');
- sitecontrols.SCSVC.removeControlledSite(titleLit.Value);
- this.refreshList();
- this.debug('...finished removing :)');
- }
- ]]></body>
- </method>
-
-
- <method name="debug">
- <parameter name="msg"/>
- <body><![CDATA[
- dump('sitecontrols-tree: '+msg+'\n');
- ]]></body>
- </method>
-
-
- <method name="refreshList">
- <parameter name="aInput"/>
- <body><![CDATA[
- this.debug('refreshList('+aInput+')');
-
- // Clear out the existing datasources
- datasources = this.tree.database.GetDataSources();
- while (datasources.hasMoreElements())
- this.tree.database.RemoveDataSource(datasources.getNext());
-
- var ds = new SiteControlsFilterDataSource;
- if (aInput) ds.SetFilter(aInput);
- this.tree.database.AddDataSource(ds);
- this.tree.builder.rebuild();
- ]]></body>
- </method>
-
- </implementation>
- </binding>
-
-
- <binding id="sitecontrols-tree-basic"
- extends="chrome://browser/content/sitecontrols/bindings.xml#sitecontrols-tree">
- <xbl:resources>
- <xbl:stylesheet src="chrome://browser/skin/pref/sitecontrols-tree.css"/>
- </xbl:resources>
- <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- xmlns:xbl="http://www.mozilla.org/xbl"
- contextmenu="_child">
- <!-- context menu -->
- <menupopup>
- <menuitem anonid="removeSite"
- label="Remove site"
- oncommand="this.parentNode.parentNode.removeItemConfirm();"/>
- </menupopup>
- <vbox flex="1">
- <tree anonid="sitecontrols-tree" flex="1" class="plain"
- datasources="rdf:null" ref="SiteControls:Root"
- sortResource="http://home.netscape.com/SC-rdf#title"
- hidecolumnpicker="true" seltype="single" flags="dont-build-content"
- onselect="this.treeBoxObject.view.selectionChanged();">
- <template container="?uri" member="?site">
- <rule>
- <conditions>
- <content uri="?uri"/>
- <member container="?uri" child="?site"/>
- <triple subject="?site"
- predicate="http://home.netscape.com/SC-rdf#title"
- object="?title"/>
- <triple subject="?site"
- predicate="http://home.netscape.com/SC-rdf#securityLevel"
- object="Low"/>
- </conditions>
- <action>
- <treechildren anonid="sitecontrols-treechildren">
- <treeitem uri="?site" value="?title">
- <treerow>
- <treecell class="site" label="?title" properties="Low"/>
- </treerow>
- </treeitem>
- </treechildren>
- </action>
- </rule>
- <rule>
- <conditions>
- <content uri="?uri"/>
- <member container="?uri" child="?site"/>
- <triple subject="?site"
- predicate="http://home.netscape.com/SC-rdf#title"
- object="?title"/>
- <triple subject="?site"
- predicate="http://home.netscape.com/SC-rdf#securityLevel"
- object="Medium"/>
- </conditions>
- <action>
- <treechildren anonid="sitecontrols-treechildren">
- <treeitem uri="?site" value="?title">
- <treerow>
- <treecell class="site" label="?title" properties="Medium"/>
- </treerow>
- </treeitem>
- </treechildren>
- </action>
- </rule>
- <rule>
- <conditions>
- <content uri="?uri"/>
- <member container="?uri" child="?site"/>
- <triple subject="?site"
- predicate="http://home.netscape.com/SC-rdf#title"
- object="?title"/>
- <triple subject="?site"
- predicate="http://home.netscape.com/SC-rdf#securityLevel"
- object="High"/>
- </conditions>
- <action>
- <treechildren anonid="sitecontrols-treechildren">
- <treeitem uri="?site" value="?title">
- <treerow>
- <treecell class="site" label="?title" properties="High"/>
- </treerow>
- </treeitem>
- </treechildren>
- </action>
- </rule>
- <rule>
- <conditions>
- <content uri="?uri"/>
- <member container="?uri" child="?site"/>
- <triple subject="?site"
- predicate="http://home.netscape.com/SC-rdf#title"
- object="?title"/>
- </conditions>
- <action>
- <treechildren anonid="sitecontrols-treechildren">
- <treeitem uri="?site" value="?title">
- <treerow>
- <treecell class="site" label="?title" properties="Custom"/>
- </treerow>
- </treeitem>
- </treechildren>
- </action>
- </rule>
- </template>
- <treecols anonid="treecols">
- <treecol id="siteName" sortActive="true" sortDirection="ascending"
- hideheader="true" flex="2"
- sort="?title"/>
- </treecols>
- </tree>
- </vbox>
- </xbl:content>
- <implementation>
- <field name="clickCount">2</field>
- </implementation>
- </binding>
-
- </bindings>