google-closure

Google Closure and generated getters/setters

谁说我不能喝 提交于 2020-01-04 02:34:06
问题 I'm trying to get KineticJS to work with Google Closure Compiler. KineticJS, however, generated it's getters & setters based on the name of the variables. Something like this: // add getter and setter methods Kinetic.Node.addSetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addSetter(constructor, attr); } }; Kinetic.Node.addGetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addGetter

How to auto-generate externs for the Google Closure Compiler

﹥>﹥吖頭↗ 提交于 2020-01-01 04:30:08
问题 Suppose you are working in a javascript project with several external library dependencies, and want to compile your sources using the Google Closure Compiler in ADVANCED_OPTIMIZATIONS mode. Since in this mode the compiler will rename your code calls to the external libraries objects and functions, you must provide externs, to prevent this renaming from happening. But, it is a lot of work to produce the externs by hand, so, what is the best way to auto-generate the appropriate extern from a

Google Closure and Chrome packaged apps: compatibility?

*爱你&永不变心* 提交于 2019-12-25 01:44:35
问题 I am using Google Closure and and I am trying to make a Chrome packaged app. My call to goog.require causes an error: Uncaught document.write() is not available in packaged apps. The culprit is in base.js goog.writeScriptTag_ = function(src) { if (goog.inHtmlDocument_()) { var doc = goog.global.document; // If the user tries to require a new symbol after document load, // something has gone terribly wrong. Doing a document.write would // wipe out the page. if (doc.readyState == 'complete') {

How to have a type in Closure Compiler externs without a constructor

雨燕双飞 提交于 2019-12-24 15:58:34
问题 I am trying to make externs for the Google Closure Compiler for types that have no constructor. I have tried the following, but it gives me a Bad type annotation. Unknown type WindowsMediaActiveX.Cdrom error because nothing tells the compiler that WindowsMediaActiveX.Cdrom is a type instead of just a collection of methods/properties. /** * @fileoverview Declares externs for the Windows media player ActiveX control. * @author Joshua Dwire * @suppress {duplicate} */ var WindowsMediaActiveX={};

Calling onclick with local variable

耗尽温柔 提交于 2019-12-24 13:17:12
问题 First, apologies for asking something that must be answered here somewhere (I've been looking!) I want to do this: var i; for (i = 0; i < 5; i++) { ... // Add an anchor to the dom ... a.onclick = goog.bind(this.doSomething, this); ... } namespace.Clazz.prototype.doSomething = function(event, index) { console.log('index: ' + index); } I want 5 anchors the each pass a different value for i to doSomething when clicked (along with the click event). I also want to keep the context of this in

Using Google Closure Templates with jQuery

风格不统一 提交于 2019-12-23 10:09:04
问题 We are starting to create an application using JavaScript and HTML5 which will use rest API to access server resources taking the advantage of jQuery awesomeness and easiness which our dev team is already comfortable with. This application is going to be made multilingual. We had decided later that we will write our DOM using JavaScript which will allow us the flexibility to use our UI bits for integration with our other applications and will create our own widgets using jQuery UI widgets.

Why does Google Closure Compiler adds variable to the global namespace when the original namespace was empty?

只愿长相守 提交于 2019-12-22 09:12:07
问题 I have a long script nicely wrapped into a (function() {/.../})() to avoid all kind of name pollution. It is 100% typed with zero warning. I found out that Google Closure compiler starts by redefining i and j in the global namespace which feels both unnecessary and dangerous, especially since I am compiling a script that has zero interference with the namespace. (the compiled script starts with var i=null,j=!1; , for compactness reasons I believe). I can think of a work around which is to

Google Closure event delegation a'la jQuery live/on

雨燕双飞 提交于 2019-12-22 08:18:17
问题 I need to delegate event to newly created elements, I need to attach handler to their creation event. Something similar to: onCreate I do not want to bind the event to the element after the creation by addressing it: jQuery: $(element).click(function(){}); I would prefer something like $.on('document','spawn', '.item', function(e) { if (e.target == this.target) { alert('element created: '+this); } }); Is there a way to do so in google closure? the goal is to attach the event on creating and

Google Closure decompiler?

試著忘記壹切 提交于 2019-12-21 22:21:49
问题 I was looking for a way to decompile JavaScript that was compiled by Google Closure. I did find a Decompiler class (https://code.google.com/p/closure-compiler/source/browse/lib/rhino/src/org/mozilla/javascript/Decompiler.java?name=v20140407), however I haven't had much luck with it. Anyone try this before or know of some other method? 回答1: Usually, I just run the code through the Closure Compiler in WHITESPACE mode and enable the pretty printing options. 来源: https://stackoverflow.com

How do I add my own JavaScript libs to ClojureScript?

雨燕双飞 提交于 2019-12-21 09:06:12
问题 I want to write a Google Chrome extension, using ClojureScript. With ClojureScript I can use all the Google Closure libs, but afaik access to the Chrome browser is not included in those libs. So I want to wrap all the Chrome stuff in my own JavaScript lib. So far I tried creating my own jar that has a single JavaScript file that just creates a Foo object and exports the constructor. I'v added this jar to the lib directory of the ClojureScript compiler (which also has for example goog.jar),