From c9c176a53b1632ca2b1c6ed27382ab72ac21d45d Mon Sep 17 00:00:00 2001
From: Adam Abrons
Date: Tue, 5 Jan 2010 16:36:58 -0800
Subject: angular.js
---
src/ControlBar.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
create mode 100644 src/ControlBar.js
(limited to 'src/ControlBar.js')
diff --git a/src/ControlBar.js b/src/ControlBar.js
new file mode 100644
index 00000000..3e1f0b57
--- /dev/null
+++ b/src/ControlBar.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2008,2009 BRAT Tech LLC
+
+nglr.ControlBar = function (document, serverUrl) {
+ this.document = document;
+ this.serverUrl = serverUrl;
+ this.window = window;
+ this.callbacks = [];
+};
+
+nglr.ControlBar.prototype.bind = function () {
+};
+
+nglr.ControlBar.HTML =
+ '
';
+
+nglr.ControlBar.prototype.login = function (loginSubmitFn) {
+ this.callbacks.push(loginSubmitFn);
+ if (this.callbacks.length == 1) {
+ this.doTemplate("/user_session/new.mini?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('');
+ this.document.append(loginView);
+ loginView.dialog({
+ height:iframeHeight + 33, width:500,
+ resizable: false, modal:true,
+ title: 'Authentication: <angular/>'
+ });
+ nglr["_iframe_notify_" + id] = function() {
+ loginView.dialog("destroy");
+ loginView.remove();
+ jQuery.each(self.callbacks, function(i, callback){
+ callback();
+ });
+ self.callbacks = [];
+ };
+};
+
+nglr.ControlBar.FORBIDEN =
+ '' +
+ 'Sorry, you do not have permission for this!'+
+ '
';
+
+nglr.ControlBar.prototype.notAuthorized = function () {
+ if (this.forbidenView) return;
+ this.forbidenView = jQuery(nglr.ControlBar.FORBIDEN);
+ this.forbidenView.dialog({bgiframe:true, height:70, modal:true});
+};
--
cgit v1.2.3