'
).append($selectAll).append($unselectAll);
- if (!this.$element.prop("multiple")) {
+ if (!this.$element.prop('multiple')) {
// this isn't a multi-select -> don't add the buttons!
return $rendered;
}
$rendered.find('.select2-dropdown').prepend($btnContainer);
- $selectAll.on('click', function (e) {
- var $results = $rendered.find('.select2-results__option[aria-selected=false]');
- $results.each(function () {
- self.trigger('select', {
- data: $(this).data('data')
- });
- });
+ $selectAll.on('click', function() {
+ $rendered.find('.select2-results__option[aria-selected=false]').each(
+ function() {
+ self.trigger('select', {
+ data: $(this).data('data'),
+ });
+ }
+ );
self.trigger('close');
});
- $unselectAll.on('click', function (e) {
- var $results = $rendered.find('.select2-results__option[aria-selected=true]');
- $results.each(function () {
- self.trigger('unselect', {
- data: $(this).data('data')
- });
- });
+ $unselectAll.on('click', function() {
+ $rendered.find('.select2-results__option[aria-selected=true]').each(
+ function() {
+ self.trigger('unselect', {
+ data: $(this).data('data'),
+ });
+ }
+ );
self.trigger('close');
});
return $rendered;
@@ -89,98 +88,98 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
* data to proper 'label', 'value' format.
*/
var NodeAjaxOptionsControl = Backform.NodeAjaxOptionsControl =
- Backform.Select2Control.extend({
- defaults: _.extend(Backform.Select2Control.prototype.defaults, {
- url: undefined,
- transform: undefined,
- url_with_id: false,
- select2: {
- allowClear: true,
- placeholder: 'Select from the list',
- width: 'style'
- }
- }),
- initialize: function() {
- /*
- * Initialization from the original control.
- */
- Backform.Select2Control.prototype.initialize.apply(this, arguments);
-
- /*
- * We're about to fetch the options required for this control.
- */
- var self = this,
+ Backform.Select2Control.extend({
+ defaults: _.extend(Backform.Select2Control.prototype.defaults, {
+ url: undefined,
+ transform: undefined,
+ url_with_id: false,
+ select2: {
+ allowClear: true,
+ placeholder: 'Select from the list',
+ width: 'style',
+ },
+ }),
+ initialize: function() {
+ /*
+ * Initialization from the original control.
+ */
+ Backform.Select2Control.prototype.initialize.apply(this, arguments);
+
+ /*
+ * We're about to fetch the options required for this control.
+ */
+ var self = this,
url = self.field.get('url') || self.defaults.url,
m = self.model.top || self.model;
- // Hmm - we found the url option.
- // That means - we needs to fetch the options from that node.
- if (url) {
- var node = this.field.get('schema_node'),
+ // Hmm - we found the url option.
+ // That means - we needs to fetch the options from that node.
+ if (url) {
+ var node = this.field.get('schema_node'),
node_info = this.field.get('node_info'),
with_id = this.field.get('url_with_id') || false,
full_url = node.generate_url.apply(
node, [
- null, url, this.field.get('node_data'), with_id, node_info
+ null, url, this.field.get('node_data'), with_id, node_info,
]),
cache_level,
cache_node = this.field.get('cache_node');
- cache_node = (cache_node && pgAdmin.Browser.Nodes[cache_node]) || node;
+ cache_node = (cache_node && pgAdmin.Browser.Nodes[cache_node]) || node;
- if (this.field.has('cache_level')) {
- cache_level = this.field.get('cache_level');
- } else {
- cache_level = cache_node.cache_level(node_info, with_id);
- }
+ if (this.field.has('cache_level')) {
+ cache_level = this.field.get('cache_level');
+ } else {
+ cache_level = cache_node.cache_level(node_info, with_id);
+ }
- /*
- * We needs to check, if we have already cached data for this url.
- * If yes - use that, and do not bother about fetching it again,
- * and use it.
- */
- var data = cache_node.cache(node.type + '#' + url, node_info, cache_level);
+ /*
+ * We needs to check, if we have already cached data for this url.
+ * If yes - use that, and do not bother about fetching it again,
+ * and use it.
+ */
+ var data = cache_node.cache(node.type + '#' + url, node_info, cache_level);
- if (this.field.get('version_compatible') &&
+ if (this.field.get('version_compatible') &&
(_.isUndefined(data) || _.isNull(data))) {
- m.trigger('pgadmin:view:fetching', m, self.field);
- $.ajax({
- async: false,
- url: full_url,
- success: function(res) {
- /*
- * We will cache this data for short period of time for avoiding
- * same calls.
- */
- data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
- },
- error: function() {
- m.trigger('pgadmin:view:fetch:error', m, self.field);
- }
- });
- m.trigger('pgadmin:view:fetched', m, self.field);
- }
- // To fetch only options from cache, we do not need time from 'at'
- // attribute but only options.
- //
- // It is feasible that the data may not have been fetched.
- data = (data && data.data) || [];
-
- /*
- * Transform the data
- */
- var transform = this.field.get('transform') || self.defaults.transform;
- if (transform && _.isFunction(transform)) {
- // We will transform the data later, when rendering.
- // It will allow us to generate different data based on the
- // dependencies.
- self.field.set('options', transform.bind(self, data));
- } else {
- self.field.set('options', data);
+ m.trigger('pgadmin:view:fetching', m, self.field);
+ $.ajax({
+ async: false,
+ url: full_url,
+ success: function(res) {
+ /*
+ * We will cache this data for short period of time for avoiding
+ * same calls.
+ */
+ data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
+ },
+ error: function() {
+ m.trigger('pgadmin:view:fetch:error', m, self.field);
+ },
+ });
+ m.trigger('pgadmin:view:fetched', m, self.field);
+ }
+ // To fetch only options from cache, we do not need time from 'at'
+ // attribute but only options.
+ //
+ // It is feasible that the data may not have been fetched.
+ data = (data && data.data) || [];
+
+ /*
+ * Transform the data
+ */
+ var transform = this.field.get('transform') || self.defaults.transform;
+ if (transform && _.isFunction(transform)) {
+ // We will transform the data later, when rendering.
+ // It will allow us to generate different data based on the
+ // dependencies.
+ self.field.set('options', transform.bind(self, data));
+ } else {
+ self.field.set('options', data);
+ }
}
- }
- }
- });
+ },
+ });
var formatNode = function(opt) {
if (!opt.id) {
@@ -189,14 +188,14 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
var optimage = $(opt.element).data('image');
- if(!optimage){
+ if (!optimage) {
return opt.text;
} else {
return $('
').append(
- $('
', {class: "wcTabIcon " + optimage})
- ).append(
- $('
').text(opt.text)
- );
+ $('
', {
+ class: 'wcTabIcon ' + optimage,
+ })
+ ).append($('
').text(opt.text));
}
};
@@ -207,27 +206,29 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
filter: undefined,
transform: function(rows) {
var self = this,
- node = self.field.get('schema_node'),
- res = [],
- filter = self.field.get('filter') || function() { return true; };
+ node = self.field.get('schema_node'),
+ res = [],
+ filter = self.field.get('filter') || function() {
+ return true;
+ };
filter = filter.bind(self);
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(node['node_label']) ?
- (node['node_label']).apply(node, [r, self.model, self]) :
- r.label),
- image= (_.isFunction(node['node_image']) ?
- (node['node_image']).apply(
- node, [r, self.model, self]
- ) :
- (node['node_image'] || ('icon-' + node.type)));
+ (node['node_label']).apply(node, [r, self.model, self]) :
+ r.label),
+ image = (_.isFunction(node['node_image']) ?
+ (node['node_image']).apply(
+ node, [r, self.model, self]
+ ) :
+ (node['node_image'] || ('icon-' + node.type)));
res.push({
'value': r._id,
'image': image,
- 'label': l
+ 'label': l,
});
}
});
@@ -239,62 +240,64 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
placeholder: 'Select from the list',
width: 'style',
templateResult: formatNode,
- templateSelection: formatNode
- }
- })
+ templateSelection: formatNode,
+ },
+ }),
});
-
- var NodeListByNameControl = Backform.NodeListByNameControl = NodeListByIdControl.extend({
+ Backform.NodeListByNameControl = NodeListByIdControl.extend({
defaults: _.extend({}, NodeListByIdControl.prototype.defaults, {
transform: function(rows) {
var self = this,
- node = self.field.get('schema_node'),
- res = [],
- filter = self.field.get('filter') || function() { return true; };
+ node = self.field.get('schema_node'),
+ res = [],
+ filter = self.field.get('filter') || function() {
+ return true;
+ };
filter = filter.bind(self);
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(node['node_label']) ?
- (node['node_label']).apply(node, [r, self.model, self]) :
- r.label),
- image = (_.isFunction(node['node_image']) ?
- (node['node_image']).apply(
- node, [r, self.model, self]
- ) :
- (node['node_image'] || ('icon-' + node.type)));
+ (node['node_label']).apply(node, [r, self.model, self]) :
+ r.label),
+ image = (_.isFunction(node['node_image']) ?
+ (node['node_image']).apply(
+ node, [r, self.model, self]
+ ) :
+ (node['node_image'] || ('icon-' + node.type)));
res.push({
'value': r.label,
'image': image,
- 'label': l
+ 'label': l,
});
}
});
return res;
- }
- })
+ },
+ }),
});
/*
* Global function to make visible particular dom element in it's parent
* with given class.
*/
- $.fn.pgMakeVisible = function( cls ) {
+ $.fn.pgMakeVisible = function(cls) {
return this.each(function() {
if (!this || !$(this.length))
return;
- var top, p = $(this), hasScrollbar = function(j) {
- if (j && j.length > 0) {
- return j.get(0).scrollHeight > j.height();
- }
- return false;
- };
+ var top, p = $(this),
+ hasScrollbar = function(j) {
+ if (j && j.length > 0) {
+ return j.get(0).scrollHeight > j.height();
+ }
+ return false;
+ };
// check if p is not empty
- while(p && p.length > 0) {
+ while (p && p.length > 0) {
top = p.get(0).offsetTop + p.height();
p = p.parent();
if (hasScrollbar(p)) {
@@ -327,40 +330,41 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
select2: {
allowClear: true,
placeholder: 'Select from the list',
- width: 'style'
+ width: 'style',
},
opt: {
label: null,
value: null,
image: null,
- selected: false
- }
+ selected: false,
+ },
}),
template: _.template(
'
'
),
- initialize: function () {
+ initialize: function() {
Backgrid.Extension.Select2Cell.prototype.initialize.apply(this, arguments);
var url = this.column.get('url') || this.defaults.url,
- is_options_cached = _.has(this.column.attributes, 'options_cached'),
- options_cached = is_options_cached && this.column.get('options_cached');
+ is_options_cached = _.has(this.column.attributes, 'options_cached'),
+ options_cached = is_options_cached && this.column.get('options_cached');
// Hmm - we found the url option.
// That means - we needs to fetch the options from that node.
if (url && !options_cached) {
var self = this,
- m = this.model, column = this.column,
- eventHandler = m.top || m,
- node = column.get('schema_node'),
- node_info = column.get('node_info'),
- with_id = column.get('url_with_id') || false,
- full_url = node.generate_url.apply(
- node, [
- null, url, column.get('node_data'), with_id, node_info
- ]),
- cache_level,
- cache_node = column.get('cache_node');
+ m = this.model,
+ column = this.column,
+ eventHandler = m.top || m,
+ node = column.get('schema_node'),
+ node_info = column.get('node_info'),
+ with_id = column.get('url_with_id') || false,
+ full_url = node.generate_url.apply(
+ node, [
+ null, url, column.get('node_data'), with_id, node_info,
+ ]),
+ cache_level,
+ cache_node = column.get('cache_node');
cache_node = (cache_node && pgAdmin.Browser.Nodes[cache_node]) || node;
@@ -378,7 +382,7 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
var data = cache_node.cache(node.type + '#' + url, node_info, cache_level);
if (column.get('version_compatible') &&
- (_.isUndefined(data) || _.isNull(data))) {
+ (_.isUndefined(data) || _.isNull(data))) {
eventHandler.trigger('pgadmin:view:fetching', m, column);
$.ajax({
async: false,
@@ -392,7 +396,7 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
},
error: function() {
eventHandler.trigger('pgadmin:view:fetch:error', m, column);
- }
+ },
});
eventHandler.trigger('pgadmin:view:fetched', m, column);
}
@@ -415,41 +419,43 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
column.set('options', data);
}
- if(is_options_cached) {
+ if (is_options_cached) {
column.set('options_cached', true);
}
}
- }
+ },
});
- var NodeListByIdCell = Backgrid.Extension.NodeListByIdCell = NodeAjaxOptionsCell.extend({
+ Backgrid.Extension.NodeListByIdCell = NodeAjaxOptionsCell.extend({
controlClassName: 'pgadmin-node-select backgrid-cell',
defaults: _.extend({}, NodeAjaxOptionsCell.prototype.defaults, {
url: 'nodes',
filter: undefined,
transform: function(rows, control) {
var self = control || this,
- node = self.column.get('schema_node'),
- res = [],
- filter = self.column.get('filter') || function() { return true; };
+ node = self.column.get('schema_node'),
+ res = [],
+ filter = self.column.get('filter') || function() {
+ return true;
+ };
filter = filter.bind(self);
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(node['node_label']) ?
- (node['node_label']).apply(node, [r, self.model, self]) :
- r.label),
- image= (_.isFunction(node['node_image']) ?
- (node['node_image']).apply(
- node, [r, self.model, self]
- ) :
- (node['node_image'] || ('icon-' + node.type)));
+ (node['node_label']).apply(node, [r, self.model, self]) :
+ r.label),
+ image = (_.isFunction(node['node_image']) ?
+ (node['node_image']).apply(
+ node, [r, self.model, self]
+ ) :
+ (node['node_image'] || ('icon-' + node.type)));
res.push({
'value': r._id,
'image': image,
- 'label': l
+ 'label': l,
});
}
});
@@ -460,40 +466,41 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
placeholder: 'Select from the list',
width: 'style',
templateResult: formatNode,
- templateSelection: formatNode
- }
- })
+ templateSelection: formatNode,
+ },
+ }),
});
-
- var NodeListByNameCell = Backgrid.Extension.NodeListByNameCell = NodeAjaxOptionsCell.extend({
+ Backgrid.Extension.NodeListByNameCell = NodeAjaxOptionsCell.extend({
controlClassName: 'pgadmin-node-select backgrid-cell',
defaults: _.extend({}, NodeAjaxOptionsCell.prototype.defaults, {
url: 'nodes',
filter: undefined,
transform: function(rows, control) {
var self = control || this,
- node = self.column.get('schema_node'),
- res = [],
- filter = self.column.get('filter') || function() { return true; };
+ node = self.column.get('schema_node'),
+ res = [],
+ filter = self.column.get('filter') || function() {
+ return true;
+ };
filter = filter.bind(self);
_.each(rows, function(r) {
if (filter(r)) {
var l = (_.isFunction(node['node_label']) ?
- (node['node_label']).apply(node, [r, self.model, self]) :
- r.label),
- image= (_.isFunction(node['node_image']) ?
- (node['node_image']).apply(
- node, [r, self.model, self]
- ) :
- (node['node_image'] || ('icon-' + node.type)));
+ (node['node_label']).apply(node, [r, self.model, self]) :
+ r.label),
+ image = (_.isFunction(node['node_image']) ?
+ (node['node_image']).apply(
+ node, [r, self.model, self]
+ ) :
+ (node['node_image'] || ('icon-' + node.type)));
res.push({
'value': r.label,
'image': image,
- 'label': l
+ 'label': l,
});
}
});
@@ -504,13 +511,13 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
placeholder: 'Select from the list',
width: 'style',
templateResult: formatNode,
- templateSelection: formatNode
- }
- })
+ templateSelection: formatNode,
+ },
+ }),
});
- // Extend the browser's node model class to create a option/value pair
- var MultiSelectAjaxCell = Backgrid.Extension.MultiSelectAjaxCell = Backgrid.Extension.NodeAjaxOptionsCell.extend({
+ // Extend the browser's node model class to create a option/value pair
+ Backgrid.Extension.MultiSelectAjaxCell = Backgrid.Extension.NodeAjaxOptionsCell.extend({
defaults: _.extend({}, NodeAjaxOptionsCell.prototype.defaults, {
transform: undefined,
url_with_id: false,
@@ -518,19 +525,19 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
allowClear: true,
placeholder: 'Select from the list',
width: 'style',
- multiple: true
+ multiple: true,
},
opt: {
label: null,
value: null,
image: null,
- selected: false
- }
+ selected: false,
+ },
}),
getValueFromDOM: function() {
var res = [];
- this.$el.find("select").find(':selected').each(function() {
+ this.$el.find('select').find(':selected').each(function() {
res.push($(this).attr('value'));
});
@@ -541,15 +548,15 @@ function(gettext, $, _, pgAdmin, Backbone, Backform, Alertify, Backgrid) {
/*
* Control to select multiple columns.
*/
- var MultiSelectAjaxControl = Backform.MultiSelectAjaxControl = NodeAjaxOptionsControl.extend({
+ Backform.MultiSelectAjaxControl = NodeAjaxOptionsControl.extend({
defaults: _.extend({}, NodeAjaxOptionsControl.prototype.defaults, {
select2: {
multiple: true,
allowClear: true,
- width: 'style'
- }
- })
+ width: 'style',
+ },
+ }),
});
return Backform;
-});
+});
\ No newline at end of file
diff --git a/web/pgadmin/browser/static/js/panel.js b/web/pgadmin/browser/static/js/panel.js
index 3a9f22d4..f0850676 100644
--- a/web/pgadmin/browser/static/js/panel.js
+++ b/web/pgadmin/browser/static/js/panel.js
@@ -1,66 +1,67 @@
define(
- ['underscore', 'sources/pgadmin', 'wcdocker'],
-function(_, pgAdmin) {
-
- var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
-
- pgAdmin.Browser.Panel = function(options) {
- var defaults = [
- 'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
- 'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer',
- 'canHide', 'limit'
- ];
- _.extend(this, _.pick(options, defaults));
- }
-
- _.extend(pgAdmin.Browser.Panel.prototype, {
- name:'',
- title: '',
- width: 300,
- height: 600,
- showTitle: true,
- isCloseable: true,
- isPrivate: false,
- content: '',
- icon: '',
- panel: null,
- onCreate: null,
- elContainer: false,
- limit: null,
- load: function(docker, title) {
- var that = this;
- if (!that.panel) {
- docker.registerPanelType(that.name, {
- title: that.title,
- isPrivate: that.isPrivate,
- limit: that.limit,
- onCreate: function(myPanel) {
- $(myPanel).data('pgAdminName', that.name);
- myPanel.initSize(that.width, that.height);
-
- if (!that.showTitle)
- myPanel.title(false);
- else {
- myPanel.title(title || that.title);
- if (that.icon != '')
- myPanel.icon(that.icon)
- }
-
- var $container = $('
', {
- 'class': 'pg-panel-content'
- }).append($(that.content));
-
- myPanel.closeable(!!that.isCloseable);
- myPanel.layout().addItem($container);
- that.panel = myPanel;
- if (that.events && _.isObject(that.events)) {
- _.each(that.events, function(v, k) {
- if (v && _.isFunction(v)) {
- myPanel.on(k, v);
- }
- });
- }
- _.each([
+ ['underscore', 'sources/pgadmin', 'jquery', 'wcdocker'],
+ function(_, pgAdmin, $) {
+
+ var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {},
+ wcDocker = window.wcDocker;
+
+ pgAdmin.Browser.Panel = function(options) {
+ var defaults = [
+ 'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
+ 'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer',
+ 'canHide', 'limit',
+ ];
+ _.extend(this, _.pick(options, defaults));
+ };
+
+ _.extend(pgAdmin.Browser.Panel.prototype, {
+ name: '',
+ title: '',
+ width: 300,
+ height: 600,
+ showTitle: true,
+ isCloseable: true,
+ isPrivate: false,
+ content: '',
+ icon: '',
+ panel: null,
+ onCreate: null,
+ elContainer: false,
+ limit: null,
+ load: function(docker, title) {
+ var that = this;
+ if (!that.panel) {
+ docker.registerPanelType(that.name, {
+ title: that.title,
+ isPrivate: that.isPrivate,
+ limit: that.limit,
+ onCreate: function(myPanel) {
+ $(myPanel).data('pgAdminName', that.name);
+ myPanel.initSize(that.width, that.height);
+
+ if (!that.showTitle)
+ myPanel.title(false);
+ else {
+ myPanel.title(title || that.title);
+ if (that.icon != '')
+ myPanel.icon(that.icon);
+ }
+
+ var $container = $('
', {
+ 'class': 'pg-panel-content',
+ }).append($(that.content));
+
+ myPanel.closeable(!!that.isCloseable);
+ myPanel.layout().addItem($container);
+ that.panel = myPanel;
+ if (that.events && _.isObject(that.events)) {
+ _.each(that.events, function(v, k) {
+ if (v && _.isFunction(v)) {
+ myPanel.on(k, v);
+ }
+ });
+ }
+ _.each([
wcDocker.EVENT.UPDATED, wcDocker.EVENT.VISIBILITY_CHANGED,
wcDocker.EVENT.BEGIN_DOCK, wcDocker.EVENT.END_DOCK,
wcDocker.EVENT.GAIN_FOCUS, wcDocker.EVENT.LOST_FOCUS,
@@ -69,109 +70,117 @@ function(_, pgAdmin) {
wcDocker.EVENT.MOVE_STARTED, wcDocker.EVENT.MOVE_ENDED,
wcDocker.EVENT.MOVED, wcDocker.EVENT.RESIZE_STARTED,
wcDocker.EVENT.RESIZE_ENDED, wcDocker.EVENT.RESIZED,
- wcDocker.EVENT.SCROLLED], function(ev) {
- myPanel.on(ev, that.eventFunc.bind(myPanel, ev));
- });
-
- if (that.onCreate && _.isFunction(that.onCreate)) {
- that.onCreate.apply(that, [myPanel, $container]);
- }
-
- if (that.elContainer) {
- myPanel.pgElContainer = $container;
- $container.addClass('pg-el-container');
- _.each([
- wcDocker.EVENT.RESIZED, wcDocker.EVENT.ATTACHED,
- wcDocker.EVENT.DETACHED, wcDocker.EVENT.VISIBILITY_CHANGED
+ wcDocker.EVENT.SCROLLED,
], function(ev) {
- myPanel.on(ev, that.resizedContainer.bind(myPanel));
+ myPanel.on(ev, that.eventFunc.bind(myPanel, ev));
});
- that.resizedContainer.apply(myPanel);
- }
-
- // Bind events only if they are configurable
- if (that.canHide) {
- _.each([wcDocker.EVENT.CLOSED, wcDocker.EVENT.VISIBILITY_CHANGED],
- function(ev) {
- myPanel.on(ev, that.handleVisibility.bind(myPanel, ev));
+
+ if (that.onCreate && _.isFunction(that.onCreate)) {
+ that.onCreate.apply(that, [myPanel, $container]);
+ }
+
+ if (that.elContainer) {
+ myPanel.pgElContainer = $container;
+ $container.addClass('pg-el-container');
+ _.each([
+ wcDocker.EVENT.RESIZED, wcDocker.EVENT.ATTACHED,
+ wcDocker.EVENT.DETACHED, wcDocker.EVENT.VISIBILITY_CHANGED,
+ ], function(ev) {
+ myPanel.on(ev, that.resizedContainer.bind(myPanel));
});
- }
+ that.resizedContainer.apply(myPanel);
+ }
+
+ // Bind events only if they are configurable
+ if (that.canHide) {
+ _.each([wcDocker.EVENT.CLOSED, wcDocker.EVENT.VISIBILITY_CHANGED],
+ function(ev) {
+ myPanel.on(ev, that.handleVisibility.bind(myPanel, ev));
+ });
+ }
+ },
+ });
+ }
+ },
+ eventFunc: function(eventName) {
+ var name = $(this).data('pgAdminName');
+
+ try {
+ pgBrowser.Events.trigger(
+ 'pgadmin-browser:panel', eventName, this, arguments
+ );
+ pgBrowser.Events.trigger(
+ 'pgadmin-browser:panel:' + eventName, this, arguments
+ );
+
+ if (name) {
+ pgBrowser.Events.trigger(
+ 'pgadmin-browser:panel-' + name, eventName, this, arguments
+ );
+ pgBrowser.Events.trigger(
+ 'pgadmin-browser:panel-' + name + ':' + eventName, this, arguments
+ );
}
- });
- }
- },
- eventFunc: function(eventName) {
- var name = $(this).data('pgAdminName');
-
- try {
- pgBrowser.Events.trigger('pgadmin-browser:panel', eventName, this, arguments);
- pgBrowser.Events.trigger('pgadmin-browser:panel:' + eventName, this, arguments);
-
- if (name) {
- pgBrowser.Events.trigger('pgadmin-browser:panel-' + name, eventName, this, arguments);
- pgBrowser.Events.trigger('pgadmin-browser:panel-' + name + ':' + eventName, this, arguments);
+ } catch (e) {
+ console.warn(e.stack || e);
}
- } catch (e) {
- console.log(e);
- }
- },
- resizedContainer: function() {
- var p = this;
-
- if (p.pgElContainer && !p.pgResizeTimeout) {
- if (!p.isVisible()) {
- clearTimeout(p.pgResizeTimeout);
- p.pgResizeTimeout = null;
+ },
+ resizedContainer: function() {
+ var p = this;
- return;
- }
- p.pgResizeTimeout = setTimeout(
- function() {
- var w = p.width();
+ if (p.pgElContainer && !p.pgResizeTimeout) {
+ if (!p.isVisible()) {
+ clearTimeout(p.pgResizeTimeout);
p.pgResizeTimeout = null;
- if (w <= 480) {
- w = 'xs';
- } else if (w < 600) {
- w = 'sm';
- } else if (w < 768) {
- w = 'md';
- } else {
- w = 'lg';
- }
-
- p.pgElContainer.attr('el', w);
- },
- 100
- );
- }
- },
- handleVisibility: function(eventName) {
- // Currently this function only works with dashboard panel but
- // as per need it can be extended
- if (this._type != 'dashboard' || _.isUndefined(pgAdmin.Dashboard))
- return;
-
- if (eventName == 'panelClosed') {
- pgBrowser.save_current_layout(pgBrowser);
- pgAdmin.Dashboard.toggleVisibility(false);
- }
- else if (eventName == 'panelVisibilityChanged') {
- if (pgBrowser.tree) {
+ return;
+ }
+ p.pgResizeTimeout = setTimeout(
+ function() {
+ var w = p.width();
+ p.pgResizeTimeout = null;
+
+ if (w <= 480) {
+ w = 'xs';
+ } else if (w < 600) {
+ w = 'sm';
+ } else if (w < 768) {
+ w = 'md';
+ } else {
+ w = 'lg';
+ }
+
+ p.pgElContainer.attr('el', w);
+ },
+ 100
+ );
+ }
+ },
+ handleVisibility: function(eventName) {
+ // Currently this function only works with dashboard panel but
+ // as per need it can be extended
+ if (this._type != 'dashboard' || _.isUndefined(pgAdmin.Dashboard))
+ return;
+
+ if (eventName == 'panelClosed') {
pgBrowser.save_current_layout(pgBrowser);
- var selectedNode = pgBrowser.tree.selected();
- // Discontinue this event after first time visible
- this.off(wcDocker.EVENT.VISIBILITY_CHANGED);
- if (!_.isUndefined(pgAdmin.Dashboard))
- pgAdmin.Dashboard.toggleVisibility(true);
- // Explicitly trigger tree selected event when we add the tab.
- pgBrowser.Events.trigger('pgadmin-browser:tree:selected', selectedNode,
- pgBrowser.tree.itemData(selectedNode), pgBrowser.Node);
+ pgAdmin.Dashboard.toggleVisibility(false);
+ } else if (eventName == 'panelVisibilityChanged') {
+ if (pgBrowser.tree) {
+ pgBrowser.save_current_layout(pgBrowser);
+ var selectedNode = pgBrowser.tree.selected();
+ // Discontinue this event after first time visible
+ this.off(wcDocker.EVENT.VISIBILITY_CHANGED);
+ if (!_.isUndefined(pgAdmin.Dashboard))
+ pgAdmin.Dashboard.toggleVisibility(true);
+ // Explicitly trigger tree selected event when we add the tab.
+ pgBrowser.Events.trigger('pgadmin-browser:tree:selected', selectedNode,
+ pgBrowser.tree.itemData(selectedNode), pgBrowser.Node);
+ }
}
- }
- }
+ },
- });
+ });
- return pgAdmin.Browser.Panel;
-});
+ return pgAdmin.Browser.Panel;
+ });
diff --git a/web/pgadmin/browser/static/js/wizard.js b/web/pgadmin/browser/static/js/wizard.js
index 2f2209a7..56b1edf2 100644
--- a/web/pgadmin/browser/static/js/wizard.js
+++ b/web/pgadmin/browser/static/js/wizard.js
@@ -1,20 +1,29 @@
-define(
- ['underscore', 'backbone', 'sources/pgadmin', 'pgadmin.browser', 'sources/gettext'],
-function(_, Backbone, pgAdmin, pgBrowser, gettext) {
+define([
+ 'underscore', 'jquery', 'backbone', 'sources/pgadmin', 'pgadmin.browser',
+ 'sources/gettext',
+], function(_, $, Backbone, pgAdmin, pgBrowser, gettext) {
- pgBrowser = pgBrowser || pgAdmin.Browser || {};
+ var wcDocker = window.wcDocker;
/* Wizard individual Page Model */
- var WizardPage = pgBrowser.WizardPage = Backbone.Model.extend({
+ pgBrowser.WizardPage = Backbone.Model.extend({
defaults: {
- id: undefined, /* Id */
- page_title: undefined, /* Page Title */
- view: undefined, /* A Backbone View */
- html: undefined, /* HTML tags to be rendered */
- image: undefined, /* Left hand side image */
- disable_prev: false, /* Previous Button Flag */
- disable_next: false, /* Next Button Flag */
- disable_cancel: false, /* Cancel Button Flag */
+ id: undefined,
+ /* Id */
+ page_title: undefined,
+ /* Page Title */
+ view: undefined,
+ /* A Backbone View */
+ html: undefined,
+ /* HTML tags to be rendered */
+ image: undefined,
+ /* Left hand side image */
+ disable_prev: false,
+ /* Previous Button Flag */
+ disable_next: false,
+ /* Next Button Flag */
+ disable_cancel: false,
+ /* Cancel Button Flag */
show_progress_bar: '',
/* Callback for OnLoad */
onLoad: function() {
@@ -24,119 +33,124 @@ function(_, Backbone, pgAdmin, pgBrowser, gettext) {
beforeNext: function() {
return true;
},
- onNext: function(){},
+ onNext: function() {},
onBefore: function() {},
/* Callback for before Previous */
beforePrev: function() {
return true;
- }
- }
+ },
+ },
});
- var Wizard = pgBrowser.Wizard = Backbone.View.extend({
+ pgBrowser.Wizard = Backbone.View.extend({
options: {
- title: 'Wizard', /* Main Wizard Title */
- image: 'left_panel.png', /* TODO:: We can use default image here */
- curr_page: 0, /* Current Page to Load */
+ title: 'Wizard',
+ /* Main Wizard Title */
+ image: 'left_panel.png',
+ /* TODO:: We can use default image here */
+ curr_page: 0,
+ /* Current Page to Load */
disable_next: false,
disable_prev: false,
disable_finish: false,
disable_cancel: false,
- show_header_cancel_btn: false, /* show cancel button at wizard header */
- show_header_maximize_btn: false, /* show maximize button at wizard header */
+ show_header_cancel_btn: false,
+ /* show cancel button at wizard header */
+ show_header_maximize_btn: false,
+ /* show maximize button at wizard header */
dialog_api: null,
height: 400,
width: 650,
show_left_panel: true,
- wizard_help: ''
+ wizard_help: '',
},
tmpl: _.template(
- "
"
- + " "
- + "
"
- + " <% if (this.options.show_left_panel) { %>"
- + "
"
- + "

"
- + " <% } %>"
- + "
"
- + " <% if ( typeof show_description != 'undefined'){ %>"
- + "
"
- + " <%= show_description %>"
- + "
"
- + " <% } %>"
- + "
<% if (show_progress_bar) { %>"
- + "
<%= show_progress_bar %>
<% } %>"
- + "
"
- + "
"
- + "
"
- + "
"
- + "
"
- + "
"
- + " "
- + "
"
- + " "
- + "
"),
+ '
' +
+ ' ' +
+ '
' +
+ ' <% if (this.options.show_left_panel) { %>' +
+ '
' +
+ '

' +
+ ' <% } %>' +
+ '
' +
+ ' <% if ( typeof show_description != "undefined"){ %>' +
+ '
' +
+ ' <%= show_description %>' +
+ '
' +
+ ' <% } %>' +
+ '
<% if (show_progress_bar) { %>' +
+ '
<%= show_progress_bar %>
<% } %>' +
+ '
' +
+ '
' +
+ '
' +
+ '
' +
+ '
' +
+ '
' +
+ ' ' +
+ '
' +
+ ' ' +
+ '
'),
events: {
- "click button.wizard-next" : "nextPage",
- "click button.wizard-back" : "prevPage",
- "click button.wizard-cancel" : "onCancel",
- "click button.wizard-cancel-event" : "onCancel",
- "click button.wizard-maximize-event" : "onMaximize",
- "click button.wizard-finish" : "finishWizard",
- "click button.wizard-help" : "onDialogHelp",
- "click a.close-error" : "closeErrorMsg",
+ 'click button.wizard-next': 'nextPage',
+ 'click button.wizard-back': 'prevPage',
+ 'click button.wizard-cancel': 'onCancel',
+ 'click button.wizard-cancel-event': 'onCancel',
+ 'click button.wizard-maximize-event': 'onMaximize',
+ 'click button.wizard-finish': 'finishWizard',
+ 'click button.wizard-help': 'onDialogHelp',
+ 'click a.close-error': 'closeErrorMsg',
},
initialize: function(options) {
this.options = _.extend({}, this.options, options.options);
@@ -150,15 +164,17 @@ function(_, Backbone, pgAdmin, pgBrowser, gettext) {
this.options.disable_prev = (this.options.disable_prev ? true : this.evalASFunc(this.currPage.disable_prev));
this.options.disable_cancel = (this.currPage.canCancel ? true : this.evalASFunc(this.currPage.disable_cancel));
- var that = this;
-
/* HTML Content */
- if (data.html) { data.content = data.html; }
+ if (data.html) {
+ data.content = data.html;
+ }
/* Backbone View */
- else if (data.view) { data.content = data.view.render().el;}
+ else if (data.view) {
+ data.content = data.view.render().el;
+ }
$(this.el).html(this.tmpl(data));
- $(this.el).find(".wizard-right-panel_content").html(data.content);
+ $(this.el).find('.wizard-right-panel_content').html(data.content);
/* OnLoad Callback */
this.onLoad();
@@ -166,15 +182,16 @@ function(_, Backbone, pgAdmin, pgBrowser, gettext) {
return this;
},
nextPage: function() {
- if (!this.beforeNext()) { return false; }
+ if (!this.beforeNext()) {
+ return false;
+ }
var page_id = this.onNext();
- if (page_id ) {
+ if (page_id) {
this.currPage = this.collection.get(page_id).toJSON();
this.options.curr_page = this.collection.indexOf(this.collection.get(page_id));
- }
- else if (this.options.curr_page < (this.collection.length-1)) {
+ } else if (this.options.curr_page < (this.collection.length - 1)) {
this.options.curr_page = this.options.curr_page + 1;
this.currPage = this.collection.at(this.options.curr_page).toJSON();
}
@@ -185,15 +202,16 @@ function(_, Backbone, pgAdmin, pgBrowser, gettext) {
return this.render();
},
prevPage: function() {
- if (!this.beforePrev()) { return false; }
+ if (!this.beforePrev()) {
+ return false;
+ }
var page_id = this.onPrev();
- if (page_id){
+ if (page_id) {
this.currPage = this.collection.get(page_id).toJSON();
this.options.curr_page = this.collection.indexOf(this.collection.get(page_id));
- }
- else if (this.options.curr_page > 0) {
+ } else if (this.options.curr_page > 0) {
this.options.curr_page = this.options.curr_page - 1;
this.currPage = this.collection.at(this.options.curr_page).toJSON();
}
@@ -212,41 +230,37 @@ function(_, Backbone, pgAdmin, pgBrowser, gettext) {
return true;
},
enableDisableNext: function(disable) {
- if (typeof(disable) != 'undefined') {
- this.options.disable_next = disable;
- }
- else if (this.options.curr_page >= (this.collection.length-1)) {
- this.options.disable_next = true;
- }
- else {
- this.options.disable_next = false;
- }
+ if (typeof(disable) != 'undefined') {
+ this.options.disable_next = disable;
+ } else if (this.options.curr_page >= (this.collection.length - 1)) {
+ this.options.disable_next = true;
+ } else {
+ this.options.disable_next = false;
+ }
},
enableDisablePrev: function(disable) {
- if (typeof(disable) != 'undefined') {
- this.options.disable_prev = disable;
- }
- else if (this.options.curr_page <= 0) {
- this.options.disable_prev = true;
- }
- else {
- this.options.disable_prev = false;
- }
+ if (typeof(disable) != 'undefined') {
+ this.options.disable_prev = disable;
+ } else if (this.options.curr_page <= 0) {
+ this.options.disable_prev = true;
+ } else {
+ this.options.disable_prev = false;
+ }
},
closeErrorMsg: function() {
$(this.el).find('.pg-prop-status-bar .alert-text').empty();
- $(this.el).find('.pg-prop-status-bar').css("visibility", "hidden");
+ $(this.el).find('.pg-prop-status-bar').css('visibility', 'hidden');
},
- beforeNext: function(){
+ beforeNext: function() {
return this.evalASFunc(this.currPage.beforeNext);
},
- beforePrev: function(){
+ beforePrev: function() {
return this.evalASFunc(this.currPage.beforePrev);
},
- onPrev: function(){
+ onPrev: function() {
return this.evalASFunc(this.currPage.onPrev);
},
- onNext: function(){
+ onNext: function() {
return this.evalASFunc(this.currPage.onNext);
},
onLoad: function() {
@@ -261,12 +275,12 @@ function(_, Backbone, pgAdmin, pgBrowser, gettext) {
},
onMaximize: function() {
var dialog_api = this.options.dialog_api,
- old_classes, _el = this.$el.find('.wizard-maximize-event');
+ _el = this.$el.find('.wizard-maximize-event');
// If no dialog api found then return
- if(!dialog_api) return;
+ if (!dialog_api) return;
- if(dialog_api.isMaximized()) {
+ if (dialog_api.isMaximized()) {
// toggle the icon
_el.removeClass('ajs-maximized');
dialog_api.restore();
@@ -297,7 +311,7 @@ function(_, Backbone, pgAdmin, pgBrowser, gettext) {
pnlDialogHelp.focus();
iframe.openURL(this.options.wizard_help);
- }
+ },
});
return pgBrowser;
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index d433b8e2..95e57e10 100755
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -534,7 +534,7 @@ var getFolderInfo = function(path, file_type) {
// Display an activity indicator.
$('.fileinfo').find('span.activity').html(
- '

'
+ '

'
);
var post_data = {