Exemple #1
0
void JSlot::setJavaScript(const std::string& js)
{
    if (widget_)
        WApplication::instance()->declareJavaScriptFunction(jsFunctionName(), js);
    else
        imp_->setJavaScript("{var f=" + js + ";f(o,e);}");
}
Exemple #2
0
void WJavascriptSlot::setJavascript(const std::string& imp)
{
  if (widget_)
    widget_->webWidget()->setScript(jsFunctionName(), imp);
  else
    imp_->setJavaScript(imp);
}
Exemple #3
0
WJavascriptSlot::WJavascriptSlot(WWidget *parent)
  : widget_(parent),
    fid_(nextFid_++)
{
  imp_ = new WStatelessSlot(parent, widget_ ? "return " + jsFunctionName()
			    + "(this, event);" : "return false;");
}
Exemple #4
0
void JSlot::create()
{
    imp_ = new WStatelessSlotImpl
    (widget_, 0, widget_
     ? WApplication::instance()->javaScriptClass()
     + '.' + jsFunctionName() + "(o,e);"
     : "");
}
Exemple #5
0
void JSlot::create()
{
  std::stringstream ss;

  if (widget_) {
    WApplication *app = WApplication::instance();
    if (app) {
      ss << WApplication::instance()->javaScriptClass() << "."
	 << jsFunctionName() << "(o,e";
      for (int i = 1; i <= nbArgs_; ++i) {
	ss << ",a" << i;
      }
      ss << ");";
    }
  }

  imp_ = new WStatelessSlotImpl(widget_, 0, ss.str());
}
Exemple #6
0
void JSlot::setJavaScript(const std::string& js, int nbArgs)
{
  if (nbArgs < 0 || nbArgs > 6) {
    throw WException("The number of arguments given must be between 0 and 6.");
  }
  nbArgs_ = nbArgs;
  WApplication *app = WApplication::instance();
  if (widget_ && app)
    WApplication::instance()->declareJavaScriptFunction(jsFunctionName(), js);
  else {
    std::stringstream ss;
    ss << "{var f=" << js << ";return f(o,e";
    for (int i = 1; i <= nbArgs; ++i) {
      ss << ",a" << i;
    }
    ss << ");}";
    imp_->setJavaScript(ss.str());
  }
}