2017-05-01 05:54:48 +02:00
|
|
|
(function ($) {
|
2012-08-06 08:14:34 +02:00
|
|
|
"use strict";
|
2012-08-01 05:00:43 +02:00
|
|
|
|
2017-05-01 05:54:48 +02:00
|
|
|
$.entwine('ss', function ($) {
|
2012-08-01 05:00:43 +02:00
|
|
|
|
2012-08-23 05:53:14 +02:00
|
|
|
$('#SectionID ul li').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
onadd: function () {
|
2012-08-23 05:44:47 +02:00
|
|
|
this.addClass('ui-button ss-ui-button ui-corner-all ui-state-default ui-widget ui-button-text-only');
|
|
|
|
this.parents('ul').removeClass('ui-tabs-nav');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-23 05:53:14 +02:00
|
|
|
$('#SectionID input[type=radio]').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
onadd: function () {
|
2012-08-23 05:44:47 +02:00
|
|
|
// Checks to see what radio button is selected
|
|
|
|
if (this.is(':checked')) {
|
|
|
|
this.change();
|
|
|
|
}
|
|
|
|
},
|
2017-05-01 05:54:48 +02:00
|
|
|
onchange: function (e) {
|
2012-08-23 05:44:47 +02:00
|
|
|
// Remove selected class from radio buttons
|
2012-08-23 05:53:14 +02:00
|
|
|
$('#SectionID').find('li').removeClass('selected');
|
2012-08-23 05:44:47 +02:00
|
|
|
//If radio button is checked then add the selected class
|
|
|
|
if (this.is(':checked')) {
|
|
|
|
this.parent('li').addClass('selected');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-01 05:00:43 +02:00
|
|
|
$('.ss-gridfield .action.dms-delete').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
onclick: function (e) {
|
2012-08-01 05:00:43 +02:00
|
|
|
//work out how many pages are left attached to this document
|
|
|
|
var pagesCount = this.data('pages-count');
|
|
|
|
var pagesCountAfterDeletion = pagesCount - 1;
|
|
|
|
var addS = 's';
|
2012-08-06 08:14:34 +02:00
|
|
|
if (pagesCountAfterDeletion === 1) {
|
|
|
|
addS = '';
|
|
|
|
}
|
2012-08-01 05:00:43 +02:00
|
|
|
|
|
|
|
//display an appropriate message
|
|
|
|
var message = '';
|
2012-08-06 08:14:34 +02:00
|
|
|
if (this.hasClass('dms-delete-last-warning')) {
|
|
|
|
message = "Permanently delete this document?\n\nWarning: this document is attached only to this page, deleting it here will delete it permanently.";
|
|
|
|
}
|
|
|
|
if (this.hasClass('dms-delete-link-only')) {
|
|
|
|
message = "Unlink this document from this page?\n\nNote: it will remain attached to "+pagesCountAfterDeletion+" other page"+addS+".";
|
|
|
|
}
|
2012-08-01 05:00:43 +02:00
|
|
|
|
2017-05-01 05:54:48 +02:00
|
|
|
if (!confirm(message)) {
|
2012-08-01 05:00:43 +02:00
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
//user says "okay", so go ahead and do the action
|
|
|
|
this._super(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-14 03:03:35 +02:00
|
|
|
$('.ss-gridfield .dms-document-hidden').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
onadd: function () {
|
2012-08-14 03:03:35 +02:00
|
|
|
this.closest('tr').addClass('dms-document-hidden-row');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-07 04:38:40 +02:00
|
|
|
$('.cms-content-actions.south .ss-ui-action-destructive').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
confirmBeforeDelete: function () {
|
2012-08-07 04:38:40 +02:00
|
|
|
var deleteButtons = $('button.dms-delete[data-pages-count=1]');
|
|
|
|
|
|
|
|
//we have page with DMSDocuments on it, and we have documents that only exist on this page
|
|
|
|
if (deleteButtons.length > 0) {
|
|
|
|
var message = "Are you sure you want to delete this page? Deleting this page will delete "+deleteButtons.length;
|
2012-08-07 08:37:10 +02:00
|
|
|
if (deleteButtons.length === 1) {
|
2012-08-07 04:38:40 +02:00
|
|
|
message += " document that is associated only with this page. This document is:\n\n";
|
|
|
|
} else {
|
|
|
|
message += " documents that are associated only with this page. These documents are:\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
//create a list of documents and their IDs
|
2017-05-01 05:54:48 +02:00
|
|
|
deleteButtons.each(function () {
|
2012-08-07 04:38:40 +02:00
|
|
|
var tr = $(this).closest('tr');
|
|
|
|
message += tr.find('.col-ID').text() +' - '+ tr.find('.col-Title').text() +"\n";
|
|
|
|
});
|
|
|
|
|
2017-05-01 05:54:48 +02:00
|
|
|
if (!confirm(message)) {
|
2012-08-07 04:38:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-08-07 08:37:10 +02:00
|
|
|
});
|
2012-08-07 04:38:40 +02:00
|
|
|
|
|
|
|
$('#Form_EditForm_action_deletefromlive').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
onclick: function (e) {
|
2012-08-07 08:37:10 +02:00
|
|
|
if (this.confirmBeforeDelete()) {
|
|
|
|
this._super(e);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-07 04:38:40 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#Form_EditForm_action_delete').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
onclick: function (e) {
|
2012-08-07 08:37:10 +02:00
|
|
|
if (this.confirmBeforeDelete()) {
|
|
|
|
this._super(e);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-07 08:37:34 +02:00
|
|
|
$('.ss-gridfield-item a.file-url').entwine({
|
2017-05-01 05:54:48 +02:00
|
|
|
onclick: function (e) {
|
2012-08-07 08:37:34 +02:00
|
|
|
//make sure the download link doesn't trigger a gridfield edit dialog
|
|
|
|
window.open(this.attr('href'), '_blank');
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
2012-08-07 04:38:40 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-01 05:00:43 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
}(jQuery));
|