2

I am learning how to make a menu bar using Google Closure libraries via this example.

http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/menubar.html

However, when I try out the code in my own application, the Plovr compiler complains that no file provides goog.ui.menuBar. Is goog.ui.menuBar part of the Closure library or is there a plugin/extension that I must download to use it?

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117
dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206

1 Answers1

3

The copy of Closure Library embedded in the February 8, 2012 release of plovr [hg revision 4b3caf2b7d84] uses Closure Library revision 1559, which is dated February 2, 2012.

The menubar widget was introduced in Closure Library revision 1947, dated June 4, 2012. Fortunately, you can download the latest version of the Closure Library and have plovr use the latest copy as follows:

plovr_config.json

{
  "id": "myapp",
  "inputs": [
    "/home/my_project/js/myapp.js"
  ],
  "closure-library": "/path/to/closure-library/closure/goog",
  "mode": "ADVANCED",
  "level": "VERBOSE",
  "output-file": "/home/my_project/build/myapp.compiled.js"
}


Where is goog.ui.menuBar provided?

goog.ui.menuBar is provided in the Closure Library in closure/goog/ui/menubar.js.

Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117
  • Thanks! I wonder why `menuBar` is camel case though instead of Pascal case. – dangerChihuahua007 Aug 11 '12 at 23:39
  • 1
    The reason `menuBar` is camel case instead of Pascal case is because there is no constructor named `MenuBar`. Instead of using a constructor, menu bar instances are created using the factory function `goog.ui.menuBar.create(opt_renderer, opt_domHelper)`. – Christopher Peisert Aug 11 '12 at 23:47
  • An issue arises when I start adding in soy templates: Plovr claims that `soy` isn't provided anywhere. I subsequently added the `closure-templates` into my paths specification in config.js. However, Plovr then complains that `goog.debug.Error` is provided in 2 places. I might just download the file that provides `goog.ui.menuBar` and place it somewhere in my application directory instead of using another Closure installation... – dangerChihuahua007 Aug 12 '12 at 04:59
  • See the last two comments on [plovr issue 55](http://code.google.com/p/plovr/issues/detail?id=55&q=closure%20library&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Reporter). – Christopher Peisert Aug 12 '12 at 05:09