~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/composer/base/content/bindings/tabeditor.xml

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0"?>
 
2
 
 
3
<!-- ***** BEGIN LICENSE BLOCK *****
 
4
   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
5
   -
 
6
   - The contents of this file are subject to the Mozilla Public License Version
 
7
   - 1.1 (the "License"); you may not use this file except in compliance with
 
8
   - the License. You may obtain a copy of the License at
 
9
   - http://www.mozilla.org/MPL/
 
10
   -
 
11
   - Software distributed under the License is distributed on an "AS IS" basis,
 
12
   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
13
   - for the specific language governing rights and limitations under the
 
14
   - License.
 
15
   -
 
16
   - The Original Code is Nvu.
 
17
   -
 
18
   - The Initial Developer of the Original Code is
 
19
   - Linspire Inc..
 
20
   - Portions created by the Initial Developer are Copyright (C) 2003
 
21
   - the Initial Developer. All Rights Reserved.
 
22
   -
 
23
   - Contributor(s):
 
24
   -   Daniel Glazman <glazman@disruptive-innovations.com>, on behalf of Linspire Inc.
 
25
   -   Fabien Cazenave (Kaze) http://fabiwan.kenobi.free.fr/
 
26
   -
 
27
   - Alternatively, the contents of this file may be used under the terms of
 
28
   - either the GNU General Public License Version 2 or later (the "GPL"), or
 
29
   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
30
   - in which case the provisions of the GPL or the LGPL are applicable instead
 
31
   - of those above. If you wish to allow use of your version of this file only
 
32
   - under the terms of either the GPL or the LGPL, and not to allow others to
 
33
   - use your version of this file under the terms of the MPL, indicate your
 
34
   - decision by deleting the provisions above and replace them with the notice
 
35
   - and other provisions required by the LGPL or the GPL. If you do not delete
 
36
   - the provisions above, a recipient may use your version of this file under
 
37
   - the terms of any one of the MPL, the GPL or the LGPL.
 
38
   -
 
39
   - ***** END LICENSE BLOCK ***** -->
 
40
 
 
41
<!DOCTYPE bindings [
 
42
  <!ENTITY % tabEditorDTD SYSTEM "chrome://editor/locale/tabeditor.dtd" >
 
43
  %tabEditorDTD;
 
44
]>
 
45
 
 
46
<bindings id="tabEditorBindings"
 
47
          xmlns="http://www.mozilla.org/xbl"
 
48
          xmlns:html="http://www.w3.org/1999/xhtml"
 
49
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
 
50
          xmlns:xbl="http://www.mozilla.org/xbl">
 
51
 
 
52
  <binding id="tabeditor">
 
53
    <resources>
 
54
      <stylesheet src="chrome://editor/skin/editor.css"/>
 
55
    </resources>
 
56
 
 
57
    <content>
 
58
      <xul:stringbundle src="chrome://editor/locale/tabeditor.properties"/>
 
59
      <xul:tabbox anonid="EditorTabbox" flex="1" onselect="this.parentNode.setFocus();">
 
60
        <xul:hbox class="tabbrowser-strip chromeclass-toolbar" context="_child">
 
61
 
 
62
          <xul:menupopup>
 
63
            <xul:menuitem label="&newTab.label;" accesskey="&newTab.accesskey;" command="cmd_newEditorTab"/>
 
64
            <xul:menuseparator/>
 
65
            <!-- Kaze: these two items refer to the active tab, not to the pointed tab. Danger!
 
66
            <xul:menuitem label="&revert.label;" accesskey="&revert.accesskey;" command="cmd_revert"/>
 
67
            <xul:menuitem label="&refreshImages.label;" acceskey="&refreshImages.accesskey;" command="cmd_refreshImages"/> 
 
68
            -->
 
69
            <xul:menuitem label="&revert.label;" accesskey="&revert.accesskey;" 
 
70
                          oncommand="var tabeditor = this.parentNode.parentNode.parentNode.parentNode;
 
71
                                     RevertTab(tabeditor.mContextTab);"/>
 
72
            <xul:menuitem label="&refreshImages.label;" acceskey="&refreshImages.accesskey;"
 
73
                          oncommand="var tabeditor = this.parentNode.parentNode.parentNode.parentNode;
 
74
                                     RefreshTab(tabeditor.mContextTab);"/>
 
75
            <xul:menuseparator/>
 
76
            <xul:menuitem label="&closeTab.label;" accesskey="&closeTab.accesskey;"
 
77
                          oncommand="var tabeditor = this.parentNode.parentNode.parentNode.parentNode;
 
78
                                     CloseTab(tabeditor.mContextTab); SelectTabEditor();"/><!-- Kaze: added 'SelectTabEditor' -->
 
79
            <xul:menuseparator/>
 
80
            <xul:menuitem label="&closeOtherTabs.label;" accesskey="&closeOtherTabs.accesskey;"
 
81
                          oncommand="var tabeditor = this.parentNode.parentNode.parentNode.parentNode;
 
82
                                     RemoveAllTabsBut(tabeditor.mContextTab);"/>
 
83
          </xul:menupopup>
 
84
 
 
85
          <xul:tabs flex="1" class="tabbrowser-tabs" anonid="EditorTabs" closebutton="true"
 
86
                    setfocus="false"
 
87
                    onclick="this.parentNode.parentNode.parentNode.onTabClick(event)"
 
88
                    onclosetab="CloseCurrentTab(true); SelectTabEditor()"
 
89
                    onmousedown="this.parentNode.parentNode.parentNode.updateContextTab(event);"
 
90
                    oncommand="SelectTabEditor()">
 
91
            <xul:tab label="&untitledDocument.label;" 
 
92
                     maxwidth="200" width="0" minwidth="30" flex="100"
 
93
                     crop="end"/>
 
94
          </xul:tabs>
 
95
        </xul:hbox>
 
96
        <xul:grid flex="1">
 
97
          <xul:columns><xul:column anonid="vRulerColumn"/><xul:column flex="1"/></xul:columns>
 
98
          <xul:rows>
 
99
            <xul:row anonid="hRulerRow" style="border-top: outset 1px;">
 
100
              <xul:spacer/>
 
101
              <xul:stack id="hRuler" style="min-height: 22px; overflow: hidden"
 
102
                        onmousedown="window.InitiateMoveObjectInRuler(event)"/>
 
103
            </xul:row>
 
104
            <xul:row flex="1">
 
105
              <xul:stack id="vRuler" onmousedown="window.InitiateMoveObjectInRuler(event)"
 
106
                        style="border-right: outset 1px; width: auto; min-width: 1em; overflow: hidden"/>
 
107
              <xul:tabpanels anonid="EditorTabpanels" selectedIndex="0">
 
108
                <xul:editor editortype="html" type="content-primary" id="content-frame"
 
109
                            context="editorContentContext"
 
110
                            flex="1" tooltip="aHTMLTooltip"/>
 
111
              </xul:tabpanels>
 
112
            </xul:row>
 
113
          </xul:rows>
 
114
        </xul:grid>
 
115
      </xul:tabbox>
 
116
    </content>
 
117
 
 
118
    <implementation>
 
119
      <constructor>
 
120
        <![CDATA[
 
121
          ShowRulers(!(this.getAttribute("collapserulers") == "true"));
 
122
          document.addEventListener("keypress", this._keyEventHandler, false);
 
123
        ]]>
 
124
      </constructor>
 
125
 
 
126
      <destructor>
 
127
        <![CDATA[
 
128
          const editors = this.mTabPanels.childNodes;
 
129
          for (var i = 0; i < editors.length; i++)
 
130
          {
 
131
            editors[i].removeEventListener("DOMTitleChanged", this.changeTabTitle, false);
 
132
          }
 
133
          document.removeEventListener("keypress", this._keyEventHandler, false);
 
134
        ]]>
 
135
      </destructor>
 
136
 
 
137
      <field name="endNavigationCallback">null</field>
 
138
      <field name="mCurrentLoadedTab">null</field>
 
139
      <field name="mContextTab">null</field>
 
140
 
 
141
      <field name="_keyEventHandler" readonly="true">
 
142
      <![CDATA[({
 
143
        tabeditor: this,
 
144
        handleEvent: function handleEvent(aEvent) {
 
145
          if (!aEvent.isTrusted) {
 
146
            // Don't let untrusted events mess with tabs.
 
147
            return;
 
148
          }
 
149
 
 
150
          if (aEvent.ctrlKey && aEvent.keyCode == KeyEvent.DOM_VK_F4)
 
151
          {
 
152
            CloseCurrentTab(true);
 
153
            SelectTabEditor();
 
154
          }
 
155
        }
 
156
      })]]>
 
157
      </field>
 
158
 
 
159
      <property name="mTabbox">
 
160
        <getter>
 
161
        <![CDATA[
 
162
          return document.getAnonymousElementByAttribute(this, "anonid", "EditorTabbox");
 
163
        ]]>
 
164
        </getter>
 
165
      </property>
 
166
 
 
167
      <property name="mTabs">
 
168
        <getter>
 
169
        <![CDATA[
 
170
          return document.getAnonymousElementByAttribute(this, "anonid", "EditorTabs");
 
171
        ]]>
 
172
        </getter>
 
173
      </property>
 
174
 
 
175
      <property name="mTabpanels">
 
176
        <getter>
 
177
        <![CDATA[
 
178
          return document.getAnonymousElementByAttribute(this, "anonid", "EditorTabpanels");
 
179
        ]]>
 
180
        </getter>
 
181
      </property>
 
182
 
 
183
      <property name="mHRulerRow">
 
184
        <getter>
 
185
        <![CDATA[
 
186
          return document.getAnonymousElementByAttribute(this, "anonid", "hRulerRow");
 
187
        ]]>
 
188
        </getter>
 
189
      </property>
 
190
 
 
191
      <property name="mVRulerColumn">
 
192
        <getter>
 
193
        <![CDATA[
 
194
          return document.getAnonymousElementByAttribute(this, "anonid", "vRulerColumn");
 
195
        ]]>
 
196
        </getter>
 
197
      </property>
 
198
 
 
199
      <property name="selectedPanel">
 
200
        <getter>
 
201
        <![CDATA[
 
202
          return this.mTabbox.selectedPanel;
 
203
        ]]>
 
204
        </getter>
 
205
        <setter>
 
206
        <![CDATA[
 
207
          this.mTabbox.selectedPanel = val;
 
208
        ]]>
 
209
        </setter>
 
210
      </property>
 
211
 
 
212
      <property name="selectedTab">
 
213
        <getter>
 
214
        <![CDATA[
 
215
          return this.mTabbox.selectedTab;
 
216
        ]]>
 
217
        </getter>
 
218
        <setter>
 
219
        <![CDATA[
 
220
          this.mTabbox.selectedTab = val;
 
221
        ]]>
 
222
        </setter>
 
223
      </property>
 
224
 
 
225
      <property name="selectedIndex">
 
226
        <getter>
 
227
        <![CDATA[
 
228
          return this.mTabbox.selectedIndex;
 
229
        ]]>
 
230
        </getter>
 
231
        <setter>
 
232
        <![CDATA[
 
233
          this.mTabbox.selectedIndex = val;
 
234
        ]]>
 
235
        </setter>
 
236
      </property>
 
237
 
 
238
      <method name="onTabClick">
 
239
        <parameter name="event"/>
 
240
        <body>
 
241
          <![CDATA[
 
242
            if (event.button != 1 || event.target.localName != 'tab')
 
243
              return;
 
244
 
 
245
            CloseTab(event.target);
 
246
            this.SelectTabEditor(); // Kaze
 
247
            event.stopPropagation();
 
248
          ]]>
 
249
        </body>
 
250
      </method>
 
251
 
 
252
      <method name="setFocus">
 
253
        <body>
 
254
          <![CDATA[
 
255
            try
 
256
            {
 
257
              this.selectedPanel.contentWindow.focus();
 
258
            }
 
259
            catch (e) {}
 
260
          ]]>
 
261
        </body>
 
262
      </method>
 
263
 
 
264
      <method name="updateContextTab">
 
265
        <parameter name="aEvent"/>
 
266
        <body>
 
267
          <![CDATA[
 
268
            if (aEvent.originalTarget.localName == "tab")
 
269
              this.mContextTab = aEvent.originalTarget;
 
270
            else
 
271
              this.mContextTab = this.selectedTab; // Kaze
 
272
              //~ this.mContextTab = document.popupNode;
 
273
          ]]>
 
274
        </body>
 
275
      </method>
 
276
 
 
277
      <method name="ShowRulers">
 
278
        <parameter name="show" />
 
279
        <body>
 
280
        <![CDATA[
 
281
          if (show)
 
282
          {
 
283
            this.mHRulerRow.setAttribute("collapsed", false);
 
284
            this.mVRulerColumn.setAttribute("collapsed", false);
 
285
          }
 
286
          else
 
287
          {
 
288
            this.mHRulerRow.setAttribute("collapsed", true);
 
289
            this.mVRulerColumn.setAttribute("collapsed", true);
 
290
          }
 
291
        ]]>
 
292
        </body>
 
293
      </method>
 
294
 
 
295
      <method name="showCurrentTabAsModified">
 
296
        <parameter name="val" />
 
297
        <body>
 
298
        <![CDATA[
 
299
          if (val)
 
300
            this.selectedTab.setAttribute("modified", "true");
 
301
          else
 
302
            this.selectedTab.removeAttribute("modified");
 
303
        ]]>
 
304
        </body>
 
305
      </method>
 
306
 
 
307
      <method name="_prepareForNewEditor">
 
308
        <body>
 
309
        <![CDATA[
 
310
          var selectedEditor = this.selectedPanel;
 
311
          selectedEditor.removeAttribute("id");
 
312
        ]]>
 
313
        </body>
 
314
      </method>
 
315
 
 
316
      <method name="SelectTabEditor">
 
317
        <body>
 
318
        <![CDATA[
 
319
          //~ GetCurrentEditingSession().setEditorOnControllers(window.content, GetCurrentEditor());
 
320
          // <Kaze> this line above creates a bug when the last tab is closed
 
321
          try {
 
322
            GetCurrentEditingSession().setEditorOnControllers(window.content, GetCurrentEditor());
 
323
          } catch(e) {}
 
324
          // </Kaze>
 
325
          var current = this.selectedPanel;
 
326
          this.setContentFrameId(current);
 
327
 
 
328
          window.UpdateWindowTitle();
 
329
 
 
330
          window.updateCommands("save");
 
331
          window.updateCommands("undo");
 
332
          window.updateCommands("select");
 
333
          window.updateCommands("style");
 
334
          window.goUpdateCommand("cmd_dtdStrictness");
 
335
          window.goUpdateCommand("cmd_dtdStrictness2");
 
336
 
 
337
          if (current.hasAttribute("displaymode"))
 
338
            window.SetEditMode(current.getAttribute("displaymode"));
 
339
          else
 
340
            window.SetEditMode(0);
 
341
          if (current.getAttribute("blockoutlines"))
 
342
            window.document.getElementById("blockOutlines").setAttribute("checked", true);
 
343
          else
 
344
            window.document.getElementById("blockOutlines").removeAttribute("checked");
 
345
        ]]>
 
346
        </body>
 
347
      </method>
 
348
 
 
349
      <method name="_newEditor">
 
350
        <body>
 
351
        <![CDATA[
 
352
          var newe = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "editor");
 
353
          newe.setAttribute("type",    "content-primary");
 
354
          newe.setAttribute("id",      "content-frame");
 
355
          newe.setAttribute("flex",    "1");
 
356
          newe.setAttribute("tooltip", "aHTMLTooltip");
 
357
          newe.setAttribute("context", "editorContentContext");
 
358
 
 
359
          return newe;
 
360
        ]]>
 
361
        </body>
 
362
      </method>
 
363
 
 
364
      <method name="_stopThrobber">
 
365
        <parameter name="aTab" />
 
366
        <body>
 
367
        <![CDATA[
 
368
          aTab.removeAttribute("busy");
 
369
        ]]>
 
370
        </body>
 
371
      </method>
 
372
 
 
373
      <method name="setContentFrameId">
 
374
        <parameter name="editorElement" />
 
375
        <body>
 
376
        <![CDATA[
 
377
          var elt = this.mTabpanels.firstChild;
 
378
          while (elt)
 
379
          {
 
380
            if (elt != editorElement)
 
381
            {
 
382
              elt.removeAttribute("id");
 
383
              elt.blur();
 
384
            }
 
385
            elt = elt.nextSibling;
 
386
          }
 
387
          editorElement.setAttribute("id", "content-frame");
 
388
        ]]>
 
389
        </body>
 
390
      </method>
 
391
 
 
392
      <method name="stopWebNavigation">
 
393
        <parameter name="notifyOnly" />
 
394
        <body>
 
395
        <![CDATA[
 
396
          if(!notifyOnly)
 
397
            GetCurrentEditorElement().webNavigation.stop(
 
398
                Components.interfaces.nsIWebNavigation.STOP_ALL);
 
399
 
 
400
          if (this.endNavigationCallback)
 
401
          {
 
402
            this.endNavigationCallback();
 
403
            if (this.mCurrentLoadedTab)
 
404
            {
 
405
              this._stopThrobber(this.mCurrentLoadedTab);
 
406
              this.mCurrentLoadedTab = null;
 
407
            }
 
408
            this.endNavigationCallback = null;
 
409
          }
 
410
        ]]>
 
411
        </body>
 
412
      </method>
 
413
 
 
414
      <method name="_editURL">
 
415
        <parameter name="editorElement" />
 
416
        <parameter name="url" />
 
417
        <parameter name="newEditor" />
 
418
        <parameter name="tabIndex" />
 
419
        <parameter name="template" />
 
420
        <parameter name="fromTemplate" />
 
421
        <body>
 
422
        <![CDATA[
 
423
          function nsLDBBrowserContentListener(boundElt, aStopCallback, aTab, aIsTemplate, aIsFromTemplate)
 
424
          {
 
425
            this.init(boundElt, aStopCallback, aTab, aIsTemplate, aIsFromTemplate);
 
426
          }
 
427
 
 
428
          nsLDBBrowserContentListener.prototype = {
 
429
 
 
430
            init : function(aBoundElt, aStopCallback, aTab, aIsTemplate, aIsFromTemplate)
 
431
              {
 
432
                this.mBoundElt       = aBoundElt;
 
433
                this.mStopCallback   = aStopCallback;
 
434
                this.mTab            = aTab;
 
435
                this.mIsTemplate     = aIsTemplate;
 
436
                this.mIsFromTemplate = aIsFromTemplate;
 
437
              },
 
438
 
 
439
            QueryInterface : function(aIID)
 
440
              {
 
441
                if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
 
442
                    aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
 
443
                    aIID.equals(Components.interfaces.nsISupports))
 
444
                  return this;
 
445
                throw Components.results.NS_NOINTERFACE;
 
446
              },
 
447
 
 
448
            // nsIWebProgressListener implementation
 
449
            onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
 
450
              {
 
451
                if (aStateFlags == 0xc0010 && !aStatus)
 
452
                {
 
453
                  this.mStopCallback(this.mTab);
 
454
                  if (this.mBoundElt)
 
455
                    this.mBoundElt.stopWebNavigation(true);
 
456
 
 
457
                  var e = GetCurrentEditor();
 
458
                  var d = e.document.documentElement;
 
459
                  if (d)
 
460
                  {
 
461
                    var b = e.document.getElementsByTagName("body").item(0);
 
462
                    b._editor = GetCurrentEditorElement();
 
463
                  }
 
464
 
 
465
                  // Are we trying to import a template from DW ?
 
466
                  var URL = null;
 
467
                  try {
 
468
                    var URL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURL);
 
469
                    URL.spec = url;
 
470
                  } catch (e) {
 
471
                  }
 
472
 
 
473
                  // is the new document a template ?
 
474
                  if (template)
 
475
                  {
 
476
                    if (d) {
 
477
                      d.setAttribute("template", "true");
 
478
                    }
 
479
                  }
 
480
                  else if (fromTemplate)
 
481
                  {
 
482
                    e instanceof Components.interfaces.nsIHTMLTemplateEditor;
 
483
                    e.isDocumentBasedOnTemplate = true;
 
484
                    if (d) {
 
485
                      d.removeAttribute("template");
 
486
                      d.setAttribute("templateref", url);
 
487
 
 
488
                      SetDocumentURI(GetIOService().newURI("about:blank", e.documentCharacterSet, null));
 
489
                      UpdateWindowTitle();
 
490
                      e.resetModificationCount();
 
491
                    }
 
492
                  }
 
493
                  else
 
494
                    WarnIfDocumentIsTemplate();
 
495
                }
 
496
              },
 
497
 
 
498
            onProgressChange : function(aWebProgress, aRequest,
 
499
                                        aCurSelfProgress, aMaxSelfProgress,
 
500
                                        aCurTotalProgress, aMaxTotalProgress)
 
501
              {
 
502
              },
 
503
 
 
504
            onLocationChange : function(aWebProgress, aRequest, aLocation)
 
505
              {
 
506
              },
 
507
 
 
508
            onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
 
509
              {
 
510
              },
 
511
 
 
512
            onSecurityChange : function(aWebProgress, aRequest, aState)
 
513
              {
 
514
              },
 
515
 
 
516
              mStopCallback   : null,
 
517
              mTab            : null,
 
518
              mBoundElt       : null,
 
519
              mIsTemplate     : false,
 
520
              mIsFromTemplate : false
 
521
          };
 
522
 
 
523
          // first, add the editor to the panels' list
 
524
          var tabAlreadyDisplayed = true;
 
525
 
 
526
          //this.setContentFrameId(editorElement);
 
527
 
 
528
          if (newEditor)
 
529
          {
 
530
            this.mTabpanels.appendChild(editorElement);
 
531
 
 
532
            // then create a new tab
 
533
            var newTab = this.mTabs.appendItem("(" + window.GetString("untitled") + ")", url);
 
534
            newTab.setAttribute("busy",     "true");
 
535
            newTab.setAttribute("maxwidth", "200");
 
536
            newTab.setAttribute("width",    "0");
 
537
            newTab.setAttribute("minwidth", "30");
 
538
            newTab.setAttribute("flex",     "100");
 
539
            newTab.setAttribute("crop",     "end");
 
540
 
 
541
            // select that new tab
 
542
            this.selectedTab = newTab;
 
543
 
 
544
            // and finish the whole thing making the editor editable
 
545
            editorElement.makeEditable("html", true);
 
546
            window.document.getElementById("blockOutlines").removeAttribute("checked");
 
547
          }
 
548
          else
 
549
          {
 
550
            if (this.selectedIndex != tabIndex)
 
551
            {
 
552
              this.selectedIndex = tabIndex;
 
553
              tabAlreadyDisplayed = false;
 
554
            }
 
555
            newTab = this.selectedTab;
 
556
            newTab.setAttribute("busy",     "true");
 
557
          }
 
558
 
 
559
          editorElement.addEventListener("DOMTitleChanged", this.changeTabTitle, false);
 
560
 
 
561
          var docShell = editorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).docShell;
 
562
          var progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);
 
563
          gProgressListener = new nsLDBBrowserContentListener(this, this._stopThrobber, newTab, template, fromTemplate);
 
564
          this.mCurrentLoadedTab = newTab;
 
565
 
 
566
          progress.addProgressListener(gProgressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
 
567
          if (newEditor)
 
568
          {
 
569
            EditorSharedStartup();
 
570
            SetupComposerWindowCommands();
 
571
          }
 
572
          // making the editor load the document now
 
573
          window.EditorLoadUrl(url);
 
574
          // window.focus();
 
575
          window.SetSaveAndPublishUI(url);
 
576
          if (!tabAlreadyDisplayed)
 
577
            SelectTabEditor();
 
578
        ]]>
 
579
        </body>
 
580
      </method>
 
581
 
 
582
      <method name="changeTabTitle">
 
583
        <parameter name="evt" />
 
584
        <body>
 
585
        <![CDATA[
 
586
          var e     = evt.currentTarget;
 
587
          var title = evt.target.title;
 
588
 
 
589
          if (!e.getEditor(e.contentWindow) && !title)
 
590
            return;
 
591
 
 
592
          var tabbox = this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
 
593
          var editors = this.parentNode.childNodes;
 
594
          var i, l = editors.length;
 
595
          for (i=0; i<l; i++)
 
596
          {
 
597
            if (editors.item(i) == e)
 
598
            {
 
599
              var tab = tabbox.mTabs.childNodes.item(i);
 
600
              tab.label = title;
 
601
              return;
 
602
            }
 
603
          }          
 
604
        ]]>
 
605
        </body>
 
606
      </method>
 
607
      
 
608
 
 
609
      <method name="_checkIfUrlIsAlreadyEdited">
 
610
        <parameter name="url" />
 
611
        <body>
 
612
        <![CDATA[
 
613
          // always accept a new blank document
 
614
          if (IsUrlAboutBlank(url))
 
615
            return null;
 
616
 
 
617
          // TBD : check all editor windows
 
618
          var editors = this.mTabpanels.childNodes;
 
619
          var i, l = editors.length;
 
620
          for (i=0; i< l; i++)
 
621
          {
 
622
            var e = editors[i];
 
623
            var elt = e.getEditor(e.contentWindow);
 
624
            if (elt && elt.document.URL == url)
 
625
              return e;
 
626
          }
 
627
          return null;
 
628
        ]]>
 
629
        </body>
 
630
      </method>
 
631
 
 
632
      <!-- Kaze: I've changed this method and made it public, to call it from editPage() -->
 
633
      <method name="checkIfUrlIsAlreadyEdited">
 
634
        <parameter name="url" />
 
635
        <body>
 
636
        <![CDATA[
 
637
          // always accept a new blank document
 
638
          if (IsUrlAboutBlank(url))
 
639
            return null;
 
640
 
 
641
          // TBD : check all editor windows
 
642
          var editors = this.mTabpanels.childNodes;
 
643
          var i, l = editors.length;
 
644
          for (i=0; i<l; i++)
 
645
          {
 
646
            var e = editors[i];
 
647
            var elt = e.getEditor(e.contentWindow);
 
648
            //~ if (elt && elt.document.URL == url) { // Kaze: bugfix
 
649
            if (elt && unescape(elt.document.URL) == unescape(url)) {
 
650
              this.selectedIndex = i;   // Kaze: bugfix
 
651
              this.stopWebNavigation(); // Kaze: bugfix
 
652
              window.UpdateWindowTitle();
 
653
              return e;
 
654
            }
 
655
          }
 
656
          return null;
 
657
        ]]>
 
658
        </body>
 
659
      </method>
 
660
 
 
661
      <method name="editURL">
 
662
        <parameter name="url" />
 
663
        <parameter name="newTab" />
 
664
        <parameter name="template" />
 
665
        <parameter name="fromTemplate" />
 
666
        <body>
 
667
        <![CDATA[
 
668
          //~ var edited = this._checkIfUrlIsAlreadyEdited(url);
 
669
          var edited = this.checkIfUrlIsAlreadyEdited(url);
 
670
          SetEditMode(kDisplayModeNormal); // Kaze: bugfix
 
671
          if (!edited)
 
672
          {
 
673
            if (!newTab)
 
674
            {
 
675
              // let's see if we can reuse an empty tab
 
676
              var reusableEditor = null;
 
677
              var reusableEditorIndex = -1;
 
678
              var editors = this.mTabpanels.childNodes;
 
679
              var i, l = editors.length;
 
680
              for (i=0; i< l; i++)
 
681
              {
 
682
                var e = editors[i];
 
683
                var elt = e.getEditor(e.contentWindow);
 
684
                if (elt && elt.documentIsEmpty && !elt.documentModified && !window.IsHTMLSourceChanged())
 
685
                {
 
686
                  reusableEditor      = e;
 
687
                  reusableEditorIndex = i;
 
688
                  break;
 
689
                }
 
690
              }
 
691
            }
 
692
            if (newTab || !reusableEditor)
 
693
            {
 
694
              this._prepareForNewEditor();
 
695
              var newEditor = this._newEditor();
 
696
              this._editURL(newEditor, url, true, 0, template, fromTemplate);
 
697
              window.content.focus();
 
698
              return newEditor;
 
699
            }
 
700
            this._editURL(reusableEditor, url, false, reusableEditorIndex, template, fromTemplate);
 
701
            window.content.focus();
 
702
            return reusableEditor;
 
703
          }
 
704
          
 
705
          // give focus to that editor
 
706
          this.selectedPanel = edited;
 
707
          return edited;
 
708
        ]]>
 
709
        </body>
 
710
      </method>
 
711
      <method name="newBlankTab">
 
712
        <parameter name="type" />
 
713
        <parameter name="strictness" />
 
714
        <body>
 
715
          <![CDATA[
 
716
            if (type == "xhtml")
 
717
              return this.editURL(strictness ? "about:xstrictblank" : "about:xblank",
 
718
                                  true, false, false);
 
719
 
 
720
            return this.editURL(strictness ? "about:strictblank" : "about:blank",
 
721
                                true, false, false);
 
722
          ]]>
 
723
        </body>
 
724
      </method>
 
725
      <method name="newTemplateTab">
 
726
        <body>
 
727
          <![CDATA[
 
728
            return this.editURL("about:blank", true, true, false);
 
729
          ]]>
 
730
        </body>
 
731
      </method>
 
732
      <method name="getCurrentEditorElement">
 
733
        <body>
 
734
          <![CDATA[
 
735
            return this.selectedPanel;
 
736
          ]]>
 
737
        </body>
 
738
      </method>
 
739
 
 
740
    </implementation>
 
741
      
 
742
    <handlers>
 
743
      <handler event="DOMAttrModified" phase="target">
 
744
        <![CDATA[
 
745
        var attrName = event.attrName.toLowerCase();
 
746
        var oldValue = event.prevValue.toLowerCase();
 
747
        var newValue = event.newValue.toLowerCase();
 
748
 
 
749
        // only if a new value is specified
 
750
        if (oldValue != newValue && newValue) {
 
751
          if (attrName == "collapserulers") {
 
752
            ShowRulers(!(newValue == "true"));
 
753
          }
 
754
        }
 
755
        ]]>
 
756
      </handler>
 
757
 
 
758
    </handlers>
 
759
 
 
760
  </binding>
 
761
 
 
762
  
 
763
</bindings>