我在导轨4.2.2上使用ruby,使用gem foundation-rails 6.1.2。 我已经在文档中安装了所有内容,现在尝试制作简单的显示模式窗口,就像在基础文档here
中一样我已经导入了动作ui,但它仍然不起作用。这是苗条的代码:
public class JarFileClassTransformer implements ClassFileTransformer {
private String jarFileName = null;
protected Map<String, InputStream> classNames = new HashMap<>();
static Instrumentation instrumentation = null;
/**
* Constructor.
* @param jarFileName
*/
public JarFileClassTransformer(String jarFileName) {
this.jarFileName = jarFileName;
File file = new File(jarFileName);
System.out.println("Jar file '" + this.jarFileName + "' " + (file.exists() ? "exists" : "doesn't exists!"));
if(file.exists()) {
try {
JarFile jarFile = new JarFile(file);
Enumeration e = jarFile.entries();
while (e.hasMoreElements()) {
JarEntry je = (JarEntry) e.nextElement();
if(je.isDirectory() || !je.getName().endsWith(".class")){
continue;
}
// -6 because of .class
String jarClassName = je.getName().substring(0,je.getName().length()-6);
jarClassName = jarClassName.replace('/', '.');
System.out.println("Adding class " + jarClassName);
this.classNames.put(jarClassName, jarFile.getInputStream(je));
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
if(classNames.containsKey(className.replace("/", "."))) {
System.out.format("\n==> Found %s to replace with the existing version\n", className);
try {
Class c = loader.loadClass(className.replace("/", "."));
System.out.println("Existing class: " + c);
InputStream is = classNames.get(className.replace("/", "."));
byte[] content = new byte[is.available()];
is.read(content);
System.out.println("Original class version: " + ((classfileBuffer[6]&0xff)<<8 | (classfileBuffer[7]&0xff)));
System.out.println("Redefined class version: " + ((content[6]&0xff)<<8 | (content[7]&0xff)));
System.out.println("Original bytecode: " + new String(classfileBuffer));
System.out.println("Redefined byte code: " + new String(content));
ClassDefinition cd = new ClassDefinition(c, content);
instrumentation.redefineClasses(cd);
return content;
} catch (Throwable e) {
e.printStackTrace();
}
}
return classfileBuffer;
}
链接本身打开模态:
.reveal#exampleModal1 data-reveal='data-reveal'
h1 Awesome. I Have It.
p.lead Your couch. It is mine.
p I'm a cool paragraph that lives inside of an even cooler modal. Wins!
button.close-button data-close="data-close" aria-label="Close modal" type="button"
span aria-hidden="true"×
所以模态是开放的,但第一次打开时有奇怪的风格。它太宽(内联样式被添加到模态中)并且关闭按钮不会关闭模态。如果我通过单击模态或ESQ外部关闭模态 - 它已关闭。第二次打开显示时,它的正确宽度为600px(控制台中的样式窗格显示现在样式来自某些css文件)。但关闭按钮仍然不起作用。
我做错了什么?有任何想法吗?谢谢