fix closure compiler incompatibilities

This commit is contained in:
Misko Hevery 2010-01-24 19:12:01 -08:00
parent efad9ec5be
commit a5c446441f
6 changed files with 45 additions and 44 deletions

View file

@ -269,10 +269,10 @@ function exposeMethods(obj, methods){
function wireAngular(element, config) { function wireAngular(element, config) {
var widgetFactory = new WidgetFactory(config['server'], config['database']); var widgetFactory = new WidgetFactory(config['server'], config['database']);
var binder = new Binder(element[0], widgetFactory, datastore, config['location'], config); var binder = new Binder(element[0], widgetFactory, datastore, config['location'], config);
var controlBar = new ControlBar(element.find('body'), config.server); var controlBar = new ControlBar(element.find('body'), config['server']);
var onUpdate = function(){binder.updateView();}; var onUpdate = function(){binder.updateView();};
var server = config['database'] =="$MEMORY" ? var server = config['database'] =="$MEMORY" ?
new FrameServer(this.window) : new FrameServer(window) :
new Server(config['server'], jQuery['getScript']); new Server(config['server'], jQuery['getScript']);
server = new VisualServer(server, new Status(jQuery(element.body)), onUpdate); server = new VisualServer(server, new Status(jQuery(element.body)), onUpdate);
var users = new Users(server, controlBar); var users = new Users(server, controlBar);

View file

@ -1,7 +1,7 @@
function ControlBar(document, serverUrl) { function ControlBar(document, serverUrl) {
this.document = document; this._document = document;
this.serverUrl = serverUrl; this.serverUrl = serverUrl;
this.window = window; this._window = window;
this.callbacks = []; this.callbacks = [];
}; };
@ -39,25 +39,24 @@ ControlBar.prototype = {
}, },
urlWithoutAnchor: function (path) { urlWithoutAnchor: function (path) {
return this.window.location.href.split("#")[0]; return this._window['location']['href'].split("#")[0];
}, },
doTemplate: function (path) { doTemplate: function (path) {
var self = this; var self = this;
var id = new Date().getTime(); var id = new Date().getTime();
var url = this.urlWithoutAnchor(); var url = this.urlWithoutAnchor() + "#$iframe_notify=" + id;
url += "#$iframe_notify=" + id;
var iframeHeight = 330; var iframeHeight = 330;
var loginView = jQuery('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+ url +'" src="'+this.serverUrl + path + '" width="500" height="'+ iframeHeight +'"/></div>'); var loginView = jQuery('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+ url +'" src="'+this.serverUrl + path + '" width="500" height="'+ iframeHeight +'"/></div>');
this.document.append(loginView); this._document.append(loginView);
loginView.dialog({ loginView['dialog']({
height:iframeHeight + 33, width:500, 'height':iframeHeight + 33, 'width':500,
resizable: false, modal:true, 'resizable': false, 'modal':true,
title: 'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>' 'title': 'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'
}); });
angularCallbacks["_iframe_notify_" + id] = function() { angularCallbacks["_iframe_notify_" + id] = function() {
loginView.dialog("destroy"); loginView['dialog']("destroy");
loginView.remove(); loginView['remove']();
foreach(self.callbacks, function(callback){ foreach(self.callbacks, function(callback){
callback(); callback();
}); });

View file

@ -3,7 +3,7 @@ function Users(server, controlBar) {
this.controlBar = controlBar; this.controlBar = controlBar;
}; };
Users.prototype = { extend(Users.prototype, {
'fetchCurrentUser':function(callback) { 'fetchCurrentUser':function(callback) {
var self = this; var self = this;
this.server.request("GET", "/account.json", {}, function(code, response){ this.server.request("GET", "/account.json", {}, function(code, response){
@ -23,7 +23,7 @@ Users.prototype = {
'login': function(callback) { 'login': function(callback) {
var self = this; var self = this;
this.controlBar.login(function(){ this.controlBar.login(function(){
self.fetchCurrentUser(function(){ self['fetchCurrentUser'](function(){
(callback||noop)(); (callback||noop)();
}); });
}); });
@ -32,4 +32,4 @@ Users.prototype = {
'notAuthorized': function(){ 'notAuthorized': function(){
this.controlBar.notAuthorized(); this.controlBar.notAuthorized();
} }
}; });

View file

@ -2,8 +2,8 @@ function WidgetFactory(serverUrl, database) {
this.nextUploadId = 0; this.nextUploadId = 0;
this.serverUrl = serverUrl; this.serverUrl = serverUrl;
this.database = database; this.database = database;
if (window.swfobject) { if (window['swfobject']) {
this.createSWF = swfobject.createSWF; this.createSWF = window['swfobject']['createSWF'];
} else { } else {
this.createSWF = function(){ this.createSWF = function(){
alert("ERROR: swfobject not loaded!"); alert("ERROR: swfobject not loaded!");
@ -62,12 +62,12 @@ WidgetFactory.prototype = {
var view = FileController.template(uploadId); var view = FileController.template(uploadId);
fileInput.after(view); fileInput.after(view);
var att = { var att = {
data:this.serverUrl + "/admin/ServerAPI.swf", 'data':this.serverUrl + "/admin/ServerAPI.swf",
width:"95", height:"20", align:"top", 'width':"95", 'height':"20", 'align':"top",
wmode:"transparent"}; 'wmode':"transparent"};
var par = { var par = {
flashvars:"uploadWidgetId=" + uploadId, 'flashvars':"uploadWidgetId=" + uploadId,
allowScriptAccess:"always"}; 'allowScriptAccess':"always"};
var swfNode = this.createSWF(att, par, uploadId); var swfNode = this.createSWF(att, par, uploadId);
fileInput.remove(); fileInput.remove();
var cntl = new FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database); var cntl = new FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database);
@ -88,10 +88,12 @@ function FileController(view, scopeName, uploader, databaseUrl) {
this.lastValue = undefined; this.lastValue = undefined;
}; };
FileController.dispatchEvent = function(id, event, args) { angularCallbacks['flashEvent'] = function(id, event, args) {
var object = document.getElementById(id); var object = document.getElementById(id);
var controller = jQuery(object).data("controller"); var jobject = jQuery(object);
FileController.prototype['_on_' + event].apply(controller, args); var controller = jobject.data("controller");
FileController.prototype[event].apply(controller, args);
jobject.scope().get('$updateView')();
}; };
FileController.template = function(id) { FileController.template = function(id) {
@ -103,23 +105,23 @@ FileController.template = function(id) {
'</span>'); '</span>');
}; };
FileController.prototype = { extend(FileController.prototype, {
'_on_cancel': noop, 'cancel': noop,
'_on_complete': noop, 'complete': noop,
'_on_httpStatus': function(status) { 'httpStatus': function(status) {
alert("httpStatus:" + this.scopeName + " status:" + status); alert("httpStatus:" + this.scopeName + " status:" + status);
}, },
'_on_ioError': function() { 'ioError': function() {
alert("ioError:" + this.scopeName); alert("ioError:" + this.scopeName);
}, },
'_on_open': function() { 'open': function() {
alert("open:" + this.scopeName); alert("open:" + this.scopeName);
}, },
'_on_progress':noop, 'progress':noop,
'_on_securityError': function() { 'securityError': function() {
alert("securityError:" + this.scopeName); alert("securityError:" + this.scopeName);
}, },
'_on_uploadCompleteData': function(data) { 'uploadCompleteData': function(data) {
var value = fromJson(data); var value = fromJson(data);
value.url = this.attachmentsPath + '/' + value.id + '/' + value.text; value.url = this.attachmentsPath + '/' + value.id + '/' + value.text;
this.view.find("input").attr('checked', true); this.view.find("input").attr('checked', true);
@ -129,7 +131,7 @@ FileController.prototype = {
this.value = null; this.value = null;
scope.get('$binder').updateView(); scope.get('$binder').updateView();
}, },
'_on_select': function(name, size, type) { 'select': function(name, size, type) {
this.name = name; this.name = name;
this.view.find("a").text(name).attr('href', name); this.view.find("a").text(name).attr('href', name);
this.view.find("span").text(angular['filter']['bytes'](size)); this.view.find("span").text(angular['filter']['bytes'](size));
@ -161,10 +163,10 @@ FileController.prototype = {
upload: function() { upload: function() {
if (this.name) { if (this.name) {
this.uploader.uploadFile(this.attachmentsPath); this.uploader['uploadFile'](this.attachmentsPath);
} }
} }
}; });
/////////////////////// ///////////////////////
// NullController // NullController
@ -532,7 +534,7 @@ BindAttrUpdater.prototype = {
} }
var attrValue = attrValues.length ? attrValues.join('') : null; var attrValue = attrValues.length ? attrValues.join('') : null;
if(isImage && attrName == 'src' && !attrValue) if(isImage && attrName == 'src' && !attrValue)
attrValue = scope.get('config.server') + '/images/blank.gif'; attrValue = scope.get('$config.blankImage');
jNode.attr(attrName, attrValue); jNode.attr(attrName, attrValue);
} }
} }

View file

@ -5,7 +5,7 @@ FileControllerTest.prototype.testOnSelectUpdateView = function(){
var swf = {}; var swf = {};
var controller = new FileController(view, null, swf); var controller = new FileController(view, null, swf);
swf.uploadFile = function(path){}; swf.uploadFile = function(path){};
controller._on_select('A', 9, '9 bytes'); controller.select('A', 9, '9 bytes');
assertEquals(view.find('a').text(), "A"); assertEquals(view.find('a').text(), "A");
assertEquals(view.find('span').text(), "9 bytes"); assertEquals(view.find('span').text(), "9 bytes");
}; };
@ -20,7 +20,7 @@ FileControllerTest.prototype.testUpdateModelView = function(){
view.data('scope', scope); view.data('scope', scope);
controller = new FileController(view, 'value.input', null, "http://server_base"); controller = new FileController(view, 'value.input', null, "http://server_base");
var value = '{"text":"A", "size":123, "id":"890"}'; var value = '{"text":"A", "size":123, "id":"890"}';
controller._on_uploadCompleteData(value); controller.uploadCompleteData(value);
controller.updateView(scope); controller.updateView(scope);
assertEquals(scope.get('value.input.text'), 'A'); assertEquals(scope.get('value.input.text'), 'A');
assertEquals(scope.get('value.input.size'), 123); assertEquals(scope.get('value.input.size'), 123);

View file

@ -223,10 +223,10 @@ BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = f
var scope = new Scope(); var scope = new Scope();
scope.set('imageUrl', undefined); scope.set('imageUrl', undefined);
scope.set('config.server', 'http://server'); scope.set('$config.blankImage', 'http://server/blank.gif');
controller.updateView(scope); controller.updateView(scope);
assertEquals("http://server/images/blank.gif", view.attr('src')); assertEquals("http://server/blank.gif", view.attr('src'));
}; };
RepeaterUpdaterTest.prototype.testShouldNotDieWhenRepeatExpressionIsNull = function() { RepeaterUpdaterTest.prototype.testShouldNotDieWhenRepeatExpressionIsNull = function() {