aboutsummaryrefslogtreecommitdiffstats
path: root/src/ControlBar.js
diff options
context:
space:
mode:
authorMisko Hevery2010-01-25 20:02:24 -0800
committerMisko Hevery2010-01-25 20:02:24 -0800
commit0b630972b15676b1c1b6c59edd564e4ee331ec70 (patch)
treebd31ca5b69b6ea03d906a3107dfe38a8c1adcb8e /src/ControlBar.js
parent19bbee030ba012b8fc4835c1d17e039804b2b94b (diff)
parent473e57e22532f9b85fc9dcc1bcc53e12a10154c2 (diff)
downloadangular.js-0b630972b15676b1c1b6c59edd564e4ee331ec70.tar.bz2
merge
Diffstat (limited to 'src/ControlBar.js')
-rw-r--r--src/ControlBar.js111
1 files changed, 55 insertions, 56 deletions
diff --git a/src/ControlBar.js b/src/ControlBar.js
index bed7742f..73be74db 100644
--- a/src/ControlBar.js
+++ b/src/ControlBar.js
@@ -1,17 +1,11 @@
-// Copyright (C) 2008,2009 BRAT Tech LLC
-
-nglr.ControlBar = function (document, serverUrl, database) {
- this.document = document;
+function ControlBar(document, serverUrl) {
+ this._document = document;
this.serverUrl = serverUrl;
- this.database = database;
- this.window = window;
+ this._window = window;
this.callbacks = [];
};
-nglr.ControlBar.prototype.bind = function () {
-};
-
-nglr.ControlBar.HTML =
+ControlBar.HTML =
'<div>' +
'<div class="ui-widget-overlay"></div>' +
'<div id="ng-login" ng-non-bindable="true">' +
@@ -19,54 +13,59 @@ nglr.ControlBar.HTML =
'</div>' +
'</div>';
-nglr.ControlBar.prototype.login = function (loginSubmitFn) {
- this.callbacks.push(loginSubmitFn);
- if (this.callbacks.length == 1) {
- this.doTemplate("/user_session/new.mini?database="+encodeURIComponent(this.database)+"&return_url=" + encodeURIComponent(this.urlWithoutAnchor()));
- }
-};
-
-nglr.ControlBar.prototype.logout = function (loginSubmitFn) {
- this.callbacks.push(loginSubmitFn);
- if (this.callbacks.length == 1) {
- this.doTemplate("/user_session/do_destroy.mini");
- }
-};
-
-nglr.ControlBar.prototype.urlWithoutAnchor = function (path) {
- return this.window.location.href.split("#")[0];
-};
-
-nglr.ControlBar.prototype.doTemplate = function (path) {
- var self = this;
- var id = new Date().getTime();
- var url = this.urlWithoutAnchor();
- url += "#$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>'
- });
- nglr["_iframe_notify_" + id] = function() {
- loginView.dialog("destroy");
- loginView.remove();
- jQuery.each(self.callbacks, function(i, callback){
- callback();
- });
- self.callbacks = [];
- };
-};
-nglr.ControlBar.FORBIDEN =
+ControlBar.FORBIDEN =
'<div ng-non-bindable="true" title="Permission Error:">' +
'Sorry, you do not have permission for this!'+
'</div>';
-nglr.ControlBar.prototype.notAuthorized = function () {
- if (this.forbidenView) return;
- this.forbidenView = jQuery(nglr.ControlBar.FORBIDEN);
- this.forbidenView.dialog({bgiframe:true, height:70, modal:true});
-};
+ControlBar.prototype = {
+ bind: function () {
+ },
+
+ login: function (loginSubmitFn) {
+ this.callbacks.push(loginSubmitFn);
+ if (this.callbacks.length == 1) {
+ this.doTemplate("/user_session/new.mini?return_url=" + encodeURIComponent(this.urlWithoutAnchor()));
+ }
+ },
+
+ logout: function (loginSubmitFn) {
+ this.callbacks.push(loginSubmitFn);
+ if (this.callbacks.length == 1) {
+ this.doTemplate("/user_session/do_destroy.mini");
+ }
+ },
+
+ urlWithoutAnchor: function (path) {
+ return this._window['location']['href'].split("#")[0];
+ },
+
+ doTemplate: function (path) {
+ var self = this;
+ var id = new Date().getTime();
+ 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>'
+ });
+ angularCallbacks["_iframe_notify_" + id] = function() {
+ loginView['dialog']("destroy");
+ loginView['remove']();
+ foreach(self.callbacks, function(callback){
+ callback();
+ });
+ self.callbacks = [];
+ };
+ },
+
+ notAuthorized: function () {
+ if (this.forbidenView) return;
+ this.forbidenView = jQuery(ControlBar.FORBIDEN);
+ this.forbidenView.dialog({bgiframe:true, height:70, modal:true});
+ }
+}; \ No newline at end of file