-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factorize both Js and css code associated with download button.
* Rename class associated with download button to a more generic name 'extensionActionButtonWrapper'. Also ensured that the same class and html is used between the different view. * Add {js/css}/common/ files for functionality and style shared by the different view. * Factorize the existing css used to render the "extension action button" * Factorize functionality allowing to update the button state into multiple function: - click handler: extensionButtonClick - updateExtensionButtonState - setExtensionButtonState * The following design should allow to easily associates new state with the "extension action" button. (i.e an 'update' state)
- Loading branch information
Showing
8 changed files
with
141 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
body { | ||
font-family: 'Lucida Grande', 'Lucida Sans Unicode', helvetica, arial, Verdana, sans-serif; | ||
} | ||
|
||
input.extensionActionButton { | ||
color: white; | ||
font-weight: bold; | ||
cursor: pointer; | ||
text-align: center; | ||
border: 1px solid white; | ||
line-height: 1.5; | ||
display: block; | ||
text-transform: uppercase; | ||
-moz-border-radius: 3px; | ||
-webkit-border-radius: 3px; | ||
-khtml-border-radius: 3px; | ||
border-radius: 3px; | ||
-webkit-box-shadow: black 0 0 3px; | ||
box-shadow: black 0 0 3px; | ||
-moz-box-shadow: 0px 0px 3px black; | ||
font-family: 'Lucida Grande', 'Lucida Sans Unicode', helvetica, arial, Verdana, sans-serif; | ||
} | ||
|
||
input.extensionActionButton:hover { | ||
-webkit-box-shadow: black 0 0 6px; | ||
box-shadow: black 0 0 6px; | ||
-moz-box-shadow: 0px 0px 6px black; | ||
} | ||
|
||
input.extensionDownloadButton, input.extensionInstallButton { | ||
background-color: #2277aa; | ||
} | ||
|
||
input.extensionDownloadButton:hover, input.extensionInstallButton:hover { | ||
background-color: #00aaaa; | ||
} | ||
|
||
input.extensionUninstallButton { | ||
background-color: #007f09; | ||
} | ||
|
||
input.extensionUninstallButton:hover { | ||
background-color: #6eb04b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var midas = midas || {}; | ||
midas.slicerappstore = midas.slicerappstore || {}; | ||
|
||
/** | ||
* Called when a user clicks the extension button (download, install or uninstall) | ||
*/ | ||
midas.slicerappstore.extensionButtonClick = function() { | ||
var extensionId = $(this).attr('element'); | ||
if(!window.extensions_manager_model || $(this).hasClass('extensionDownloadButton')) { | ||
var url = json.global.webroot+'/slicerappstore/index/downloadextension?extensionId='+extensionId; | ||
window.location.assign(url); | ||
} else if($(this).hasClass('extensionInstallButton')) { | ||
window.extensions_manager_model.downloadAndInstallExtension(extensionId); | ||
} else if($(this).hasClass('extensionUninstallButton')) { | ||
window.extensions_manager_model.uninstallExtension($(this).attr('extensionname')); | ||
} | ||
} | ||
|
||
/** | ||
* Update extension button state considering 'window.extensions_manager_model' | ||
* @param extensionName Name of the extension associated with the button to update | ||
*/ | ||
midas.slicerappstore.updateExtensionButtonState = function(extensionName) { | ||
if(!window.extensions_manager_model) { | ||
midas.slicerappstore.setExtensionButtonState(extensionName, 'download'); | ||
} else { | ||
var buttonState = 'install'; | ||
if(window.extensions_manager_model.isExtensionInstalled(extensionName)) { | ||
buttonState = 'uninstall'; | ||
} | ||
midas.slicerappstore.setExtensionButtonState(extensionName, buttonState); | ||
} | ||
} | ||
|
||
/** | ||
* Set extension button state | ||
* @param extensionName Name of the extension associated with the button to update | ||
* @param buttonState Either 'download', 'install' or 'uninstall' | ||
*/ | ||
midas.slicerappstore.setExtensionButtonState = function(extensionName, buttonState) { | ||
if (buttonState != 'download' && buttonState != 'install' && buttonState != 'uninstall') { | ||
alert('Unknown buttonState:' + buttonState); | ||
} | ||
var buttonText = buttonState.charAt(0).toUpperCase() + buttonState.slice(1); | ||
var buttonClass = 'extension' + buttonText + 'Button'; | ||
$('input[extensionname="' + extensionName + '"]').val(buttonText) | ||
.removeClass('extensionDownloadButton extensionInstallButton extensionUninstallButton') | ||
.addClass(buttonClass) | ||
.unbind('click').click(midas.slicerappstore.extensionButtonClick); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.