PATH:
home
/
letacommog
/
letaweb
/
scripts
/
editor
/
popup
angular.module('ui.popup') .service('popup_shipping_rule', ['communication','popup_form',function(communication,popup_form) { this.open = function(opt) { return popup_form.open( { name:'shipping_rule', controller: function($scope,$modalInstance) { $scope.rule_text = opt.data.text || ""; var rule_texts = $scope.rule_text.split(";"); var lastFrom; var lastAmount; var firstAmount = 0; var firstFrom; var rules = []; for(var i = 0;i < rule_texts.length;i++) { var rule_item = rule_texts[i].split(":"); if(rule_item[0]*1 == 0) {firstAmount = rule_item[1] * 1;continue}; if(lastFrom != undefined) { rules.push({from:lastFrom, to:(rule_item[0] * 1), amount:lastAmount}); } if(firstFrom == undefined) { firstFrom = rule_item[0] * 1; } lastFrom = (rule_item[0]*1) ; lastAmount = rule_item[1] * 1; } $scope.rules = rules; $scope.lastAmount = lastAmount; $scope.lastFrom = lastFrom || 0; $scope.firstAmount = firstAmount; $scope.firstFrom = firstFrom; $scope.rule_length = $scope.rules.length; $scope.cancel = function () { $modalInstance.dismiss('cancel'); } $scope.ok = function () { var rule_text = ''; if($scope.rule_length==0) { rule_text += '0:' + $scope.lastAmount; //return; } else { rule_text += '0:' + $scope.firstAmount; for(var i = 0;i < $scope.rules.length;i++) { rule_text += ';'+$scope.rules[i].from + ':' + $scope.rules[i].amount; } rule_text += ';' + $scope.lastFrom + ':' + $scope.lastAmount; } $modalInstance.close(rule_text); } $scope.addRule = function() { var length = $scope.rules.length; last = $scope.lastFrom*1 ; $scope.rules.push({from:last, to:(last)*1 + 1 , amount:0}); changeRules(); } $scope.delete = function(index) { $scope.rules.splice(index,1); changeRules(); } $scope.changeRules = function() { changeRules(); } var changeRules = function() { $scope.rule_length = $scope.rules.length; if($scope.rule_length==0) { $scope.lastFrom = 0; $scope.firstFrom = 10; return; } var last = 0; var change = 0; $scope.firstFrom = ($scope.firstFrom == 0 ? 10:$scope.firstFrom); var lastFrom = $scope.firstFrom*1; var lastAmount = $scope.firstAmount; var firstAmount = 0; var firstFrom; for(var i = 0;i < $scope.rules.length;i++) { var rule_item = $scope.rules[i]; //if($scope.rules.hasOwnProperty(i-1)) { change = lastFrom - $scope.rules[i].from * 1; $scope.rules[i].from = lastFrom*1; //$scope.rules[i].to = rule_item.to*1 + change; if( (rule_item.to*1 + change)< $scope.rules[i].from) { $scope.rules[i].to = $scope.rules[i].from*1 + 1 ; } else $scope.rules[i].to = rule_item.to*1 + change; //} //rules.push({from:last, to:rule_item[0], amount:rule_item[1]}); lastFrom = ($scope.rules[i].to*1) ; //lastAmount = $scope.rules[i].amount*1; } //$scope.lastAmount = lastAmount; $scope.lastFrom = lastFrom; //$scope.firstAmount = firstAmount; // $scope.firstFrom = firstFrom; } }, }); } }]);
[+]
..
[-] profile.js
[edit]
[-] pagelist.js
[edit]
[-] order.js
[edit]
[-] customer_group.js
[edit]
[-] module_list.js
[edit]
[-] backgroundeditor.js
[edit]
[-] product.js
[edit]
[-] visualcsseditor.js
[edit]
[-] shipping_rule.js
[edit]
[-] profile_change_password.js
[edit]
[-] review.js
[edit]
[-] contributor_invite.js
[edit]
[-] dbfilter.js
[edit]
[-] tax_class.js
[edit]
[-] special_module_style_editor.js
[edit]
[-] idletimeout.js
[edit]
[-] address.js
[edit]
[-] contributor.js
[edit]
[-] login.js
[edit]
[-] skin.js
[edit]
[-] mail.js
[edit]
[-] discount.js
[edit]
[-] customer.js
[edit]
[-] productgrid.js
[edit]
[-] socialsharebuttonconfig.js
[edit]
[-] news.js
[edit]
[-] color.js
[edit]
[-] palette.js
[edit]
[-] newsgrid.js
[edit]
[-] product_option_combination_grid.js
[edit]
[-] page.js
[edit]
[-] product_option.js
[edit]
[-] tax_rate.js
[edit]
[-] coupons.js
[edit]
[-] zone.js
[edit]
[-] product_bulk_price.js
[edit]
[-] option_set.js
[edit]
[-] product_option_combination.js
[edit]