Skip to content

Commit

Permalink
MISC: JS coding standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpenny authored and chrispenny committed Mar 10, 2019
1 parent 3b6dfd7 commit f05957a
Show file tree
Hide file tree
Showing 5 changed files with 2,169 additions and 61 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/embargo-expiry.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/dist/js/embargo-expiry.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 28 additions & 18 deletions client/src/bundles/embargo-expiry.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,33 @@ window.jQuery.entwine('ss', ($) => {
let versionedObjectPublishButton = null;
let versionedObjectSaveButton = null;

const showHidePublishButton = (hasEmbargo) => {
const showHidePublishButtons = (hasEmbargo) => {
if (hasEmbargo) {
if (siteTreePublishButton !== null) {
siteTreePublishButton.detach();
}

if (versionedObjectPublishButton !== null) {
versionedObjectPublishButton.detach();
}
} else {
if (siteTreePublishButton !== null) {
siteTreePublishButton.insertAfter(siteTreeSaveButton);
}

if (versionedObjectPublishButton !== null) {
versionedObjectPublishButton.insertAfter(versionedObjectSaveButton);
}
hidePublishButton();

return;
}

showPublishButton();
};

const hidePublishButton = () => {
if (siteTreePublishButton !== null) {
siteTreePublishButton.detach();
}

if (versionedObjectPublishButton !== null) {
versionedObjectPublishButton.detach();
}
};

const showPublishButton = () => {
if (siteTreePublishButton !== null) {
siteTreePublishButton.insertAfter(siteTreeSaveButton);
}

if (versionedObjectPublishButton !== null) {
versionedObjectPublishButton.insertAfter(versionedObjectSaveButton);
}
};

Expand All @@ -34,10 +44,10 @@ window.jQuery.entwine('ss', ($) => {
versionedObjectPublishButton = $('button[name="action_doPublish"]');
versionedObjectSaveButton = $('button[name="action_doSave"]');

showHidePublishButton($(this).val().length > 0);
showHidePublishButtons($(this).val().length > 0);
},
onchange() {
showHidePublishButton($(this).val().length > 0);
showHidePublishButtons($(this).val().length > 0);
},
});
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
},
"homepage": "https://github.com/silverstripe-terraformers/silverstripe-embargo-expiry",
"devDependencies": {
"@silverstripe/webpack-config": "^0.4.1"
"@silverstripe/eslint-config": "0.0.5",
"@silverstripe/webpack-config": "^0.11.0"
},
"dependencies": {
"jquery": "^3.2.1"
Expand Down
Loading

0 comments on commit f05957a

Please sign in to comment.