diff --git a/ckan/public/scripts/application.js b/ckan/public/scripts/application.js
index a19b0e18a20..2f3efa81b5c 100644
--- a/ckan/public/scripts/application.js
+++ b/ckan/public/scripts/application.js
@@ -150,12 +150,15 @@ CKAN.View.UrlEditor = Backbone.View.extend({
new RegExp('-*$', 'g')];
// Default options
- if (!this.options.apiUrl)
+ if (!this.options.apiUrl) {
this.options.apiUrl = CKAN.SITE_URL + '/api/2/util/is_slug_valid';
- if (!this.options.MAX_SLUG_LENGTH)
+ }
+ if (!this.options.MAX_SLUG_LENGTH) {
this.options.MAX_SLUG_LENGTH = 90;
- if (!this.options.editMode)
+ }
+ if (!this.options.editMode) {
this.options.editMode = false;
+ }
if (this.options.editMode) {
this.originalUrl = this.urlInput.val();
@@ -201,9 +204,9 @@ CKAN.View.UrlEditor = Backbone.View.extend({
/* Called when the title changes */
titleChanged: function() {
- if (this.disableTitleChanged) return;
+ if (this.disableTitleChanged) { return; }
var title = this.titleInput.val();
- if (title == this.lastTitle) return;
+ if (title == this.lastTitle) { return; }
this.lastTitle = title;
slug = this.titleToSlug(title);
@@ -214,8 +217,8 @@ CKAN.View.UrlEditor = Backbone.View.extend({
/* Called when the url is changed */
urlChanged: function() {
var slug = this.urlInput.val();
- if (this.updateTimer) clearTimeout(this.updateTimer);
- if (slug.length==0) {
+ if (this.updateTimer) { clearTimeout(this.updateTimer); }
+ if (slug.length) {
this.urlSuffix.html('...');
}
else {
@@ -260,7 +263,7 @@ CKAN.View.UrlEditor = Backbone.View.extend({
} else {
this.validMsg.html(''+CKAN.Strings.urlIsNotAvailable+'');
}
- },
+ }
});
@@ -335,7 +338,7 @@ CKAN.View.ResourceEditor = Backbone.View.extend({
* Open the 'Add New Resource' special-case panel on the right.
*/
openAddPanel: function(e) {
- if (e) e.preventDefault();
+ if (e) { e.preventDefault(); }
var panel = this.el.find('.resource-panel');
var addLi = this.el.find('.resource-list-add li');
this.el.find('.resource-list li').removeClass('active');
@@ -349,7 +352,7 @@ CKAN.View.ResourceEditor = Backbone.View.extend({
* Close the panel on the right.
*/
closePanel: function(e) {
- if (e) e.preventDefault();
+ if (e) { e.preventDefault(); }
this.el.find('.resource-list li').removeClass('active');
this.el.find('.resource-panel').hide();
},
@@ -367,7 +370,7 @@ CKAN.View.ResourceEditor = Backbone.View.extend({
$.each(table.find('input,textarea,select'), function(input_index, input) {
var name = $(input).attr('name');
if (name) {
- name = name.replace(/(resources__)\d+(.*)/, '$1'+index+'$2')
+ name = name.replace(/(resources__)\d+(.*)/, '$1'+index+'$2');
$(input).attr('name',name);
}
});
@@ -383,7 +386,7 @@ CKAN.View.ResourceEditor = Backbone.View.extend({
var name = $(input).attr('name') || '';
var splitName=name.split('__');
if (splitName.length>1) {
- var myId = parseInt(splitName[1])
+ var myId = parseInt(splitName[1],10);
maxId = Math.max(myId, maxId);
}
});
@@ -433,14 +436,14 @@ CKAN.View.Resource = Backbone.View.extend({
num: this.options.position,
resource_icon: '/images/icons/page_white.png',
resourceTypeOptions: [
- ['file', 'Data File']
- , ['api', 'API']
- , ['visualization', 'Visualization']
- , ['image', 'Image']
- , ['metadata', 'Metadata']
- , ['documentation', 'Documentation']
- , ['code', 'Code']
- , ['example', 'Example']
+ ['file', 'Data File'],
+ ['api', 'API'],
+ ['visualization', 'Visualization'],
+ ['image', 'Image'],
+ ['metadata', 'Metadata'],
+ ['documentation', 'Documentation'],
+ ['code', 'Code'],
+ ['example', 'Example']
]
};
// Generate DOM elements
@@ -484,7 +487,7 @@ CKAN.View.Resource = Backbone.View.extend({
var errorText = '';
var newLine = false;
$.each(v,function(index,value) {
- if (newLine) errorText += '
';
+ if (newLine) { errorText += '
'; }
errorText += value;
newLine = true;
});
@@ -550,7 +553,7 @@ CKAN.View.Resource = Backbone.View.extend({
* Closes all other panels on the right and opens my editor panel.
*/
openMyPanel: function(e) {
- if (e) e.preventDefault();
+ if (e) { e.preventDefault(); }
// Close all tables
var panel = this.table.parents('.resource-panel');
panel.find('.resource-details').hide();
@@ -579,7 +582,7 @@ CKAN.View.Resource = Backbone.View.extend({
var self = this;
$.each(this.raw_resource, function(key,value) {
// Skip the known keys
- if (self.reservedWord(key)) return;
+ if (self.reservedWord(key)) { return; }
self.addDynamicExtra(key,value);
});
this.table.find('.add-resource-extra').click(function(e) {
@@ -603,7 +606,7 @@ CKAN.View.Resource = Backbone.View.extend({
var _key = inputKey.val();
var key = _key.trim().replace(/\s+/g,'');
// Don't allow you to create an extra called mimetype (etc)
- if (self.reservedWord(key)) key='';
+ if (self.reservedWord(key)) { key=''; }
// Set or unset the field's name
if (key.length) {
var newName = 'resources__'+self.options.position+'__'+key;
@@ -626,32 +629,31 @@ CKAN.View.Resource = Backbone.View.extend({
setExtraName();
},
reservedWord: function(word) {
- return word=='cache_last_updated'
- || word=='cache_url'
- || word=='dataset'
- || word=='description'
- || word=='displaytitle'
- || word=='extras'
- || word=='format'
- || word=='hash'
- || word=='id'
- || word=='last_modified'
- || word=='mimetype'
- || word=='mimetype_inner'
- || word=='name'
- || word=='package_id'
- || word=='position'
- || word=='resource_group_id'
- || word=='resource_type'
- || word=='revision_id'
- || word=='revision_timestamp'
- || word=='size'
- || word=='size_extra'
- || word=='state'
- || word=='url'
- || word=='webstore_last_updated'
- || word=='webstore_url'
- ;
+ return word=='cache_last_updated' ||
+ word=='cache_url' ||
+ word=='dataset' ||
+ word=='description' ||
+ word=='displaytitle' ||
+ word=='extras' ||
+ word=='format' ||
+ word=='hash' ||
+ word=='id' ||
+ word=='last_modified' ||
+ word=='mimetype' ||
+ word=='mimetype_inner' ||
+ word=='name' ||
+ word=='package_id' ||
+ word=='position' ||
+ word=='resource_group_id' ||
+ word=='resource_type' ||
+ word=='revision_id' ||
+ word=='revision_timestamp' ||
+ word=='size' ||
+ word=='size_extra' ||
+ word=='state' ||
+ word=='url' ||
+ word=='webstore_last_updated' ||
+ word=='webstore_url';
},
/*
* Called when my model is destroyed. Remove me from the page.
@@ -663,7 +665,7 @@ CKAN.View.Resource = Backbone.View.extend({
onDatastoreEnabledChange: function(e) {
var isChecked = this.table.find('.js-datastore-enabled-checkbox').prop('checked');
var webstore_url = isChecked ? 'enabled' : null;
- this.model.set({webstore_url: webstore_url});;
+ this.model.set({webstore_url: webstore_url});
this.table.find('.js-datastore-enabled-text').val(webstore_url);
}
});
@@ -686,7 +688,7 @@ CKAN.View.ResourceAddTabs = Backbone.View.extend({
reset: function() {
this.el.find('button').removeClass('depressed');
- if (this.subView != null) {
+ if (this.subView) {
this.subView.remove();
this.subView = null;
}
@@ -751,20 +753,17 @@ CKAN.View.ResourceAddLink = Backbone.View.extend({
},
render: function() {
+ var tmpl = null;
if (this.mode=='file') {
- var tmpl = $.tmpl(CKAN.Templates.resourceAddLinkFile);
+ tmpl = $.tmpl(CKAN.Templates.resourceAddLinkFile);
}
else if (this.mode=='api') {
- var tmpl = $.tmpl(CKAN.Templates.resourceAddLinkApi);
+ tmpl = $.tmpl(CKAN.Templates.resourceAddLinkApi);
}
$(this.el).html(tmpl);
return this;
},
- events: {
- 'submit form': 'setResourceInfo',
- },
-
setResourceInfo: function(e) {
e.preventDefault();
@@ -798,6 +797,10 @@ CKAN.View.ResourceAddLink = Backbone.View.extend({
} else {
this.model.set({url: urlVal, resource_type: this.mode});
}
+ },
+
+ events: {
+ 'submit form': 'setResourceInfo'
}
});
@@ -809,12 +812,12 @@ CKAN.View.ResourceAddLink = Backbone.View.extend({
CKAN.Utils = function($, my) {
// Animate the appearance of an element by expanding its height
my.animateHeight = function(element, animTime) {
- if (!animTime) animTime = 350;
+ if (!animTime) { animTime = 350; }
element.show();
var finalHeight = element.height();
element.height(0);
element.animate({height:finalHeight}, animTime);
- }
+ };
my.bindInputChanges = function(input, callback) {
input.keyup(callback);
@@ -826,7 +829,7 @@ CKAN.Utils = function($, my) {
my.setupWelcomeBanner = function(banner) {
var cookieName = 'ckan_killtopbar';
- var isKilled = ($.cookie(cookieName)!=null);
+ var isKilled = ($.cookie(cookieName)!==null);
if (!isKilled) {
banner.show();
// Bind to the close button
@@ -884,14 +887,13 @@ CKAN.Utils = function($, my) {
var field_name_regex = /^(\S+)__(\d+)__(\S+)$/;
var split = old_name.match(field_name_regex);
- var new_name = split[1] + '__' + (parseInt(split[2]) + 1) + '__' + split[3]
+ var new_name = split[1] + '__' + (parseInt(split[2],10) + 1) + '__' + split[3];
- input_box.attr('name', new_name)
- input_box.attr('id', new_name)
+ input_box.attr('name', new_name);
+ input_box.attr('id', new_name);
parent_dd.before(
- '' +
- '