X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/6711796e2e218419485fd3ebd4949cfeefa01b16..3c0f69b2b4d62eaeb05403edc7b4c171622edc9a:/project/static/js/editor.js diff --git a/project/static/js/editor.js b/project/static/js/editor.js index 0a56c5ab..5366c587 100644 --- a/project/static/js/editor.js +++ b/project/static/js/editor.js @@ -47,6 +47,7 @@ Panel.prototype.load = function (url) { $(self.contentDiv).html(data); self.hooks = panel_hooks; panel_hooks = null; + self.connectToolbar(); self.callHook('load'); }, error: function(request, textStatus, errorThrown) { @@ -104,6 +105,52 @@ Panel.prototype.saveInfo = function() { return saveInfo; } +Panel.prototype.connectToolbar = function() { + // check if there is a one + var toolbar = $("div.toolbar", this.contentDiv); + $.log('Connecting toolbar', toolbar); + if(toolbar.length == 0) return; + + // connect group-switch buttons + var group_buttons = $('*.toolbar-tabs-container button', toolbar); + + $.log('Found groups:', group_buttons); + + group_buttons.each(function() { + var group = $(this); + var group_name = group.attr('ui:group'); + $.log('Connecting group: ' + group_name); + + group.click(function() { + // change the active group + var active = $("*.toolbar-tabs-container button.active"); + if (active != group) { + active.removeClass('active'); + group.addClass('active'); + $(".toolbar-button-groups-container p").each(function() { + if ( $(this).attr('ui:group') != group_name) + $(this).hide(); + else + $(this).show(); + }); + } + }); + }); + + // connect action buttons + var action_buttons = $('*.toolbar-button-groups-container button'); + action_buttons.each(function() { + var button = $(this); + var action = button.attr('ui:action').split(':'); + var action_name = action[0]; + var action_data = action[1]; + + button.click(function() { + $.log('emiting action ', action_name, ' with data: ', action_data); + $(document).trigger('ui:action:' + action_name, action_data); + }); + }); +} function Editor() { this.rootDiv = $('#panels'); @@ -148,7 +195,8 @@ Editor.prototype.loadConfig = function() { panels: [ {name: 'htmleditor', ratio: 0.5}, {name: 'gallery', ratio: 0.5} - ] + ], + lastUpdate: 0, } try { @@ -200,6 +248,7 @@ Editor.prototype.savePanelOptions = function() { }) }); self.options.panels = panels; + self.options.lastUpdate = (new Date()).getTime() / 1000; $.log($.toJSON(self.options)); $.cookie('options', $.toJSON(self.options), { expires: 7, path: '/'}); } @@ -320,7 +369,7 @@ Editor.prototype.showPopup = function(name, text) return; var box = $('#message-box > #' + name); - $('span.data', box).html(text); + $('*.data', box).html(text); box.fadeIn(); self._nextPopup = function() { @@ -329,11 +378,11 @@ Editor.prototype.showPopup = function(name, text) var box = $('#message-box > #' + elem[0]); box.fadeOut(300, function() { - $('span.data', box).html(); + $('*.data', box).html(); if( self.popupQueue.length > 0) { box = $('#message-box > #' + self.popupQueue[0][0]); - $('span.data', box).html(self.popupQueue[0][1]); + $('*.data', box).html(self.popupQueue[0][1]); box.fadeIn(); setTimeout(self._nextPopup, 5000); }