BookmarkPage

From CDOT Wiki
Revision as of 12:32, 29 September 2006 by Melz (talk | contribs)
Jump to: navigation, search

Bookmark > Bookmark This Page

 45 <dialog id="createbookmark" title="&bookmark.label;"
 46         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
 47         buttons="accept,cancel"
 48         ondialogaccept="return OnBookmarkOK()"
 49         onload="OnBookmarkLoad();"
 50         width="500"
 51         height="200"
 52         >
 53   <script src="chrome://cckwizard/content/cckwizard.js"/>
 54   <vbox>
 55     <label>&bookmark.description;</label>
 56     <label control="bookmarkname">&bookmarkTitle.label;</label>
 57     <textbox flex="1" id="bookmarkname" onchange="bookmarkCheckOKButton();" onkeyup="bookmarkCheckOKButton();"/>
 58     <label control="bookmarkurl">&bookmarkURL.label;</label>
 59     <textbox flex="1" id="bookmarkurl" onchange="bookmarkCheckOKButton();" onkeyup="bookmarkCheckOKButton();"/>
 60     <checkbox id="liveBookmark" label="Live Bookmark"/>
 61   </vbox>
 62 </dialog>

- Defines the the Add Bookmark dialog box.

538 function bookmarkCheckOKButton()
539 {
540   if ((document.getElementById("bookmarkname").value) && (document.getElementById("bookmarkurl").value)) {
541     document.documentElement.getButton("accept").setAttribute( "disabled", "false" );
542   } else {
543     document.documentElement.getButton("accept").setAttribute( "disabled", "true" );  
544   }
545 }

- Enable the OK button only if the bookmark name and URL is defined.

547 function OnBookmarkOK()
548 {
549 
550   listbox = this.opener.document.getElementById(getPageId() +'.bookmarkList');
551   var listitem;
552   if (window.name == 'newbookmark') {
553     listitem = listbox.appendItem(document.getElementById('bookmarkname').value, document.getElementById('bookmarkurl').value);
554     listitem.setAttribute("class", "listitem-iconic");
555   } else {
556     listitem = listbox.selectedItem;
557     listitem.setAttribute("label", document.getElementById('bookmarkname').value);
558     listitem.setAttribute("value", document.getElementById('bookmarkurl').value);
559   }
560   if (document.getElementById('liveBookmark').checked) {
561     listitem.cck['type'] = "live";
562     listitem.setAttribute("image", "chrome://browser/skin/page-livemarks.png");
563   } else {
564     listitem.setAttribute("image", "chrome://browser/skin/Bookmarks-folder.png");
565     listitem.cck['type'] = "";
566   }
567 }

- After you click OK,