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) {
var widgetFactory = new WidgetFactory(config['server'], config['database']);
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 server = config['database'] =="$MEMORY" ?
new FrameServer(this.window) :
new FrameServer(window) :
new Server(config['server'], jQuery['getScript']);
server = new VisualServer(server, new Status(jQuery(element.body)), onUpdate);
var users = new Users(server, controlBar);

View file

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

View file

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

View file

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

View file

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

View file

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