Commit Graph

1237 Commits

Author SHA1 Message Date
George Stephanis 2a15dbbe1b Declare ajaxurl as a global. jshint 2015-08-14 11:10:55 -04:00
George Stephanis 14c88fe5e5 Don't trigger a change after having just finished saving!
That’s silly!  Plus it’ll set up the leave page blocker again.
2015-08-14 11:08:26 -04:00
George Stephanis 6e1388d334 Set the key to `rates` not the variable rates. 2015-08-14 11:08:00 -04:00
Manos Psychogyiopoulos 9652d881f9 child selector 2015-08-14 09:46:22 +03:00
Manos Psychogyiopoulos a86403f884 toggle metabox classes on boxes added via ajax 2015-08-14 09:38:22 +03:00
Claudio Sanches 086566092a Minify files 2015-08-13 23:37:04 -03:00
George Stephanis 085ab57571 Better success callback. 2015-08-13 17:54:31 -04:00
George Stephanis 2aa1650f54 Rearrange things to get ajax working.
Spread them out throughout WooCommerce.
2015-08-13 17:49:59 -04:00
George Stephanis ec287f116f Add ajax submission processing.
Not quite finished yet, as the add_action isn’t catching.
2015-08-13 16:57:54 -04:00
George Stephanis 6b04e1b889 IT'S PEANUT BUTTER COMMA TIME
:dancing banana:
2015-08-13 15:22:05 -04:00
George Stephanis a3182a6b48 Move the export into the View.
Also:

* Use the correct rates, as data.rates may be out of date (or maybe
not, yay pass by reference?)
* Use rowData.postcode and rowData.city, not rowData.tax_rate_postcode
and rowData.tax_rate_city — those are wrong (my mistake earlier)
2015-08-13 14:58:19 -04:00
George Stephanis 2d097a8f4c Minified version of new js file. 2015-08-13 14:29:01 -04:00
George Stephanis 3c83e4ee4c Declare vars. jshint. 2015-08-13 14:27:50 -04:00
George Stephanis c243b431d5 Handle the deleting of rows as well.
Delete can accept one or more selected rows.
2015-08-13 14:25:38 -04:00
George Stephanis 3a87b98ba6 Rewrite onAddNewRow for Backbone models. 2015-08-13 14:10:47 -04:00
George Stephanis 0e902de9c8 Move new row and deletion inside the view. 2015-08-13 13:07:20 -04:00
George Stephanis b50af4839c Whitespace tidy. 2015-08-13 13:07:00 -04:00
George Stephanis 6dddc2ad84 Moving initialize up to the top. 2015-08-13 13:01:42 -04:00
George Stephanis 22b14e254f Single quotes for jshint coding standards. 2015-08-13 12:29:40 -04:00
George Stephanis d86814d6f1 Disable sorting when searching. 2015-08-13 12:13:05 -04:00
George Stephanis 64ef2a6c5c Remove several now unneeded log commands. 2015-08-13 12:00:10 -04:00
George Stephanis e888f65b4d Simplify how we're tracking single value changes as well. 2015-08-13 11:59:34 -04:00
George Stephanis 525d6987d3 Change how we're saving / logging order changes. 2015-08-13 11:59:12 -04:00
George Stephanis b4bd433342 Update the unsaved message to give better data. 2015-08-13 11:58:09 -04:00
George Stephanis 411d77aae8 Only update if necessary. 2015-08-12 17:26:10 -04:00
George Stephanis 9c58efeefd Make sure we're sorting by numbers, not strings. 2015-08-12 17:18:46 -04:00
George Stephanis d191914e2f Update the rate order on sort. 2015-08-12 17:18:32 -04:00
George Stephanis e10064d0fe Revert back to passing in array values. We can indexBy in JS 2015-08-12 17:17:39 -04:00
George Stephanis e7347ecca4 Handle sorting by tax_rate_order. 2015-08-12 15:29:33 -04:00
George Stephanis f77b77e335 New template for empty set. 2015-08-12 15:29:17 -04:00
George Stephanis 4581289fee Drat, wanted `event.data.view` not `view` 2015-08-12 15:05:00 -04:00
George Stephanis 6e169e313f `_.size()` can run on an object, `.length` cannot. 2015-08-12 15:03:50 -04:00
George Stephanis a587f9c5a9 Pull listeners back in to the view. 2015-08-12 15:01:27 -04:00
George Stephanis 91d8ce1bd4 Move deletion block to be adjacent to creation block. 2015-08-12 14:44:24 -04:00
George Stephanis 1b435e18c2 Move search triggers. 2015-08-12 14:44:05 -04:00
George Stephanis 059e9a9494 Better to run down here when needed. 2015-08-12 14:43:48 -04:00
George Stephanis 506a1141f7 Should be an array, not an object. 2015-08-12 14:41:52 -04:00
George Stephanis 72c16a2472 Let's do a simpler way of changing Object to array.
Underscore gives us lots of tools, it would be a shame not to use them.
2015-08-12 14:39:34 -04:00
George Stephanis c326b8f54d Add a way to get filtered rates -- affected by search. 2015-08-12 14:31:07 -04:00
George Stephanis c65f5b17b2 Set up listeners for searches. 2015-08-12 14:30:52 -04:00
George Stephanis 435ef9218f Optimize the search field selector. 2015-08-12 14:30:26 -04:00
George Stephanis 4e1922e9be new updateUrl function to store search queries and pagination changes in the url.
This makes it easier for folks to bookmark a page, share a url, etc.
2015-08-12 14:19:45 -04:00
George Stephanis 10255fcdd4 Globally cache the search field from the dom. 2015-08-12 14:19:01 -04:00
George Stephanis e9f0325ac1 Sanitize the pagination for scope on load. 2015-08-12 14:17:50 -04:00
George Stephanis c4f3d90588 Add in tracking for changes. 2015-08-12 12:59:13 -04:00
George Stephanis 56218b0824 Add in a notification for unsaved changes. 2015-08-12 12:59:13 -04:00
George Stephanis 843fef6e26 Remove debugging per_page override. 2015-08-12 12:59:12 -04:00
George Stephanis a7a12f977e Kinda silly to have min length 3 on a field that holds max 2. 2015-08-12 12:59:12 -04:00
George Stephanis 5ff9e2e52e Reorder where we're running the before unload 2015-08-12 12:59:12 -04:00
George Stephanis d8fdfe4c87 Manually trigger change event. Why?
Unsure why this needs to be manually triggered, but its seems to.
2015-08-12 12:59:12 -04:00
George Stephanis a8b1cabc0b Be more specific as to what we're listening for. 2015-08-12 12:59:12 -04:00
George Stephanis ca13f5785b Listen for changes in form inputs.
When one is found, update the model to reflect the data in the dom.
2015-08-12 12:59:12 -04:00
George Stephanis efcb9f5048 Give the Model a setRateAttribute method.
This should simplify updating when listening for changes in the form.
2015-08-12 12:59:12 -04:00
George Stephanis 1332ef4a71 String.trim() polyfill. 2015-08-12 12:59:12 -04:00
George Stephanis d52c4d1fde Don't base size of news off the dom. 2015-08-12 12:59:11 -04:00
George Stephanis 1a066ebbe0 Swap to associative array for model. 2015-08-12 12:59:11 -04:00
George Stephanis 388a584914 Not actually used, comment it out. 2015-08-12 12:59:11 -04:00
George Stephanis 9887fbaf50 Probably tidier to use `event` and not `e` 2015-08-12 12:59:11 -04:00
George Stephanis 0996778567 Figured out how to avoid hardcoding the instance. 2015-08-12 12:59:11 -04:00
George Stephanis 5783a20794 Don't use `this` in a callback with the wrong context.
@todo: Find a way to stop needing to refer to the specific instance
from the abstract class.
2015-08-12 12:59:11 -04:00
George Stephanis 0fb85f4656 Use $(window).on() instead of window.addEventListener. Because ¯\_(ツ)_/¯ 2015-08-12 12:59:10 -04:00
George Stephanis dc649e2964 JS objects + trailing commas = sad IE 2015-08-12 12:59:10 -04:00
George Stephanis 187e253177 Remove some debugging 2015-08-12 12:59:10 -04:00
George Stephanis ce7cb1f65d Add a `beforeunload` event to prompt before leaving with unsaved changes. 2015-08-12 12:59:10 -04:00
George Stephanis b4682d7f2d Change how things are called to the new bb render. 2015-08-12 12:59:10 -04:00
George Stephanis f7c2223a23 Change the structure to Backbone models/views. 2015-08-12 12:59:10 -04:00
George Stephanis 9e5abc22ad Whoops! Comma, not semicolon. 2015-08-12 12:59:10 -04:00
George Stephanis b75093b640 Optimization, save the $table selector to avoid some dom lookups. 2015-08-12 12:59:09 -04:00
George Stephanis 386ec26fb9 Whitespace tweaks. 2015-08-12 12:59:09 -04:00
George Stephanis e197bc242f Retool the export to use the global object, not parsing out of the dom. 2015-08-12 12:59:09 -04:00
George Stephanis a1d7121c99 Update the current page when the number is changed. 2015-08-12 12:59:09 -04:00
George Stephanis 7bebbaff9e Pagination now works by first, prev, next, last.
Still need to get number based pagination working.
2015-08-12 12:59:09 -04:00
George Stephanis cf59aec17d Add in and populate pagination template.
The buttons don’t actually do anything yet, but it outputs accurately
and inherits core styles.
2015-08-12 12:59:09 -04:00
George Stephanis d9b2907ae2 Begin to handle pagination.
This lets the initial view display only a single page, future commits
will add in the paginater.
2015-08-12 12:59:08 -04:00
George Stephanis 0608bcce19 The name resetter should also be run after each render. 2015-08-12 12:59:08 -04:00
George Stephanis f9fd4ada58 Wrap the rendering code inside a function that the data can be passed to. 2015-08-12 12:59:08 -04:00
George Stephanis 7985aec296 Ernest the JS so none of it evaluates before dom ready. 2015-08-12 12:59:08 -04:00
George Stephanis 26b95a4d80 Inline documentation explaining some functionality. 2015-08-12 12:59:08 -04:00
George Stephanis 7c60e48b0c Add some code comments. 2015-08-12 12:59:08 -04:00
George Stephanis 37f10c18cd Reposition when autocomplete is triggered.
Also, instead of searching through the whole dom, only search in the
tbody.
2015-08-12 12:59:07 -04:00
George Stephanis 308c7f8676 Whitespace tweaks 2015-08-12 12:59:07 -04:00
George Stephanis ea0b9b96b9 Optimization: Don't use $.size(), use native Object.length instead. 2015-08-12 12:59:07 -04:00
George Stephanis 676af1f308 JSHint fixes.
The other advantage of splitting js out of php files — jshint can run
on it! :) :) :)
2015-08-12 12:59:07 -04:00
George Stephanis d3922a96cd Don't constantly rescan the dom for tbody
We have a cached version of $tbody a level up.
2015-08-12 12:59:07 -04:00
George Stephanis 1b035b43a3 Swap `jQuery` to `$`
It’s more readable, and safe to do as we’ve aliased it back in the
enclosure.
2015-08-12 12:59:07 -04:00
George Stephanis 8c47c0df1d Migrate current_class from php to js 2015-08-12 12:59:07 -04:00
George Stephanis 52d4ea822c Extract 'No Rows Selected' string 2015-08-12 12:59:07 -04:00
George Stephanis 18293cf365 Extract the autocomplete for states and countries data.
Localize it!
2015-08-12 12:59:06 -04:00
George Stephanis 5d5a64753d Migrate csv columns to localize script. 2015-08-12 12:59:06 -04:00
George Stephanis 39749c4563 Move js in from php template file. 2015-08-12 12:59:06 -04:00
George Stephanis c128e4f826 Change variable name to consistent `$tbody` 2015-08-12 12:59:06 -04:00
George Stephanis a63ef876d7 Rename and tweak how js is registered.
Thanks @claudiosmweb for the suggestion to match existing conventions.
2015-08-12 12:59:06 -04:00
George Stephanis 0ed5f40fa2 Prefix template name with `wc-`
Good call, @mikejolley
2015-08-12 12:59:06 -04:00
George Stephanis a59ed70774 Big changeover to JS templating for the table.
Switching over to building the table with JS — wp.template.

We are now using the same JS template for existing rows and newly
generated rows on the fly — this should simplify things moving forward.

I’ve also started building stuff in an external JS file rather than
straight on the page.  Will continue migrating things to it and
localizing as needed.

Saved ( 2 * displayed tax rates - 1 ) db queries per page load by doing
the locations all in one query and then parceling them out in php.

More coming.
2015-08-12 12:59:06 -04:00
Emil Kjær Eriksen 733a9a2fe5 checkout.js now looks for payment method in entire checkout form 2015-08-12 18:03:59 +02:00
Claudio Sanches ac1986412c Stay on the same page when delete a variation 2015-08-12 11:39:55 -03:00
Mike Jolley a3d376b5c3 Tab hiding with some theme markup.
Closes #8791
2015-08-12 12:05:31 +01:00
Mike Jolley 9986240793 min 2015-08-12 11:51:10 +01:00
Claudio Sanches aae3581a28 Minify files for 2.4.2 2015-08-11 14:22:54 -03:00
Mike Jolley 08c751f4fe Minify scripts 2015-08-11 10:46:25 +01:00
Mike Jolley 03f16d6833 Made tab panel selector more specific to avoid theme conflicts. 2015-08-11 10:46:21 +01:00
Shiva Poudel 3fe37da3f7 Allow support for variable in backbone modal template in extensions 2015-08-06 11:08:02 +05:45
Shiva Poudel 4cc26ab799 Backbone modal template to support wp.template 2015-08-06 10:22:53 +05:45
Claudio Sanches 5e91d27b66 Minify 2015-08-05 16:52:54 -03:00
Claudio Sanches 054dfe0c7b Changed default Underscore's template for wp.template in API Keys 2015-08-05 15:02:55 -03:00
Brent Shepherd 501f0b752f Save product type before saving variations
WooCommerce prior to WC 2.4 saved the product type before any variations were saved because
WC_Meta_Box_Product_Data::save_variations() was called by WC_Meta_Box_Product_Data::save().
However, in WC 2.4 the variations are saved independently of other data about the containing
variable product, including product type. Because the product type hasn't been saved yet,
extensions that need to save their own variation level meta data can't know when saving
variations if the product is of the type they want to act on. They also can't check `$_POST`
to find out when saving variations, because 'product-type' isn't passed to that as it's
variable level meta data, not variation level meta data.

This patch passes the product type along with the variation level meta data when saving variations.
It then uses that to save the product type if the variable product has not yet been saved (and
therefore the product type has never been stored, which means calling get_product() would instantiate
a 'simple' product, as that is the default product type). This can lead to fatal errors if callbacks
expect the product type to be variable and attempt to call methods that only exist on those product
types, like variable_product_sync().

It will also update the product type if it was previously saved but has since changed. This prevents
fatal errors like that mentioned above but caused by switching from one product type, like a simple
product, to another, like a variable product.
2015-07-31 11:42:21 -07:00
Mike Jolley 67788f971d Merge pull request #8696 from franticpsyx/animate-variations-changes
[2.4] Animate variations script DOM modifications
2015-07-31 12:44:18 +01:00
Mike Jolley 82f50cedb0 Allow menu_order sorting like in 2.3
Also allow setting manually to allow sorting between pages.

Fixes #8690
2015-07-31 12:39:23 +01:00
Manos Psychogyiopoulos f5691fd82a animate variations script markup changes 2015-07-31 14:04:55 +03:00
Claudio Sanches b28c6db7f5 Added button to dismiss variation error notices 2015-07-29 19:56:33 -03:00
Claudio Sanches d0e34588aa Updated all .page-selector when change page, closes #8681 2015-07-29 19:25:17 -03:00
Claudio Sanches 8780f2c1ef Fixed chmod to jquery-serializejson 2015-07-29 19:16:27 -03:00
Mike Jolley e3ff9d6e24 Minify 2015-07-28 16:22:00 +01:00
Manos Psychogyiopoulos dae10a962c allow product variations data refresh 2015-07-28 15:34:04 +03:00
Mike Jolley 890bcff302 Fix cart ajax endpoint
@claudiosmweb @BFTrick
2015-07-27 20:02:40 +01:00
Mike Jolley ef5b2007f6 min 2015-07-27 19:03:17 +01:00
Mike Jolley 97bbdb63fa Merge pull request #8663 from roykho/gallery-images
gallery images where not saving
2015-07-27 18:27:00 +01:00
roykho 4203a2cf83 minified file 2015-07-27 10:21:58 -07:00
Claudio Sanches b0ce578541 Show errors for admin ajax variations 2015-07-27 14:16:52 -03:00
roykho 4a8712053f gallery images where not saving 2015-07-27 09:57:21 -07:00
Mike Jolley d0c2c10c47 Made the linter happy 2015-07-27 17:55:37 +01:00
Mike Jolley 0ab151562a Fix issues with trailing slashes on permalinks
Closes #8658
2015-07-27 11:56:07 +01:00
Claudio Sanches f8dfc64db7 Fixed postcode/zip reset in address i18n script, closes #8646 2015-07-24 18:24:33 -03:00
Claudio Sanches 77e8c19330 Minify files for #8631 2015-07-21 20:36:46 -03:00
Brent Shepherd 23418214d0 Trigger do_variation_action + '_ajax_data'
To allow extensions which add their own variation bulk actions to pass
data back to WooCommerce core's handler so that only one ajax call
is necessary for updating the data.

Previously, a duplicate ajax call would be required as trigger() does
not capture the callbacks return value.
2015-07-21 15:41:13 -07:00
Claudio Sanches 791c20ae51 Added param for exclude posts from wc-product-search, closes #8613 2015-07-20 13:41:14 -03:00
Claudio Sanches 5e97a68e3d Fixed calendar when added new variation, closes #8533 2015-07-15 12:26:38 -03:00
Claudio Sanches 8b5fff38e4 Stop alerts when use delete all variations action 2015-07-14 14:08:59 -03:00
Mike Jolley c707f771ad serializeJSON to maintain POST data structure
@claudiosmweb
2015-07-14 13:49:45 +01:00
Mike Jolley 44b91e5b66 Revert triggerHandlers back to trigger() for BW compat
Closes #8569
2015-07-14 10:28:49 +01:00
Claudio Sanches ee1263db9c Minify 2015-07-10 20:17:47 -03:00
Claudio Sanches b8a28bdab4 Admin variations - Cancel button reset the default form values
@mikejolley
2015-07-10 20:16:35 -03:00
Mike Jolley 3ec4003bbb Move add variation button and toolbars 2015-07-11 00:04:16 +01:00
Claudio Sanches 8b4711f655 Admin variations - Removed alert when add new variation 2015-07-10 19:30:14 -03:00
Claudio Sanches 441d3c44bb Admin variations - Go to previous page when delete the last variation in a page 2015-07-10 18:57:38 -03:00
Claudio Sanches 501742b07f Updated grunt dependencies 2015-07-10 18:48:04 -03:00
Claudio Sanches e0c1cc7784 Admin variations - Turn on save button when add new variation 2015-07-10 18:31:38 -03:00
Claudio Sanches e9fc799f97 Admin variations - Fix product add and save methods
Allow add new variations and stay at the same page
When save will set up the pagination again

@mikejolley
2015-07-10 18:22:05 -03:00
Mike Jolley 2834eff221 Merge branch 'variations-8477'
Conflicts:
	assets/js/frontend/add-to-cart-variation.js
	assets/js/frontend/add-to-cart-variation.min.js
	assets/js/frontend/add-to-cart.min.js
	assets/js/frontend/checkout.min.js
	assets/js/frontend/geolocation.min.js
2015-07-10 11:37:05 +01:00
Claudio Sanches 62d879e86c Fixed all jshint errors #4680 2015-07-10 02:13:30 -03:00
Claudio Sanches 76b312b9e7 Use always min.js files on admin 2015-07-10 01:32:30 -03:00
Claudio Sanches 319bcd48e6 Updated accounting.js 2015-07-10 01:31:57 -03:00
Claudio Sanches 987a789367 Admin variations - Show link all variations bulk action 2015-07-10 00:49:52 -03:00
Claudio Sanches a64695b7f5 Admin variations - Added new triggers and removed data-product_id 2015-07-09 17:31:48 -03:00
Claudio Sanches ce08c336e9 Updated jquery.payment.js to version 1.2.4 2015-07-09 17:17:34 -03:00
Claudio Sanches 3c409e07e1 Fixed js coding standards in assets/js/frontend/checkout.js 2015-07-09 15:04:00 -03:00
Mike Jolley 9531258ee6 Treat each form separately. 2015-07-09 16:21:17 +01:00
Mike Jolley 65f19d5ca7 Ajax variation handling
If there are more variations than the threshold allows (set to 20
currently) this loads the matching variation via ajax instead of inline
in the HTML. #8477
2015-07-09 15:56:20 +01:00
Claudio Sanches 1ce7719c98 Save variable defaults via ajax 2015-07-08 22:50:32 -03:00
Claudio Sanches 88c0f61007 Fixed js standards 2015-07-08 22:33:58 -03:00