Skip to content

Commit

Permalink
Jumplist items shouldn't open inside modals; Refresh current page w/ …
Browse files Browse the repository at this point in the history
…ajax instead of redirecting (#68)
  • Loading branch information
davilima6 authored and jensens committed May 2, 2016
1 parent b53f65b commit 97d668b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
46 changes: 43 additions & 3 deletions plone/app/portlets/browser/manage-portlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define([
trigger: '.pat-manage-portlets',
messageTimeout: 0,
submitTimeout: 0,
switchTimeout: 0,
isModal: false,
dirty: false,
init: function(){
Expand All @@ -40,6 +41,7 @@ define([
bind: function(){
var that = this;
that.setupAddDropdown();
that.setupSwitchPortletManager();
that.setupSavePortletsSettings();
that.setupPortletEdit();
if(that.isModal){
Expand Down Expand Up @@ -100,7 +102,7 @@ define([
$message.html('<strong>' + _t("Info") + '</strong>' + msg);
clearTimeout(that.messageTimeout);
$message.fadeTo(500, 1);
that.messageTimeout = setTimeout(function(){
that.messageTimeout = window.setTimeout(function(){
$message.fadeTo(500, 0.6);
}, 3000);
},
Expand Down Expand Up @@ -163,7 +165,7 @@ define([
},
setupSavePortletsSettings: function(){
var that = this;
$('.portlets-settings,form.portlet-action', that.$el).ajaxForm({
$('.portlets-settings, form.portlet-action', that.$el).ajaxForm({
beforeSubmit: function(){
that.loading.show();
},
Expand All @@ -174,13 +176,51 @@ define([
that.rebind($('#' + that.$el.attr('id'), $body).eq(0));
}
});
// Block/unblock inherited portlets (parent, group and content type portlets)
$('.portlets-settings select', that.$el).change(function(){
log.info('select change');
clearTimeout(that.submitTimeout);
that.submitTimeout = setTimeout(function(){
that.submitTimeout = window.setTimeout(function(){
$('.portlets-settings', that.$el).submit();
}, 100);
});
},
setupSwitchPortletManager: function(){
var that = this;
$('#main-container').on('change', '.switch-portlet-manager', function(e){
e.stopImmediatePropagation();
log.info('switch portlet manager');
var url_ = $(this).val();
clearTimeout(that.switchTimeout);
that.switchTimeout = window.setTimeout(function() {
that._reloadPortletManager(url_);
}, 100);
});
// Handle back/forward browser buttons
$(window).on('popstate', function(e) {
e.stopImmediatePropagation();
if (e && e.state === undefined) {
var url_ = window.location.href;
log.info("redirecting to: " + url_);
that._reloadPortletManager(url_, true);
}
});
},
_reloadPortletManager: function(url_, is_popstate){
var that = this;
that.loading.show();
$.get(url_, {ajax_load: 1}).done(function(html) {
var $html = $(utils.parseBodyTag(html));
var $content = ('#content', $html);
$('#content').html($content);
that.rebind($('.pat-manage-portlets', $content), true);
if (!is_popstate) {
window.history.pushState(null, null, url_);
} else {
window.history.replaceState(null, null, url_);
}
that.loading.hide();
});
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

<div metal:fill-slot="main" tal:define="plone_view context/@@plone">

<div class="quicknav-wrapper pat-manage-portlets">
<div class="quicknav-wrapper">
<form method="post"
tal:attributes="action context/absolute_url">
<select id="quicknav" class="add-portlet pull-right" name=":action"
style="width: auto; margin-top: 0.5em;"
<select id="quicknav" class="switch-portlet-manager pull-right" name=":action"
tal:define="portlet_menu context/@@view_get_menu/plone_contentmenu_portletmanager"
tal:attributes="data-context-url context/absolute_url">
<option tal:attributes="value python:request['ACTUAL_URL']"
i18n:translate="title_switch_portlet_managers">Other portlet managers&hellip;</option>
<tal:item repeat="item portlet_menu">
<option tal:define="item_id python:item['title'].lower().replace(' ', '.');
is_current python:item_id == view.manager_name"
Expand All @@ -23,7 +24,7 @@
tal:omit-tag="is_current">Plone Leftcolumn</option>
</tal:item>
</select>
<label for="quicknav" i18n:translate="title_manage_contextual_portlets" class="pull-right" style="margin-right: 0.5em; padding-top: 1em;">Quick access: </label>
<label for="quicknav" class="sr-only" i18n:translate="title_switch_portlet_managers">Other portlet managers</label>
</form>
</div>

Expand Down

0 comments on commit 97d668b

Please sign in to comment.