diff --git a/dist/README.md b/dist/README.md deleted file mode 100644 index 12db1bf..0000000 --- a/dist/README.md +++ /dev/null @@ -1,203 +0,0 @@ -![plentymarkets Logo](http://www.plentymarkets.eu/layout/pm/images/logo/plentymarkets-logo.jpg) - -# plentymarkets CMS library 0.9.1 - -## Update your **Callisto Light 2** to plentymarketsCMStools 0.9.1 - -### Step 1: Download plentymarketsCMStools 0.9.1 - -You can download this repository as a [zip archive](https://github.com/plentymarkets/plenty-cms-library/archive/master.zip). -All required files can be found in `dist/`-folder - -### Step 2: Upload required files - -Upload the following files to `LAYOUT_FOLDER/js/plenty/`: -- `plentymarketsCMStools-0.9.1.js` -- `lang/de_DE.json` (You have to create the folder `lang` manually) -- `lang/en_EN.json` - -### Step 3: Include new files in your template - -Download and open `LAYOUT_FOLDER/js/plenty/scripts.json` and change the file to use: -```js -{ - "PageDesignGlobal": { - "head": [], - "body": [ - . - . - . - "plenty/plentymarketsCMStools-0.9.1.js" - ] - }, - . - . - . -} -``` -If the `scripts.json` doesn't exist see [Update your Callisto Light using dependecyInjector](#update-your-callisto-light-using-dependecyinjector). -Upload the edited file back to your webspace (you will override the existing version). - -### Step 4: Load language files in your PageDesign-templates - -Open templates: `PageDesignContent`, `PageDesignCheckout`, `PageDesignMyAccount` and search for: - -```html - -``` -If you cannot find this code see [Update your Callisto Light using dependecyInjector](#update-your-callisto-light-using-dependecyinjector). - -**ATTENTION:** In each template you will find two similar occurrences of this snippet. Make sure that the value of the parameter `position` is `'body'` - -Add the following lines after each occurrence: - -```html - -``` - -**ATTENTION:** Do not wrap these calls in the same <script> tag. Be sure to have separate <script> tags for each call. - -### Step 5: Edit Category for Checkout-Step 3 - -Open the category which is set for Checkout-Step 3. By default this category is named "Kasse". -Search for -```html -{% if GetGlobal("ShowTabDetails") %} - -
.from( layoutGroup )
to specify the location in the CMS
- * (e.g. 'Checkout')
- * @example
- * CMSFactory.getContainer( 'CheckoutTotals' ).from( 'Checkout' )
- * .done(function( response ) {
- * // container content
- * var html = response.data[0]
- * });
- */
- function getContainer( containerName, params ) {
-
- function from( layoutGroup ) {
- return API.get( '/rest/' + layoutGroup.toLowerCase() + '/container_' + containerName.toLowerCase() + '/', params );
- }
-
- return {
- from: from
- }
-
- }
-
- /**
- * Prepare the request to receive Layout parameters for a template
- * @function getParams
- * @param {string} containerName The Layoutcontainer to receive the parameteres of.
- * @param {object} params Additional GET-parameters.
- * @returns {object} The prepared request. Call .from( layoutGroup )
to specify the location in the CMS
- * (e.g. 'ItemView')
- * @example
- * CMSFactory.getParams( 'BasketItemsList' ).from( 'ItemView' )
- * .done(function( response ) {
- * // BasketItems
- * var items = response.data;
- * });
- */
- function getParams( containerName, params ) {
-
- function from( layoutGroup ) {
- return API.get( '/rest/' + layoutGroup.toLowerCase() + '/' + containerName.toLowerCase() + '/', params );
- }
-
- return {
- from: from
- }
- }
-
- /**
- * Get the content of a category specified by its ID
- * @function getCategoryContent
- * @param {number} categoryID The ID of the category to get the content from
- * @returns {object} jQuery deferred Object
- */
- function getCategoryContent( categoryID ) {
-
- return API.get( '/rest/categoryview/categorycontentbody/?categoryID=' + categoryID );
- }
-
- }, ['APIFactory']);
-}(PlentyFramework));
-/**
- * Licensed under AGPL v3
- * (https://github.com/plentymarkets/plenty-cms-library/blob/master/LICENSE)
- * =====================================================================================
- * @copyright Copyright (c) 2015, plentymarkets GmbH (http://www.plentymarkets.com)
- * @author Felix Dausch addBasketItem()
again
- * @function saveOrderParams
- * @private
- * @param {Array} articleWithParams Containing the current item to add. Read OrderParams will be injected
- */
- function saveOrderParams( articleWithParams ) {
- //TODO use $("[data-plenty-checkout-form='OrderParamsForm']").serializeArray() to get order params
- var orderParamsForm = $('[data-plenty-checkout-form="OrderParamsForm"]');
- var wrappedThis = {};
- var attrType = "";
-
- //Groups
- orderParamsForm.find('[name^="ParamGroup"]').each(function(){
- var match = this.name.match(/^ParamGroup\[(\d+)]\[(\d+)]$/);
- articleWithParams = addOrderParamValue(articleWithParams, match[1], $(this).val(), $(this).val());
- });
-
- //Values
- orderParamsForm.find('[name^="ParamValue"]').each(function(){
- wrappedThis = $(this);
- attrType = wrappedThis.attr('type');
-
- if( ((attrType == 'checkbox' && wrappedThis.is(':checked')) ||
- (attrType == 'radio' && wrappedThis.is(':checked')) ||
- (attrType != 'radio' && attrType != 'checkbox')) &&
- attrType != 'file')
- {
- var match = this.name.match(/^ParamValue\[(\d+)]\[(\d+)]$/);
-
- articleWithParams = addOrderParamValue(articleWithParams, match[1], match[2], wrappedThis.val());
-
- } else if (attrType == 'file') {
- articleWithParams = orderParamFileUpload(this, articleWithParams);
- }
- });
-
- addArticle( articleWithParams );
- }
-
- function addArticle( article ) {
- API.post( '/rest/checkout/basketitemslist/', article, true)
- .done(function() {
- // Item has no OrderParams -> Refresh Checkout & BasketPreview
- Checkout.loadCheckout()
- .done(function() {
- refreshBasketPreview();
- // Show confirmation popup
- CMS.getContainer('ItemViewItemToBasketConfirmationOverlay', { ArticleID : article[0].BasketItemItemID }).from('ItemView')
- .done(function(response) {
- Modal.prepare()
- .setContent(response.data[0])
- .setTimeout(5000)
- .show();
- });
- });
- }).fail(function(jqXHR) {
- // some other error occured
- UI.printErrors(JSON.parse(jqXHR.responseText).error.error_stack);
- });
- }
-
- function orderParamFileUpload(input , articleWithParams ) {
- var key = input.id;
- var orderParamUploadFiles = {};
- var orderParamFileIdStack = [];
- var formData;
- var fileData;
- var params = {
- type: 'POST',
- data: {},
- isFile: true,
- cache: false,
- dataType: 'json',
- processData: false,
- contentType: false
- };
-
- orderParamUploadFiles[key] = $(input)[0].files;
-
- if (orderParamFileIdStack.indexOf(key) == -1) {
- orderParamFileIdStack.push(key);
- }
-
- for(var i= 0, length = orderParamFileIdStack.length; i < length; ++i){
- formData = new FormData();
- fileData = orderParamUploadFiles[orderParamFileIdStack[i]];
- formData.append("0", fileData[0], fileData[0].name);
-
- params.data = formData;
-
- API.post("/rest/checkout/orderparamfile/", params);
- }
-
- var match = input.name.match(/^ParamValueFile\[(\d+)]\[(\d+)]$/);
-
- return addOrderParamValue(articleWithParams, match[1], match[2], $(input).val());
- }
-
- /**
- * Inject an OrderParam.
- * @function addOrderParamValue
- * @private
- * @param {Array} basketList The target to inject the value in.
- * @param {number} position Position where to inject the value
- * @param {number} paramId The ID of the OrderParam to inject
- * @param {string|number} paramValue the value of the OrderParam to inject
- * @returns {Array} Containing the item and the injected OrderParam
- */
- function addOrderParamValue(basketList, position, paramId, paramValue) {
- if (position > 0 && basketList[position] == undefined)
- {
- basketList[position] = $.extend(true, {}, basketList[0]);
- basketList[position].BasketItemOrderParamsList = [];
- }
-
- if(basketList[position] != undefined)
- {
- basketList[position].BasketItemQuantity = 1;
- if(basketList[position].BasketItemOrderParamsList == undefined)
- {
- basketList[position].BasketItemOrderParamsList = [];
- }
- if(paramValue){
- basketList[position].BasketItemOrderParamsList.push({
- BasketItemOrderParamID : paramId,
- BasketItemOrderParamValue : paramValue
- });
- }
- }
-
- return basketList;
- }
-
- /**
- * Remove item from basket. Will show a confirmation popup at first.
- * @function removeBasketItem
- * @param {number} BasketItemID The ID of the basket item to remove
- * @param {boolean} [forceDelete=false] Set true to remove the basket item without showing a confirmation popup
- * @return Promise
- */
- function removeBasketItem( BasketItemID, forceDelete ) {
-
- // get item name
- var itemName, originalItemQuantity;
- var params = Checkout.getCheckout().BasketItemsList;
-
- for ( var i = 0; i < params.length; i++ ) {
- if ( params[i].BasketItemID == BasketItemID ) {
- originalItemQuantity = params[i].BasketItemQuantity;
- itemName = params[i].BasketItemNameMap[1];
- }
- }
-
- // calling the delete request
- function doDelete() {
- API.delete('/rest/checkout/basketitemslist/?basketItemIdsList[0]='+BasketItemID)
- .done(function() {
- Checkout.loadCheckout().done(function() {
- $('[data-basket-item-id="'+BasketItemID+'"]').remove();
-
- if( !Checkout.getCheckout().BasketItemsList || Checkout.getCheckout().BasketItemsList.length <= 0 ) {
- Checkout.reloadCatContent( pm.getGlobal( 'basketCatID' ) );
- } else {
- Checkout.reloadContainer('Totals');
- }
-
- refreshBasketPreview();
- });
- });
- }
-
- if( !forceDelete ) {
- // show confirmation popup
- Modal.prepare()
- .setTitle( pm.translate('Please confirm') )
- .setContent('' + pm.translate( "Do you really want to remove \"{{item}}\" from your basket?", {item: itemName}) + '
') - .onDismiss(function () { - $('[data-basket-item-id="' + BasketItemID + '"]').find('[data-plenty="quantityInput"]').val(originalItemQuantity); - }) - .onConfirm(function () { - doDelete(); - }) - .setLabelConfirm( pm.translate("Delete") ) - .show(); - } else { - doDelete(); - } - } - - /** - * Set a new quantity for the given BasketItem. If quantity is set to 0, - * remove the item. - * @function setItemQuantity - * @param {number} BasketItemID The ID of the basket item to change the quantity of - * @param {number} BasketItemQuantity The new quantity to set or 0 to remove the item - */ - function setItemQuantity( BasketItemID, BasketItemQuantity ) { - // delete item if quantity is 0 - if( BasketItemQuantity <= 0 ) { - removeBasketItem( BasketItemID ); - } - - var params = Checkout.getCheckout().BasketItemsList; - var basketItem; - var basketItemIndex; - - for ( var i = 0; i < params.length; i++ ) { - if ( params[i].BasketItemID == BasketItemID ) { - basketItemIndex = i; - basketItem = params[i]; - break; - - } - } - - if( !!basketItem && basketItem.BasketItemQuantity != BasketItemQuantity ) { - params[basketItemIndex].BasketItemQuantity = parseInt( BasketItemQuantity ); - - API.post("/rest/checkout/basketitemslist/", params) - .done(function () { - Checkout.setCheckout().done(function () { - Checkout.reloadContainer('Totals'); - - var basketItemsPriceTotal = 0; - var params2 = Checkout.getCheckout().BasketItemsList; - for (var i = 0; i < params2.length; i++) { - if (params2[i].BasketItemID == BasketItemID) { - basketItemsPriceTotal = params2[i].BasketItemPriceTotal; - } - } - $('[data-basket-item-id="' + BasketItemID + '"]').find('[data-plenty-checkout="basket-item-price-total"]').html(basketItemsPriceTotal); - refreshBasketPreview(); - }); - }); - } - } - - /** - * Reload BasketPreview-Template and update basket totals - * @function refreshBasketPreview - * @private - */ - function refreshBasketPreview() { - - Checkout.reloadItemContainer('BasketPreviewList') - .done(function() { - - $('[data-plenty-basket-empty]').each(function(i, elem) { - var toggleClass = $(elem).attr('data-plenty-basket-empty'); - if( Checkout.getCheckout().BasketItemsList.length <= 0 ) { - $(elem).addClass( toggleClass ); - } else { - $(elem).removeClass( toggleClass ); - } - }); - - }); - - //update quantity - var itemQuantityTotal = 0; - $.each( Checkout.getCheckout().BasketItemsList, function(i, basketItem) { - itemQuantityTotal += basketItem.BasketItemQuantity; - }); - - $('[data-plenty-basket-preview="itemQuantityTotal"]').text( itemQuantityTotal ); - $('[data-plenty-basket-preview="totalsItemSum"]').text( Checkout.getCheckout().Totals.TotalsItemSum ); - } - - /** - * Read the coupon code from an <input> element marked with data-plenty-checkout-form="couponCode" - * and try to add this coupon. - * @function addCoupon - * @return {object} jQuery deferred - * Object - */ - function addCoupon() { - var params = { - CouponActiveCouponCode: $('[data-plenty-checkout-form="couponCode"]').val() - }; - - return API.post("/rest/checkout/coupon/", params) - .done(function() { - Checkout.setCheckout() - .done(function() { - - updateContainer(); - }); - }); - } - - /** - * Remove the currently added coupon - * @function removeCoupon - * @return {object} jQuery deferred - * Object - */ - function removeCoupon() { - var params = { - CouponActiveCouponCode: Checkout.getCheckout().Coupon.CouponActiveCouponCode - }; - - return API.delete("/rest/checkout/coupon/", params) - .done(function() { - Checkout.setCheckout() - .done(function() { - delete Checkout.getCheckout().Coupon; - - updateContainer(); - }); - }); - } - - // update container - function updateContainer() { - Checkout.reloadContainer('Coupon'); - // reload category, if we are at checkout - if ( $('[data-plenty-checkout-catcontent="' + pm.getGlobal('checkoutConfirmCatID') + '"]').length > 0 ) { - Checkout.reloadCatContent( pm.getGlobal('checkoutConfirmCatID') ); - } - else - // reload totals, if we are at basket - if ( $('[data-plenty-checkout-template="Totals"]').length > 0 ) { - Checkout.reloadContainer('Totals'); - } - } - - }, ['APIFactory', 'UIFactory', 'CMSFactory', 'CheckoutFactory', 'ModalFactory']); -}(jQuery, PlentyFramework)); -/** - * Licensed under AGPL v3 - * (https://github.com/plentymarkets/plenty-cms-library/blob/master/LICENSE) - * ===================================================================================== - * @copyright Copyright (c) 2015, plentymarkets GmbH (http://www.plentymarkets.com) - * @author Felix DauschgoTo(targetContainer.index, true)
- * @function continueChange
- * @param targetContainer The tab-object received from an interceptor
- */
- function continueChange(targetContainer) {
- goTo(targetContainer.index, true);
- }
-
- /**
- * Show next checkout tab if available. Shorthand for
- *
- * if (current < navigation.length - 1) {
- * goTo(current + 1);
- * }
- *
- * @function next
- */
- function next() {
- if (current < navigation.length - 1) {
- goTo(current + 1);
- }
- }
-
- /**
- * Show previous checkout tab if available
- * @function next
- */
- function previous() {
- if (current > 0) {
- goTo(current - 1);
- }
- }
-
- /**
- * Show checkout tab given by ID
- * @function goToID
- * @param {string} containerID ID of tab to show. Target tab must be marked with data-plenty-checkout-id="#..."
- */
- function goToID(containerID) {
- if (containerID == 'next') {
- next();
- return true;
- }
- else if (containerID == 'prev') {
- previous();
- return true;
- }
- else {
- containerID = containerID.replace('#', '');
- $(container).each(function (i, elem) {
- if ($(elem).attr('data-plenty-checkout-id') == containerID) {
- goTo(i);
- return true;
- }
- });
- }
-
- return false;
- }
-
- /**
- * Calculate navigation's width to match its parent element
- * by increasing its items padding.
- * @function fillNavigation
- */
- function fillNavigation() {
- // break if manager has not been initialized
- var navigationCount = navigation.length;
- if( navigationCount <= 0 ) return;
-
- // reset inline styles
- $(navigation).removeAttr('style');
- $(navigation).children('span').removeAttr('style');
- $(buttonNext).removeAttr('style');
- $(buttonPrev).removeAttr('style');
-
-
- var buttonWidth = ($(buttonPrev).outerWidth() < $(buttonNext).outerWidth()) ? $(buttonNext).outerWidth(true)+1 : $(buttonPrev).outerWidth(true)+1;
- $(buttonNext).css({ width: buttonWidth+'px' });
- $(buttonPrev).css({ width: buttonWidth+'px' });
-
- // calculate width to fill
- var width = $(navigation).parent().parent().outerWidth(true) - ( 2 * buttonWidth);
- width -= parseInt($(navigation).parent().css('marginLeft')) + parseInt($(navigation).parent().css('marginRight'));
-
- var padding = width;
- var tabWidth = [];
-
- $(navigation).each(function(i, elem) {
- padding -= parseInt( $(elem).css('marginLeft') );
- padding -= parseInt( $(elem).css('marginRight') );
-
- tabWidth[i] = $(elem).children('span').width();
- padding -= tabWidth[i];
-
- padding -= parseInt( $(elem).children('span').css('marginLeft') );
- padding -= parseInt( $(elem).children('span').css('marginRight') );
- });
-
- var paddingEachItem = parseInt( padding / navigationCount );
-
- var paddingLeft, paddingRight;
- if ( paddingEachItem % 2 == 1 ) {
- paddingLeft = ( paddingEachItem / 2 ) + 0.5;
- paddingRight = ( paddingEachItem / 2 ) - 0.5;
- }
- else {
- paddingLeft = paddingEachItem / 2;
- paddingRight = paddingEachItem / 2;
- }
-
- var paddingLastItem = parseInt( padding - ( ( navigationCount - 1 ) * ( paddingLeft + paddingRight ) ) );
- var paddingLastLeft, paddingLastRight;
- if ( paddingLastItem % 2 == 1 ) {
- paddingLastLeft = ( paddingLastItem / 2 ) + 0.5;
- paddingLastRight = ( paddingLastItem / 2) - 0.5;
- }
- else {
- paddingLastLeft = paddingLastItem / 2;
- paddingLastRight = paddingLastItem / 2;
- }
-
- var diff = width;
- $(navigation).each(function(i, elem) {
- if ( i < navigationCount - 1) {
- $(elem).children('span').css({'paddingLeft': paddingLeft + 'px', 'paddingRight': paddingRight + 'px'}); //.parent().css({ width: ( tabWidth[i] + paddingLeft + paddingRight + parseInt( $(elem).children('span').css('marginLeft') ) + parseInt( $(elem).children('span').css('marginRight') ) )+'px' });
- }
- else {
- $(elem).children('span').css({'paddingLeft': paddingLastLeft + 'px', 'paddingRight': paddingLastRight + 'px'}); //.parent().css({ width: ( tabWidth[i] + paddingLastLeft + paddingLastRight + parseInt( $(elem).children('span').css('marginLeft') ) + parseInt( $(elem).children('span').css('marginRight') ) )+'px' });
- }
- });
-
- //$(navigation).parent().css('marginRight', 0);
- }
-
- });
-
-}(jQuery, PlentyFramework));
-/**
- * Licensed under AGPL v3
- * (https://github.com/plentymarkets/plenty-cms-library/blob/master/LICENSE)
- * =====================================================================================
- * @copyright Copyright (c) 2015, plentymarkets GmbH (http://www.plentymarkets.com)
- * @author Felix Dausch