Skip to content

Commit

Permalink
issue #32 - 2/3 complete - added localHistory implementation and open…
Browse files Browse the repository at this point in the history
… / close trigger
  • Loading branch information
Robert Gregor committed Jul 29, 2015
1 parent 75b506e commit 965e54e
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .idea/enom_pro.iml

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

2 changes: 1 addition & 1 deletion .idea/jsLibraryMappings.xml

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

10 changes: 10 additions & 0 deletions jsTestDriver.conf
@@ -0,0 +1,10 @@
load:
- 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js'
- 'http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js'
- src/modules/addons/enom_pro/js/jquery.admin.js

test:
- tests/qunit/*.js

#serve:
# - build/encoded_prep/modules/addons/enom_pro/css/admin.min.css
27 changes: 14 additions & 13 deletions src/modules/addons/enom_pro/css/admin.css
Expand Up @@ -483,6 +483,9 @@ Licensed from Orion IP Ventures, LLC
.enom_pro_output #enom_pro_pricing_import_page nav {
text-align: center;
}
.enom_pro_output .close-bulk-editor {
display: none;
}
.enom_pro_output .fixedBulk {
/* Left hand bulk update */
}
Expand All @@ -495,22 +498,26 @@ Licensed from Orion IP Ventures, LLC
z-index: 3;
overflow-y: auto;
}
.enom_pro_output .fixedBulk #bulkRightWrap .hidden-turbo,
.enom_pro_output .fixedBulk #bulkLeftWrap .hidden-turbo {
display: none;
}
.enom_pro_output .fixedBulk .close-bulk-editor {
display: block;
position: absolute;
top: 2.5px;
right: 5px;
font-size: 24pt;
}
.enom_pro_output .fixedBulk #bulkLeftWrap {
padding: 3px;
width: 25%;
margin: 0;
border-radius: 0;
}
.enom_pro_output .fixedBulk #bulkLeftWrap .close {
display: none;
}
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingImportWrap .col-xs-12 {
padding: 0;
}
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingImportWrap label[for="percentMarkup"],
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingImportWrap label[for="preferredPercentMarkup"] {
display: none;
}
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingImportWrap .pull-right {
float: none !important;
}
Expand All @@ -519,12 +526,6 @@ Licensed from Orion IP Ventures, LLC
width: 100%;
margin: 0;
}
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingImportWrap h3,
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingMetaWrap h3,
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingImportWrap p,
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingMetaWrap p {
display: none;
}
.enom_pro_output .fixedBulk #bulkLeftWrap #bulkPricingMetaWrap {
margin-top: 5px;
}
Expand Down
24 changes: 13 additions & 11 deletions src/modules/addons/enom_pro/css/admin.less
Expand Up @@ -538,6 +538,9 @@ Licensed from Orion IP Ventures, LLC
text-align: center;
}
}
.close-bulk-editor {
display: none;
}
//Bulk Pricing Turbo Editor
.fixedBulk {
#bulkRightWrap,
Expand All @@ -548,6 +551,16 @@ Licensed from Orion IP Ventures, LLC
height: 100%;
z-index: 3;
overflow-y: auto;
.hidden-turbo {
display: none;
}
}
.close-bulk-editor {
display: block;
position: absolute;
top: 2.5px;
right: 5px;
font-size: 24pt;
}
/* Left hand bulk update */
@leftWidth: 25%;
Expand All @@ -558,28 +571,17 @@ Licensed from Orion IP Ventures, LLC
margin: 0;
border-radius: 0;

.close {
display: none;
}
#bulkPricingImportWrap {
.col-xs-12 {
padding: 0;
}
label[for="percentMarkup"],
label[for="preferredPercentMarkup"] {
display: none;
}

.pull-right {
float: none !important;
}
}
#bulkPricingImportWrap, #bulkPricingMetaWrap {
width: 100%;
margin: 0;
h3, p {
display: none;
}
}
#bulkPricingMetaWrap {
margin-top: 5px;
Expand Down
Expand Up @@ -160,7 +160,7 @@ class="clear_all btn btn-default btn-xs">Clear All Pricing</a> before saving.</
<div id="bulkRightWrap">

<form method="GET" id="tldSearchForm">
<h4>Search</h4>
<h4 class="hidden-turbo">Search</h4>
<input type="hidden" name="module" value="enom_pro" />
<input type="hidden" name="view" value="pricing_import" />

Expand Down
@@ -1,14 +1,8 @@
<div class="well row" id="bulkLeftWrap">
<button type="button"
class="close"
data-dismiss="alert"
aria-hidden="true">&uarr;</button>

<div class="col-lg-6" id="bulkPricingImportWrap">
<div class="enom-pro-icon enom-pro-icon-cancel-circle close-bulk-editor" title="Close Bulk Pricing editor"></div>

<h3>Bulk Import</h3>

<p>Import all TLDs on this page</p>
<h3 class="hidden-turbo"><span class="btn btn-primary btn-lg open-bulk-editor"><span class="enom-pro-icon enom-pro-icon-tag"></span> Bulk Import <span class="badge">New!</span></h3>

<form class="bulkImport form-inline"
role="form"
Expand All @@ -17,7 +11,7 @@ class="close"
<div class="form-group col-xs-12">
<h5 class="ep_pop" title="Minimum Markup" data-placement="auto top" data-content="Enter the minimum acceptable markup. Use this to cover credit card processing fees, for example.">Minimum Markup</h5>
<div class="input-group">
<label for="percentMarkup" class="input-group-addon">Markup</label>
<label for="percentMarkup" class="input-group-addon hidden-turbo">Markup</label>
<input type="number"
min="0"
step="0.01"
Expand Down Expand Up @@ -47,7 +41,7 @@ class="form-control input-sm"/>
<div class="form-group col-xs-12">
<h5 class="ep_pop" title="Preferred Markup" data-placement="auto top" data-content="The Markup you'd like to make, while still being protected from under-selling.">Preferred Markup</h5>
<div class="input-group">
<label for="preferredPercentMarkup" class="input-group-addon">Markup</label>
<label for="preferredPercentMarkup" class="input-group-addon hidden-turbo">Markup</label>
<input type="number"
min="0"
max="500"
Expand Down Expand Up @@ -128,7 +122,7 @@ class="btn btn-danger dropdown-toggle"
</form>
</div>
<div class="col-lg-6" id="bulkPricingMetaWrap">
<h3>Domain Pricing Meta</h3>
<h3 class="hidden-turbo">Domain Pricing Meta</h3>
Pricing for a total of <?php echo count( $this->getAllDomainsPricing() ) ?> TLDs.
<br/>
Pricing data last updated <?php echo $this->get_price_cache_date(); ?>
Expand Down
68 changes: 63 additions & 5 deletions src/modules/addons/enom_pro/js/jquery.admin.js
@@ -1,5 +1,4 @@
try {

function precise_round(num, decimals) {
return Math.round(num * Math.pow(10, decimals)) / Math.pow(10, decimals);
}
Expand Down Expand Up @@ -142,7 +141,7 @@ try {
preferredWholeMarkup = parseFloat($("#preferredWholeMarkup").val()) || 0,
doRound = (round != -1),
newPriceDouble = 0,
$elems = enom_pro.getTLDInputSet();
$elems = enom_pro.getTLDInputSet();
$.each($elems, function (k, value) {
//If min. is lt preferred, use preferred, else use minimum
var $elem = $(value),
Expand Down Expand Up @@ -490,7 +489,7 @@ try {
inputSet = [];
$.each(checks, function (k, v) {
var tld = $(v).prop('name'),
filter = $('#overWriteWHMCS').prop('checked') ? ', [data-whmcs]' : '',
filter = $('#overWriteWHMCS').prop('checked') ? ', [data-whmcs]' : '',
$inputs = $("[data-tld='" + tld + "']").filter(':not(a, .btn' + filter + ')');
inputSet = $.merge(inputSet, $inputs);
});
Expand All @@ -508,13 +507,28 @@ try {
* @constant int SAVE_INTERVAL_CLICK How long to wait after a click before sending result to server
*/
SAVE_INTERVAL_CLICK: 750,
openBulkPricingEditor: function () {
this.showBulkPricingTurboEditor();
this.setLocalStorage('openBulkPricingEditor', true);
},
closeBulkPricingEditor: function () {
this.hideBulkPricingTurboEditor();
this.setLocalStorage('openBulkPricingEditor', false);
},
/**
* TLD Pricing Import Page
*/
initPricingImport: function () {
this.getLocalStorage('openBulkPricingEditor') === 'true' ? this.showBulkPricingTurboEditor() : null;
$('.close-bulk-editor').on('click', function() {
enom_pro.closeBulkPricingEditor();
});
$('.open-bulk-editor').on('click', function() {
enom_pro.openBulkPricingEditor();
return false;
});
$('.dropdown-toggle').dropdown();
//TODO restore / hide based on localStorage
// this.showBulkPricingTurboEditor();

$('.tldAction').on('click', function () {
var $check = $(this).closest('td').find('input');
Expand Down Expand Up @@ -1203,7 +1217,51 @@ try {
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
},
/**
* @constant
*/
LOCAL_STORAGE_PREFIX: 'enom_pro_',
/**
* Gets an item from local storage if supported
* @param key
* @returns {boolean} false of failure
*/
getLocalStorage: function (key) {
if (this.support.localStorage()) {
return window.localStorage.getItem(this.getLocalStorageKey(key));
}
return false;
},
/**
*
* @param key
* @param value
* @returns {boolean} true on set, false on fail
*/
setLocalStorage: function (key, value) {
if (this.support.localStorage()) {
window.localStorage.setItem(this.getLocalStorageKey(key), value);
return true;
}
return false;
},
/**
* @private
* @param unPrefixedKey {string}
* @returns {string}
*/
getLocalStorageKey: function (unPrefixedKey) {
return this.LOCAL_STORAGE_PREFIX + unPrefixedKey;
},
/**
* Simple feature detection
* @property
*/
support: {
/**
* @method localStorage
* @returns {boolean}
*/
localStorage: function () {
try {
return 'localStorage' in window && window['localStorage'] !== null;
Expand All @@ -1212,10 +1270,10 @@ try {
}
}
}

});
enom_pro.init();
}); //end jQuery Ready
} catch (err) {
alert('Enom PRO JS Error: ' + err);

}
14 changes: 14 additions & 0 deletions tests/qunit/jquery.admin.test.js
@@ -0,0 +1,14 @@
TestCase('localStorage', {
testSupportsLocalStorage: function () {
assertTrue('supports', enom_pro.support.localStorage());
},
testGetLocalStorageKey: function () {
var got_key = enom_pro.getLocalStorageKey('key');
assertEquals('key is wrong', 'enom_pro_key', got_key);
},
testSaveLocalStorage: function (){
var set = 'bam';
enom_pro.setLocalStorage('foobar', set);
assertEquals('get localstorage failed', set, enom_pro.getLocalStorage('foobar'));
}
});

0 comments on commit 965e54e

Please sign in to comment.