1 19 20 package com.sslexplorer.core; 21 22 import java.awt.Rectangle ; 23 24 import com.sslexplorer.boot.Util; 25 26 27 33 public class WindowOpenJavascriptLink implements JavascriptLink { 34 35 private String uri; 37 private String windowId; 38 private Rectangle bounds; 39 private boolean resizable; 40 private boolean menuBar; 41 private boolean toolBar; 42 private boolean scrollBars; 43 private boolean location; 44 45 49 public WindowOpenJavascriptLink() { 50 this(null, null, null, false, false, false, false, false); 51 } 52 53 66 public WindowOpenJavascriptLink(String uri, String windowId, Rectangle bounds, 67 boolean resizable, boolean menuBar, boolean toolBar, boolean scrollBars, boolean location) { 68 this.uri = uri; 69 this.windowId = windowId; 70 this.bounds = bounds; 71 this.resizable = resizable; 72 this.menuBar = menuBar; 73 this.toolBar = toolBar; 74 this.scrollBars = scrollBars; 75 this.location = location; 76 } 77 78 83 public String getURI() { 84 return uri; 85 } 86 87 92 public String toJavascript() { 93 if(uri == null) { 94 return "void();"; 95 } 96 97 StringBuffer openBuf = new StringBuffer (); 98 openBuf.append("windowRef = window.open('"); 99 openBuf.append(Util.escapeForJavascriptString(uri)); 100 openBuf.append("','"); 101 openBuf.append(windowId); 102 openBuf.append("','"); 103 if(bounds != null) { 104 openBuf.append("top="); 105 openBuf.append(bounds.y); 106 openBuf.append(",left="); 107 openBuf.append(bounds.x); 108 openBuf.append(",width="); 109 openBuf.append(bounds.width); 110 openBuf.append(",height="); 111 openBuf.append(bounds.height); 112 openBuf.append(","); 113 } 114 openBuf.append("location="); 115 openBuf.append(location ? 1 : 0); 116 openBuf.append(",resizable="); 117 openBuf.append(resizable ? 1 : 0); 118 openBuf.append(",toolbar="); 119 openBuf.append(toolBar ? 1 : 0); 120 openBuf.append(",menubar="); 121 openBuf.append(menuBar ? 1 : 0); 122 openBuf.append(",scrollbars="); 123 openBuf.append(scrollBars ? 1 : 0); 124 openBuf.append("'); "); 125 126 StringBuffer buf = new StringBuffer (); 127 buf.append("this.blur(); "); 128 buf.append(openBuf.toString()); 129 buf.append("if(windowRef==null || typeof(windowRef)=='undefined') { "); 130 buf.append(" if(setPopupBlocked) { setPopupBlocked(); }"); 131 buf.append("} else { windowRef.focus(); }"); 132 return buf.toString(); 133 } 134 } 135 | Popular Tags |