home *** CD-ROM | disk | FTP | other *** search
- /**
- * toolbar.js
- * by gary smith July 1997
- * for sample code (still under construction)
- * see also menubar.js
- */
-
- function ToolBar() {
- this.cToolBarParentLayer = null;
- this.cToolBarBgColor = '#C1CDCD'; //CDB79E
- this.prev = null;
- this.countItems = 0;
- this.items = new Array();
-
- this.addToolBarItem = addToolBarItem;
- this.moveToolBarItem = moveToolBarItem;
- this.moveToolBar = moveToolBar;
- this.onToolBar = onToolBar;
- this.resizeToolBar = resizeToolBar;
- this.cToolBarShow = cToolBarShow;
- this.setCToolBarLeft = setCToolBarLeft;
- this.setCToolBarTop = setCToolBarTop;
- this.setCToolBarWidth = setCToolBarWidth;
- this.setCToolBarHeight = setCToolBarHeight;
- this.setCToolBarBgColor = setCToolBarBgColor;
- this.setCToolBarParentLayer = setCToolBarParentLayer;
- }
-
- function cToolBarShow(p, width, height) {
- var p = p || this.cToolBarParentLayer;
- width = width || window.innerWidth || 100;
- height = height || 40;
- this.bar = makeLayer('m', ' ', p, width, height, 0,0, '#000000');
- this.barWidth = this.bar.clip.width;
- this.bar.clip.height += 3;
- this.barHeight = this.bar.clip.height;
- //this.bar.onFocus = resizeToolBar;
- this.bar.shadow = makeLayer('m', ' ', this.bar, this.barWidth -1, this.barHeight -1, 0,0, '#888888');
- this.bar.lite = makeLayer('m', ' ', this.bar, this.barWidth -2, this.barHeight -2, 0,0, '#EEEEEE');
- this.bar.gray = makeLayer('m', ' ', this.bar, this.barWidth -3, this.barHeight -3, 1,1, this.cToolBarBgColor);
- this.bar.gray.onFocus = onToolBar;
- this.bar.gray.ToolBar = true;
- }
-
- function addToolBarItem(label, label_focus, action) {
- if(label_focus.indexOf(" HREF") == -1) label_focus = '<A HREF="#">' + label_focus + '</A>';
- if(label.indexOf("<DIV ID") == -1) {
- label = '<NOBR><DIV ID=sysFont>' + label + '</DIV></NOBR>';
- label_focus = '<NOBR><DIV ID=sysFont>' + label_focus + '</DIV></NOBR>';
- }
- //java.lang.System.out.println("label=" + label);
- var item = makeLayer('label', label, this.bar, 0,0, 1,1, "", "hide");
- item.focus = makeLayer('label_focus', label_focus, this.bar, 0,0, 1,1, "", "hide");
- item.label = label;
- item.bar = this.bar;
- item.focus.ref = item;
- if(this.items[this.countItems -1])
- item.left = this.items[this.countItems -1].left + this.items[this.countItems -1].clip.width +5;
- item.focus.left = item.left;
- item.visibility = 'inherit';
- item.focus.visibility = 'hide';
- item.onMouseOver = onToolBarItem_MouseOver;
- item.focus.onMouseOut = onToolBarItem_MouseOut;
- //item.focus.captureEvents(Event.MOUSEDOWN);
- //item.focus.onmousedown = this.onToolBar;
- item.onFocus = this.onToolBar;
- if(action) item.focus.onFocus = this.onToolBar;
- item.focus.action = action;
- //item.clip.width = document.width || top.width || 100;
- item.ref = this;
- if(item.menuLayer) item.menuLayer = item.menuLayer;
- //this.bar.clip.width += item.clip.width;
- this.items[item] = item;
- this.items[this.countItems] = item;
- this.countItems++;
- }
-
- function onToolBarItem_MouseOver(e) {
- //if(window.nsToolBarActive) return;
- if(window.activeToolBarItem) window.activeToolBarItem.visibility = "hide";
- //this.visibility = "hide";
- this.focus.visibility = "inherit";
- //this.focus.bgColor = "#0000FF";
- onToolBar(e,this);
- window.activeToolBarItem = this.focus;
- }
-
- function onToolBarItem_MouseOut(e) {
- //this.bgColor = "#BEBEBE";
- this.visibility = "hide";
- //this.dark.visibility = "inherit";
- //window.activeToolBarItem = this;
- }
-
- function onToolBar(e,lyr) {
- //java.lang.System.out.println("e.target.name=" + e.target.name);
- //java.lang.System.out.println("lyr=" + lyr);
-
- if(!lyr) {
- var l = this;
- //if(window.nsActiveMenu) window.nsActiveMenu.visibility = 'hide';
- if(window.activeToolBarItem) window.activeToolBarItem.visibility = "hide";
- //l.visibility = 'hide';
- if(l.action) eval( l.action );
- if(l.ToolBar) return;
- //window.nsToolBarActive = true;
- } else {
- var l = lyr;
- }
- if(l.menuLayer) {
- l.menuLayer.left = l.left + l.bar.left;
- l.menuLayer.top = l.top + l.clip.height + l.bar.top;
- l.menuLayer.visibility = 'inherit';
- }
-
- }
-
-
- function moveToolBarItem(item, x, y) {
- if(typeof(item) == 'string') {
- //alert(this.items[item]);
- item = this.items[item];
- }
- if(x) {
- item.left = x;
- item.focus.left = x;
- }
- if(y) {
- item.top = y;
- item.focus.top = y;
- }
- }
-
- function moveToolBar(x,y) {
- this.bar.left = x;
- this.bar.top = y;
- //if(l.bar) {
- //java.lang.System.out.println("this=" + this.items.length);
- //l.menuLayer.left = l.bar.left;
- //l.menuLayer.top = l.bar.top;
- //}
- }
-
- function resizeToolBar(w, h) {
- if(w) {
- this.bar.clip.width = w;
- this.bar.shadow.clip.width = w -1;
- this.bar.lite.clip.width = w -2;
- this.bar.gray.clip.width = w -3;
- }
- if(h) {
- this.bar.clip.height = h;
- this.bar.shadow.clip.height = h -1;
- this.bar.lite.clip.height = h -2;
- this.bar.gray.clip.height = h -3;
- }
- }
-
- function setCToolBarBgColor(str) {
- this.cToolBarBgColor = str;
- }
- function setCToolBarParentLayer(l) {
- this.cToolBarParentLayer = l;
- }
- function setCToolBarLeft(i) {
- this.cToolBarLeft = i;
- }
- function setCToolBarTop(i) {
- this.cToolBarTop = i;
- }
- function setCToolBarWidth(i) {
- this.cToolBarWidth = i;
- }
- function setCToolBarHeight(i) {
- this.cToolBarHeight = i;
- }
-
- function makeLayer(label, content, parentLyr, width, height, x, y, color, viso) {
- //java.lang.System.out.println(""+ parentLyr);
- if(!content) content = " ";
- if(parentLyr) var l = new Layer(width, parentLyr);
- else var l = new Layer(width);
- l.document.ids.font14.fontSize = 14;
- l.document.ids.sysFont.fontSize = 12;
- l.document.ids.sysFont.fontFamily = "Arial, Espy, sans-serif";
- l.document.open("text/html");
- l.document.writeln(content);
- l.document.close();
- l.label = label;
- l.moveTo(x,y);
- if(color != "") l.bgColor = color;
- if(width) l.clip.width = width;
- if(height) l.clip.height = height;
- if(!viso) l.visibility = "inherit";
- return l;
- }