mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
Tidy up JS indentation and comments
This commit is contained in:
parent
2ddd20cd6c
commit
9200d83b12
@ -19,7 +19,7 @@
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (bytes >= 1000000000) {
|
if (bytes >= 1000000000) {
|
||||||
return (bytes / 1000000000).toFixed(2) + ' GB';
|
return (bytes / 1000000000).toFixed(2) + ' GB'
|
||||||
}
|
}
|
||||||
if (bytes >= 1000000) {
|
if (bytes >= 1000000) {
|
||||||
return (bytes / 1000000).toFixed(2) + ' MB';
|
return (bytes / 1000000).toFixed(2) + ' MB';
|
||||||
@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
selectdocument: function (documentID, documentName) {
|
selectdocument: function (documentID, documentName) {
|
||||||
if (typeof(documentID) !== "undefined") {
|
if (typeof(documentID) !== "undefined") {
|
||||||
//substitute the ID for the full document name, if no name is present
|
// Substitute the ID for the full document name, if no name is present
|
||||||
if (typeof(documentName) === "undefined") {
|
if (typeof(documentName) === "undefined") {
|
||||||
documentName = documentID;
|
documentName = documentID;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,10 @@
|
|||||||
$(this).closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', true);
|
$(this).closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', true);
|
||||||
},
|
},
|
||||||
onpanelhide: function () {
|
onpanelhide: function () {
|
||||||
$(this).closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', $(this).closest('.document-add-existing').find('.document-list:visible').length > 0);
|
$(this)
|
||||||
|
.closest('.document-add-existing')
|
||||||
|
.find('input.document-autocomplete')
|
||||||
|
.prop('disabled', $(this).closest('.document-add-existing').find('.document-list:visible').length > 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -92,7 +95,6 @@
|
|||||||
doclist.load(
|
doclist.load(
|
||||||
'admin/pages/adddocument/documentlist?pageID=' + $(this).val()
|
'admin/pages/adddocument/documentlist?pageID=' + $(this).val()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -116,8 +118,11 @@
|
|||||||
|
|
||||||
$('body').entwine({
|
$('body').entwine({
|
||||||
onclick: function (event) {
|
onclick: function (event) {
|
||||||
$('.document-list:visible').hide()
|
$('.document-list:visible')
|
||||||
.closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', false);
|
.hide()
|
||||||
|
.closest('.document-add-existing')
|
||||||
|
.find('input.document-autocomplete')
|
||||||
|
.prop('disabled', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -126,6 +131,5 @@
|
|||||||
$('.document-list:visible').hide();
|
$('.document-list:visible').hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
$.entwine('ss', function($) {
|
$.entwine('ss', function($) {
|
||||||
|
|
||||||
$('#DocumentTypeID ul li').entwine({
|
$('#DocumentTypeID ul li').entwine({
|
||||||
onadd: function () {
|
onadd: function () {
|
||||||
this.addClass('ui-button ss-ui-button ui-corner-all ui-state-default ui-widget ui-button-text-only');
|
this.addClass('ui-button ss-ui-button ui-corner-all ui-state-default ui-widget ui-button-text-only');
|
||||||
@ -18,22 +17,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* $('#DocumentTypeID input[type=radio]').entwine({
|
|
||||||
onadd: function() {
|
|
||||||
// Checks to see what radio button is selected
|
|
||||||
if (this.is(':checked')) {
|
|
||||||
this.change();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onchange: function(e) {
|
|
||||||
// Remove selected class from radio buttons
|
|
||||||
$('#DocumentTypeID').find('li').removeClass('selected');
|
|
||||||
//If radio button is checked then add the selected class
|
|
||||||
if (this.is(':checked')) {
|
|
||||||
this.parent('li').addClass('selected');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
$('.permissions input[name="CanViewType"], .permissions input[name="CanEditType"]').entwine({
|
$('.permissions input[name="CanViewType"], .permissions input[name="CanEditType"]').entwine({
|
||||||
onchange: function () {
|
onchange: function () {
|
||||||
if (!this.is(':checked')) {
|
if (!this.is(':checked')) {
|
||||||
@ -51,28 +34,25 @@
|
|||||||
this.trigger('change');
|
this.trigger('change');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.dmsdocment-actions ul li').entwine({
|
$('.dmsdocment-actions ul li').entwine({
|
||||||
onclick: function (e) {
|
onclick: function (e) {
|
||||||
|
// Add active state to the current button
|
||||||
//add active state to the current button
|
|
||||||
$('.dmsdocment-actions ul li').removeClass('dms-active');
|
$('.dmsdocment-actions ul li').removeClass('dms-active');
|
||||||
this.addClass('dms-active');
|
this.addClass('dms-active');
|
||||||
//$('li.dms-active').append('<span class="arrow"></span>');
|
|
||||||
|
|
||||||
//hide all inner field sections
|
// Hide all inner field sections
|
||||||
var panel = $('.dmsdocument-actionspanel:first');
|
var panel = $('.dmsdocument-actionspanel:first');
|
||||||
panel.find('> .fieldgroup > .fieldgroup-field').hide();
|
panel.find('> .fieldgroup > .fieldgroup-field').hide();
|
||||||
|
|
||||||
//show the correct group of controls
|
// Show the correct group of controls
|
||||||
//panel.find('.'+this.data('panel')).closest('div.fieldgroup').show();
|
|
||||||
panel.find('.'+this.data('panel')).show().parents('.fieldgroup-field').show();
|
panel.find('.'+this.data('panel')).show().parents('.fieldgroup-field').show();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#Form_ItemEditForm_Embargo input, #Form_EditForm_Embargo input').entwine({
|
$('#Form_ItemEditForm_Embargo input, #Form_EditForm_Embargo input').entwine({
|
||||||
onchange: function () {
|
onchange: function () {
|
||||||
//selected the date options
|
// Selected the date options
|
||||||
if (this.attr('value') === 'Date') {
|
if (this.attr('value') === 'Date') {
|
||||||
$('.embargoDatetime').children().show();
|
$('.embargoDatetime').children().show();
|
||||||
$('.embargoDatetime').show();
|
$('.embargoDatetime').show();
|
||||||
@ -84,7 +64,7 @@
|
|||||||
|
|
||||||
$('#Form_ItemEditForm_Expiry input, #Form_EditForm_Expiry input').entwine({
|
$('#Form_ItemEditForm_Expiry input, #Form_EditForm_Expiry input').entwine({
|
||||||
onchange: function () {
|
onchange: function () {
|
||||||
//selected the date options
|
// Selected the date options
|
||||||
if (this.attr('value') === 'Date') {
|
if (this.attr('value') === 'Date') {
|
||||||
$('.expiryDatetime').children().show();
|
$('.expiryDatetime').children().show();
|
||||||
$('.expiryDatetime').show();
|
$('.expiryDatetime').show();
|
||||||
@ -96,50 +76,39 @@
|
|||||||
|
|
||||||
$('.dmsdocument-actionspanel').entwine({
|
$('.dmsdocument-actionspanel').entwine({
|
||||||
onadd: function () {
|
onadd: function () {
|
||||||
//do an initial show of the entire panel
|
// Do an initial show of the entire panel
|
||||||
this.show();
|
this.show();
|
||||||
|
|
||||||
//add some extra classes to the replace field containers to make it work with drag and drop uploading
|
// Add some extra classes to the replace field containers to make it work with drag and drop uploading
|
||||||
this.find('.replace').closest('div.fieldgroup-field').addClass('ss-upload').addClass('ss-uploadfield');
|
this.find('.replace').closest('div.fieldgroup-field').addClass('ss-upload').addClass('ss-uploadfield');
|
||||||
|
|
||||||
// add class and hide
|
// Add class and hide
|
||||||
$('.dmsdocument-actionspanel .embargo input.date').closest('.fieldholder-small').addClass('embargoDatetime').hide();
|
$('.dmsdocument-actionspanel .embargo input.date').closest('.fieldholder-small').addClass('embargoDatetime').hide();
|
||||||
$('.dmsdocument-actionspanel .expiry input.date').closest('.fieldholder-small').addClass('expiryDatetime').hide();
|
$('.dmsdocument-actionspanel .expiry input.date').closest('.fieldholder-small').addClass('expiryDatetime').hide();
|
||||||
// We need to duplicate the above functions to work when Adding documents
|
|
||||||
// $('#Form_EditForm_EmbargoedUntilDate_date').closest('.fieldholder-small').addClass('embargoDatetime').hide();
|
|
||||||
// $('#Form_EditForm_ExpireAtDate_date').closest('.fieldholder-small').addClass('expiryDatetime').hide();
|
|
||||||
|
|
||||||
//Add placeholder attribute to date and time fields
|
// Add placeholder attribute to date and time fields
|
||||||
$('.dmsdocument-actionspanel .embargo input.date').attr('placeholder', 'dd-mm-yyyy');
|
$('.dmsdocument-actionspanel .embargo input.date').attr('placeholder', 'dd-mm-yyyy');
|
||||||
$('.dmsdocument-actionspanel .embargo input.time').attr('placeholder', 'hh:mm:ss');
|
$('.dmsdocument-actionspanel .embargo input.time').attr('placeholder', 'hh:mm:ss');
|
||||||
$('.dmsdocument-actionspanel .expiry input.date').attr('placeholder', 'dd-mm-yyyy');
|
$('.dmsdocument-actionspanel .expiry input.date').attr('placeholder', 'dd-mm-yyyy');
|
||||||
$('.dmsdocument-actionspanel .expiry input.time').attr('placeholder', 'hh:mm:ss');
|
$('.dmsdocument-actionspanel .expiry input.time').attr('placeholder', 'hh:mm:ss');
|
||||||
// We need to duplicate to work when adding documents
|
|
||||||
// $('#Form_EditForm_EmbargoedUntilDate_date').attr('placeholder', 'dd-mm-yyyy');
|
|
||||||
// $('#Form_EditForm_EmbargoedUntilDate_time').attr('placeholder', 'hh:mm:ss');
|
|
||||||
// $('#Form_EditForm_ExpireAtDate_date').attr('placeholder', 'dd-mm-yyyy');
|
|
||||||
// $('#Form_EditForm_ExpireAtDate_time').attr('placeholder', 'hh:mm:ss');
|
|
||||||
|
|
||||||
//show the embargo panel when the page loads
|
// Show the embargo panel when the page loads
|
||||||
$('li[data-panel="embargo"]').click();
|
$('li[data-panel="embargo"]').click();
|
||||||
|
|
||||||
//set the initial state of the radio button and the associated dropdown hiding
|
// Set the initial state of the radio button and the associated dropdown hiding
|
||||||
$('.dmsdocument-actionspanel .embargo input[type="radio"][checked]').change();
|
$('.dmsdocument-actionspanel .embargo input[type="radio"][checked]').change();
|
||||||
$('.dmsdocument-actionspanel .expiry input[type="radio"][checked]').change();
|
$('.dmsdocument-actionspanel .expiry input[type="radio"][checked]').change();
|
||||||
//Again we need to duplicate the above function to work when adding documents
|
|
||||||
// $('#Form_EditForm_Embargo input[checked]').change();
|
|
||||||
// $('#Form_EditForm_Expiry input[checked]').change();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#Form_ItemEditForm_action_doDelete').entwine({
|
$('#Form_ItemEditForm_action_doDelete').entwine({
|
||||||
onclick: function (e) {
|
onclick: function (e) {
|
||||||
//work out how many pages are left attached to this document
|
// Work out how many pages are left attached to this document
|
||||||
var form = this.closest('form');
|
var form = this.closest('form');
|
||||||
var pagesCount = form.data('pages-count');
|
var pagesCount = form.data('pages-count');
|
||||||
var relationCount = form.data('relation-count');
|
var relationCount = form.data('relation-count');
|
||||||
|
|
||||||
//display an appropriate message
|
// Display an appropriate message
|
||||||
var message = '';
|
var message = '';
|
||||||
if (pagesCount > 1 || relationCount > 0) {
|
if (pagesCount > 1 || relationCount > 0) {
|
||||||
var pages = '';
|
var pages = '';
|
||||||
@ -166,12 +135,10 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
//user says "okay", so go ahead and do the action
|
// User says "okay", so go ahead and do the action
|
||||||
this._super(e);
|
this._super(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
$.entwine('ss', function ($) {
|
$.entwine('ss', function ($) {
|
||||||
$('.ss-gridfield-item a.file-url').entwine({
|
$('.ss-gridfield-item a.file-url').entwine({
|
||||||
onclick: function (e) {
|
onclick: function (e) {
|
||||||
//make sure the download link doesn't trigger a gridfield edit dialog
|
// Make sure the download link doesn't trigger a gridfield edit dialog
|
||||||
window.open(this.attr('href'), '_blank');
|
window.open(this.attr('href'), '_blank');
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
$.entwine('ss', function ($) {
|
$.entwine('ss', function ($) {
|
||||||
|
|
||||||
$('form.htmleditorfield-linkform input[name=LinkType]').entwine({
|
$('form.htmleditorfield-linkform input[name=LinkType]').entwine({
|
||||||
onchange: function (e) {
|
onchange: function (e) {
|
||||||
this._super(e);
|
this._super(e);
|
||||||
@ -16,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//hide or show the additional document link addition tool
|
// Hide or show the additional document link addition tool
|
||||||
if (show) {
|
if (show) {
|
||||||
form.find('.ss-add').show();
|
form.find('.ss-add').show();
|
||||||
} else {
|
} else {
|
||||||
@ -44,10 +43,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var attributes = {
|
var attributes = {
|
||||||
href : href,
|
href: href,
|
||||||
target : target,
|
target: target,
|
||||||
class : 'documentLink',
|
class: 'documentLink',
|
||||||
title : this.find('.selected-document').text() //title is the text of the selected document
|
// Title is the text of the selected document
|
||||||
|
title: this.find('.selected-document').text()
|
||||||
};
|
};
|
||||||
|
|
||||||
this.modifySelection(function (ed) {
|
this.modifySelection(function (ed) {
|
||||||
@ -70,6 +70,7 @@
|
|||||||
linkDataSource = selectedEl = selectedEl.parents('a:first');
|
linkDataSource = selectedEl = selectedEl.parents('a:first');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linkDataSource && linkDataSource.length) {
|
if (linkDataSource && linkDataSource.length) {
|
||||||
this.modifySelection(function (ed) {
|
this.modifySelection(function (ed) {
|
||||||
ed.selectNode(linkDataSource[0]);
|
ed.selectNode(linkDataSource[0]);
|
||||||
@ -90,7 +91,7 @@
|
|||||||
action = "update";
|
action = "update";
|
||||||
}
|
}
|
||||||
|
|
||||||
//match a document or call the regular link handling
|
// Match a document or call the regular link handling
|
||||||
if (href.match(new RegExp("/^\[" + this.getShortcodeKey() + "(\s*|%20|,)?id=([0-9]+)\]?$/", "i"))) {
|
if (href.match(new RegExp("/^\[" + this.getShortcodeKey() + "(\s*|%20|,)?id=([0-9]+)\]?$/", "i"))) {
|
||||||
var returnArray = {
|
var returnArray = {
|
||||||
LinkType: 'document',
|
LinkType: 'document',
|
||||||
@ -98,20 +99,20 @@
|
|||||||
Description: title
|
Description: title
|
||||||
};
|
};
|
||||||
|
|
||||||
//show the selected document
|
// Show the selected document
|
||||||
$('.document-add-existing').selectdocument(returnArray.DocumentID,returnArray.Description);
|
$('.document-add-existing').selectdocument(returnArray.DocumentID,returnArray.Description);
|
||||||
|
|
||||||
//select the correct radio button
|
// Select the correct radio button
|
||||||
$('form.htmleditorfield-linkform input[name=LinkType][value=document]').click();
|
$('form.htmleditorfield-linkform input[name=LinkType][value=document]').click();
|
||||||
|
|
||||||
return returnArray;
|
return returnArray;
|
||||||
} else {
|
} else {
|
||||||
$('.document-add-existing').selectdocument(); //clear the selected document
|
// Clear the selected document
|
||||||
|
$('.document-add-existing').selectdocument();
|
||||||
$('form.htmleditorfield-linkform .ss-add.ss-upload').hide();
|
$('form.htmleditorfield-linkform .ss-add.ss-upload').hide();
|
||||||
return this._super();
|
return this._super();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
Loading…
Reference in New Issue
Block a user