Files
Phraseanet/www/scripts/apps/admin/main/views/rightPanel.js
Benoît Burnichon 1e18b3e69f This is a combination of 33 commits.
- Squashed Pull request #1730
- Squashed Pull request #1741
- Squashed Pull request #1742
- Squash merge branch 4.0
- Squashed Pull request #1744
- Squashed Pull request #1746
- Squashed merge branch 4.0
- Squashed merge branch 4.0
- Squashed merge branch 4.0
- Squashed merge branch 4.0
- Squashed Pull request #1758
- Avoid using imagine/imagine alias as it is causing install issues
- Squashed merge branch 4.0
- Squashed Pull request #1763
- Squashed merge branch 4.0
- Squash of 6 commits
- Squashed merge branch 4.0
- This is a combination of 2 commits.
- Squashed Pull request #1775
- Squashed Pull request #1777
- Squashed Pull request #1779
- Squashed Pull request #1780
- Squashed Pull request #1782
- Adds a Pull request template
- Squased Pull request #1783
- Squash Pull request #1786
- Squashed Pull request #1796
- Squashed merge branch 4.0
- Squash Pull request #1791
- Squashed merge branch 4.0
- Squashed Pull request #1808
- Squashed Pull request #1811
- Squashed Pull request #1809
2016-04-20 16:22:14 +02:00

106 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
define([
"jquery",
"underscore",
"backbone",
"blueimp.loadimage",
"jfu.iframe-transport",
"jfu.fileupload",
"jquery.ui",
"bootstrap"
], function ($, _, Backbone) {
var RightPanelView = Backbone.View.extend({
initialize: function (options) {
options = options || {};
if (false === ("eventManager" in options)) {
throw "You must set en event manager";
}
this.delegateEvents(this.events);
this.eventManager = options.eventManager;
var $this = this;
this.eventManager.on("panel:right:beforeSend", function() {
$this.$el.empty();
$this.loadingState(true);
});
this.eventManager.on("panel:right:complete", function() {
$this.loadingState(false);
});
this.eventManager.on("panel:right:success", function(data) {
$this.render(data);
})
},
events: {
"submit form:not(.no-ajax)": "submitAction",
"click a:not(.no-ajax)": "clickAction"
},
render: function (data) {
this.$el.html(data);
return this;
},
clickAction: function(event) {
event.preventDefault();
var $this = this;
var link = $(event.currentTarget);
var url = link.attr('href');
if(url && url.indexOf('#') !== 0) {
$.ajax({
type: link.attr("method") || "GET",
url: url,
success: function(data) {
$this.eventManager.trigger('panel:right:success', data);
},
beforeSend: function(){
$this.eventManager.trigger('panel:right:beforeSend');
},
complete: function(){
$this.eventManager.trigger('panel:right:complete');
}
});
}
},
submitAction: function(event) {
event.preventDefault();
var $this = this;
var link = $(event.currentTarget);
var url = link.attr('action');
if(url) {
$.ajax({
type: link.attr('method') || 'GET',
url: url,
data: link.serializeArray(),
success: function (data) {
$this.eventManager.trigger("panel:right:success", data);
},
beforeSend: function(){
$this.eventManager.trigger('panel:right:beforeSend');
},
complete: function(){
$this.eventManager.trigger('panel:right:complete');
}
});
}
},
loadingState: function(state) {
if (state) {
this.$el.addClass("loading");
} else {
this.$el.removeClass("loading");
}
}
});
return RightPanelView;
});