X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..407a830d3dbe065b09de2207d69b1d38511a770c:/src/redakcja/static/js/wiki/base.js?ds=inline
diff --git a/src/redakcja/static/js/wiki/base.js b/src/redakcja/static/js/wiki/base.js
index ad2ee3a9..b4fee85f 100644
--- a/src/redakcja/static/js/wiki/base.js
+++ b/src/redakcja/static/js/wiki/base.js
@@ -47,7 +47,7 @@
$.wiki.activePerspective = function() {
- return this.perspectives[$("#tabs li.active").attr('id')];
+ return this.perspectives[$("#tabs li a.active").parent().attr('id')];
};
$.wiki.exitContext = function() {
@@ -68,8 +68,8 @@
$.wiki.newTab = function(doc, title, klass) {
var base_id = 'id' + Math.floor(Math.random()* 5000000000);
var id = (''+klass)+'_' + base_id;
- var $tab = $('
'
- + title + '');
+ var $tab = $(''
+ + title + ' x');
var $view = $('
');
this.perspectives[id] = new $.wiki[klass]({
@@ -104,30 +104,40 @@
return this.perspectives[ $(tab).attr('id')];
}
- $.wiki.switchToTab = function(tab){
- var self = this;
- var $tab = $(tab);
-
- if($tab.length != 1)
- $tab = $(DEFAULT_PERSPECTIVE);
-
- var $old = $tab.closest('.tabs').find('.active');
-
- $old.each(function(){
- $(this).removeClass('active');
- self.perspectives[$(this).attr('id')].onExit();
- $('#' + $(this).attr('data-ui-related')).hide();
- });
-
- /* show new */
- $tab.addClass('active');
- $('#' + $tab.attr('data-ui-related')).show();
-
- console.log($tab);
- console.log($.wiki.perspectives);
-
- $.wiki.perspectives[$tab.attr('id')].onEnter();
- };
+ $.wiki.exitTab = function(tab){
+ var self = this;
+ var $tab = $(tab);
+ if (!('.active', $tab)) return;
+ $('.active', $tab).removeClass('active');
+ self.perspectives[$tab.attr('id')].onExit();
+ $('#' + $tab.attr('data-ui-related')).hide();
+ }
+
+ $.wiki.switchToTab = function(tab){
+ var self = this;
+ var $tab = $(tab);
+
+ if($tab.length != 1)
+ $tab = $(DEFAULT_PERSPECTIVE);
+
+ var $old_a = $tab.closest('.tabs').find('.active');
+
+ $old_a.each(function(){
+ var tab = $(this).parent()
+ $(this).removeClass('active');
+ self.perspectives[tab.attr('id')].onExit();
+ $('#' + tab.attr('data-ui-related')).hide();
+ });
+
+ /* show new */
+ $('a', tab).addClass('active');
+ $('#' + $tab.attr('data-ui-related')).show();
+
+ console.log($tab);
+ console.log($.wiki.perspectives);
+
+ $.wiki.perspectives[$tab.attr('id')].onEnter();
+ };
/*
* Basic perspective.
@@ -272,9 +282,11 @@
$.blockUI({
message: this.$elem,
css: {
- 'top': '25%',
- 'left': '25%',
- 'width': '50%'
+ 'top': '25%',
+ 'left': '25%',
+ 'width': '50%',
+ 'max-height': '75%',
+ 'overflow-y': 'scroll'
}
});
},
@@ -336,4 +348,28 @@
}
};
+
+ window.addEventListener("message", (event) => {
+ event.source.close()
+
+ $.ajax("/editor/editor-user-area/", {
+ success: function(d) {
+ $("#user-area")[0].innerHTML = d;
+ }
+ });
+ }, false);
+
+ $("#login").click(function (e) {
+ e.preventDefault();
+ let h = 600;
+ let w = 500;
+ let x = window.screenX + (window.innerWidth - w) / 2;
+ let y = window.screenY + (window.innerHeight - h) / 2;
+ window.open(
+ "/accounts/login/?next=/editor/back",
+ "login-window",
+ "width=" + w + " height=" + h + " top=" + y + " left=" + x
+ );
+ });
+
})(jQuery);