From 965e54e8df8de90150ffa2ce34661b256a3efbff Mon Sep 17 00:00:00 2001 From: Robert Gregor Date: Tue, 28 Jul 2015 20:20:55 -0400 Subject: [PATCH] issue #32 - 2/3 complete - added localHistory implementation and open / close trigger --- .idea/enom_pro.iml | 2 + .idea/jsLibraryMappings.xml | 2 +- jsTestDriver.conf | 10 +++ src/modules/addons/enom_pro/css/admin.css | 27 ++++---- src/modules/addons/enom_pro/css/admin.less | 24 ++++--- .../includes/page_import_tld_pricing.php | 2 +- .../page_import_tld_pricing_bulk_process.php | 16 ++--- .../addons/enom_pro/js/jquery.admin.js | 68 +++++++++++++++++-- tests/qunit/jquery.admin.test.js | 14 ++++ 9 files changed, 123 insertions(+), 42 deletions(-) create mode 100644 jsTestDriver.conf create mode 100644 tests/qunit/jquery.admin.test.js diff --git a/.idea/enom_pro.iml b/.idea/enom_pro.iml index 488da3d..7b826ab 100644 --- a/.idea/enom_pro.iml +++ b/.idea/enom_pro.iml @@ -3,6 +3,7 @@ + @@ -39,5 +40,6 @@ + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml index 01862e9..750b376 100644 --- a/.idea/jsLibraryMappings.xml +++ b/.idea/jsLibraryMappings.xml @@ -3,6 +3,6 @@ - + \ No newline at end of file diff --git a/jsTestDriver.conf b/jsTestDriver.conf new file mode 100644 index 0000000..72a2a69 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/src/modules/addons/enom_pro/css/admin.css b/src/modules/addons/enom_pro/css/admin.css index 1fa099a..bf81283 100644 --- a/src/modules/addons/enom_pro/css/admin.css +++ b/src/modules/addons/enom_pro/css/admin.css @@ -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 */ } @@ -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; } @@ -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; } diff --git a/src/modules/addons/enom_pro/css/admin.less b/src/modules/addons/enom_pro/css/admin.less index c114f46..0d85c5b 100644 --- a/src/modules/addons/enom_pro/css/admin.less +++ b/src/modules/addons/enom_pro/css/admin.less @@ -538,6 +538,9 @@ Licensed from Orion IP Ventures, LLC text-align: center; } } + .close-bulk-editor { + display: none; + } //Bulk Pricing Turbo Editor .fixedBulk { #bulkRightWrap, @@ -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%; @@ -558,18 +571,10 @@ 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; } @@ -577,9 +582,6 @@ Licensed from Orion IP Ventures, LLC #bulkPricingImportWrap, #bulkPricingMetaWrap { width: 100%; margin: 0; - h3, p { - display: none; - } } #bulkPricingMetaWrap { margin-top: 5px; diff --git a/src/modules/addons/enom_pro/includes/page_import_tld_pricing.php b/src/modules/addons/enom_pro/includes/page_import_tld_pricing.php index 56d04ea..d3b94c6 100644 --- a/src/modules/addons/enom_pro/includes/page_import_tld_pricing.php +++ b/src/modules/addons/enom_pro/includes/page_import_tld_pricing.php @@ -160,7 +160,7 @@ class="clear_all btn btn-default btn-xs">Clear All Pricing before saving.
-

Search

+

Search

diff --git a/src/modules/addons/enom_pro/includes/page_import_tld_pricing_bulk_process.php b/src/modules/addons/enom_pro/includes/page_import_tld_pricing_bulk_process.php index f20e6d2..3a722e7 100644 --- a/src/modules/addons/enom_pro/includes/page_import_tld_pricing_bulk_process.php +++ b/src/modules/addons/enom_pro/includes/page_import_tld_pricing_bulk_process.php @@ -1,14 +1,8 @@
- -
+
-

Bulk Import

- -

Import all TLDs on this page

+

Bulk Import New!

Minimum Markup
- +
Preferred Markup
- +
-

Domain Pricing Meta

+

Domain Pricing Meta

Pricing for a total of getAllDomainsPricing() ) ?> TLDs.
Pricing data last updated get_price_cache_date(); ?> diff --git a/src/modules/addons/enom_pro/js/jquery.admin.js b/src/modules/addons/enom_pro/js/jquery.admin.js index 985901f..efaf61a 100644 --- a/src/modules/addons/enom_pro/js/jquery.admin.js +++ b/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); } @@ -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), @@ -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); }); @@ -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'); @@ -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; @@ -1212,10 +1270,10 @@ try { } } } + }); enom_pro.init(); }); //end jQuery Ready } catch (err) { alert('Enom PRO JS Error: ' + err); - } \ No newline at end of file diff --git a/tests/qunit/jquery.admin.test.js b/tests/qunit/jquery.admin.test.js new file mode 100644 index 0000000..5dbce40 --- /dev/null +++ b/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')); + } +}); \ No newline at end of file