From 9067e77b647efeca753cfdbeb52aca8e8303127c Mon Sep 17 00:00:00 2001 From: joamag Date: Thu, 5 Jul 2018 13:00:55 +0100 Subject: [PATCH] renamed variables --- src/js/base/ripe.js | 24 ++++++++++++------------ src/js/ripe-min.js | 10 +++++----- src/js/ripe.js | 24 ++++++++++++------------ src/python/ripe_demo/static/js/ripe.js | 24 ++++++++++++------------ 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/js/base/ripe.js b/src/js/base/ripe.js index dc5b5c354..6ea7a66ad 100644 --- a/src/js/base/ripe.js +++ b/src/js/base/ripe.js @@ -47,14 +47,14 @@ ripe.Ripe.prototype.init = function(brand, model, options) { return; } - if (ripe.equal(this.parts, this.partsHistory[this.partsHistoryPointer])) { + if (ripe.equal(this.parts, this.history[this.historyPointer])) { return; } var _parts = ripe.clone(this.parts); - this.partsHistory = this.partsHistory.slice(0, this.partsHistoryPointer + 1); - this.partsHistory.push(_parts); - this.partsHistoryPointer = this.partsHistory.length - 1; + this.history = this.history.slice(0, this.historyPointer + 1); + this.history.push(_parts); + this.historyPointer = this.history.length - 1; }); }; @@ -111,8 +111,8 @@ ripe.Ripe.prototype.config = function(brand, model, options) { this, function(result) { result = result || this.parts; - this.partsHistory = []; - this.partsHistoryPointer = -1; + this.history = []; + this.historyPointer = -1; if (this.ready === false) { this.ready = true; this.trigger("ready"); @@ -298,8 +298,8 @@ ripe.Ripe.prototype.undo = function() { return; } - this.partsHistoryPointer -= 1; - var parts = this.partsHistory[this.partsHistoryPointer]; + this.historyPointer -= 1; + var parts = this.history[this.historyPointer]; parts && this.setParts(parts, false, { action: "undo" }); }; @@ -314,8 +314,8 @@ ripe.Ripe.prototype.redo = function() { return; } - this.partsHistoryPointer += 1; - var parts = this.partsHistory[this.partsHistoryPointer]; + this.historyPointer += 1; + var parts = this.history[this.historyPointer]; parts && this.setParts(parts, false, { action: "redo" }); }; @@ -326,7 +326,7 @@ ripe.Ripe.prototype.redo = function() { * current parts history stack. */ ripe.Ripe.prototype.canUndo = function() { - return this.partsHistoryPointer > 0; + return this.historyPointer > 0; }; /** @@ -336,7 +336,7 @@ ripe.Ripe.prototype.canUndo = function() { * in the history stack. */ ripe.Ripe.prototype.canRedo = function() { - return this.partsHistory.length - 1 > this.partsHistoryPointer; + return this.history.length - 1 > this.historyPointer; }; ripe.Ripe.prototype.addPlugin = function(plugin) { diff --git a/src/js/ripe-min.js b/src/js/ripe-min.js index 2d3e1a454..3bf8d79e6 100644 --- a/src/js/ripe-min.js +++ b/src/js/ripe-min.js @@ -17,10 +17,10 @@ var index=callbacks.indexOf(callback);if(index===-1){return;} callbacks.splice(index,1);this.callbacks[event]=callbacks;};ripe.Observable.prototype.runCallbacks=function(event){var callbacks=this.callbacks[event]||[];for(var index=0;index=0;index--){var child=this.children[index];this.unbindInteractable(child);} +if(ripe.equal(this.parts,this.history[this.historyPointer])){return;} +var _parts=ripe.clone(this.parts);this.history=this.history.slice(0,this.historyPointer+1);this.history.push(_parts);this.historyPointer=this.history.length-1;});};ripe.Ripe.prototype.deinit=function(){var index=null;for(index=this.children.length-1;index>=0;index--){var child=this.children[index];this.unbindInteractable(child);} for(index=this.plugins.length-1;index>=0;index--){var plugin=this.plugins[index];this.removePlugin(plugin);} -ripe.Observable.prototype.deinit.call(this);};ripe.Ripe.prototype.load=function(){this.update();};ripe.Ripe.prototype.unload=function(){};ripe.Ripe.prototype.config=function(brand,model,options){this.brand=brand;this.model=model;options=ripe.assign({update:true},this.options,options);this.setOptions(options);var hasParts=this.parts&&Object.keys(this.parts).length!==0;var loadDefaults=!hasParts&&this.useDefaults;var loadParts=loadDefaults?this.getDefaults:function(callback){setTimeout(callback);};loadParts.call(this,function(result){result=result||this.parts;this.partsHistory=[];this.partsHistoryPointer=-1;if(this.ready===false){this.ready=true;this.trigger("ready");} +ripe.Observable.prototype.deinit.call(this);};ripe.Ripe.prototype.load=function(){this.update();};ripe.Ripe.prototype.unload=function(){};ripe.Ripe.prototype.config=function(brand,model,options){this.brand=brand;this.model=model;options=ripe.assign({update:true},this.options,options);this.setOptions(options);var hasParts=this.parts&&Object.keys(this.parts).length!==0;var loadDefaults=!hasParts&&this.useDefaults;var loadParts=loadDefaults?this.getDefaults:function(callback){setTimeout(callback);};loadParts.call(this,function(result){result=result||this.parts;this.history=[];this.historyPointer=-1;if(this.ready===false){this.ready=true;this.trigger("ready");} this.setParts(result);this.remote();this.update();}.bind(this));var update=this.options.update||false;this.ready=update?this.ready:hasParts;this.trigger("config");};ripe.Ripe.prototype.remote=function(){var loadCombinations=this.useCombinations;loadCombinations&&this.getCombinations(function(result){this.combinations=result;this.trigger("combinations",this.combinations);}.bind(this));};ripe.Ripe.prototype.setOptions=function(options){this.options=options||{};this.variant=this.options.variant||null;this.url=this.options.url||"https://sandbox.platforme.com/api/";this.parts=this.options.parts||{};this.country=this.options.country||null;this.currency=this.options.currency||null;this.format=this.options.format||"jpeg";this.backgroundColor=this.options.backgroundColor||"";this.noDefaults=this.options.noDefaults===undefined?false:this.options.noDefaults;this.useDefaults=this.options.useDefaults===undefined?!this.noDefaults:this.options.useDefaults;this.noCombinations=this.options.noCombinations===undefined?false:this.options.noCombinations;this.useCombinations=this.options.useCombinations===undefined?!this.noCombinations:this.options.useCombinations;this.noPrice=this.options.noPrice===undefined?false:this.options.noPrice;this.usePrice=this.options.usePrice===undefined?!this.noPrice:this.options.usePrice;this.backgroundColor=this.backgroundColor.replace("#","");};ripe.Ripe.prototype.setPart=function(part,material,color,noUpdate,options){if(noUpdate){return this._setPart(part,material,color);} this.trigger("pre_parts",this.parts,options);this._setPart(part,material,color);this.update();this.trigger("parts",this.parts,options);this.trigger("post_parts",this.parts,options);};ripe.Ripe.prototype.setParts=function(update,noUpdate,options){if(typeof update==="object"&&!Array.isArray(update)){update=this._partsList(update);} if(!noUpdate){this.trigger("pre_parts",this.parts,options);} @@ -31,8 +31,8 @@ this.update();};ripe.Ripe.prototype.getFrames=function(callback){if(this.options this.getConfig(function(config){var frames={};var faces=config["faces"];for(var index=0;index0;};ripe.Ripe.prototype.canRedo=function(){return this.partsHistory.length-1>this.partsHistoryPointer;};ripe.Ripe.prototype.addPlugin=function(plugin){plugin.register(this);this.plugins.push(plugin);};ripe.Ripe.prototype.removePlugin=function(plugin){plugin.unregister(this);this.plugins.splice(this.plugins.indexOf(plugin),1);};ripe.Ripe.prototype._getState=function(){return{parts:this.parts,initials:this.initials,engraving:this.engraving};};ripe.Ripe.prototype._setPart=function(part,material,color){var value=this.parts[part]||{};value.material=material;value.color=color;this.parts[part]=value;this.trigger("pre_part",part,value);this.trigger("part",part,value);this.trigger("post_part",part,value);};ripe.Ripe.prototype._partsList=function(parts){parts=parts||this.parts;var partsList=[];for(var part in parts){var value=parts[part];partsList.push([part,value.material,value.color]);} +this.historyPointer-=1;var parts=this.history[this.historyPointer];parts&&this.setParts(parts,false,{action:"undo"});};ripe.Ripe.prototype.redo=function(){if(!this.canRedo()){return;} +this.historyPointer+=1;var parts=this.history[this.historyPointer];parts&&this.setParts(parts,false,{action:"redo"});};ripe.Ripe.prototype.canUndo=function(){return this.historyPointer>0;};ripe.Ripe.prototype.canRedo=function(){return this.history.length-1>this.historyPointer;};ripe.Ripe.prototype.addPlugin=function(plugin){plugin.register(this);this.plugins.push(plugin);};ripe.Ripe.prototype.removePlugin=function(plugin){plugin.unregister(this);this.plugins.splice(this.plugins.indexOf(plugin),1);};ripe.Ripe.prototype._getState=function(){return{parts:this.parts,initials:this.initials,engraving:this.engraving};};ripe.Ripe.prototype._setPart=function(part,material,color){var value=this.parts[part]||{};value.material=material;value.color=color;this.parts[part]=value;this.trigger("pre_part",part,value);this.trigger("part",part,value);this.trigger("post_part",part,value);};ripe.Ripe.prototype._partsList=function(parts){parts=parts||this.parts;var partsList=[];for(var part in parts){var value=parts[part];partsList.push([part,value.material,value.color]);} return partsList;};var Ripe=ripe.Ripe;if(typeof require!=="undefined"){var base=require("./base");var ripe=base.ripe;} ripe.createElement=function(tagName,className){var element=tagName&&document.createElement(tagName);element.className=className||"";return element;};ripe.animateProperty=function(element,property,initial,final,duration,callback){element.style[property]=initial;var last=new Date();var frame=function(){var current=new Date();var timeDelta=current-last;var animationDelta=(timeDelta*(final-initial))/duration;var value=parseFloat(element.style[property]);value+=animationDelta;value=final>initial?Math.min(value,final):Math.max(value,final);element.style[property]=value;last=current;var incrementAnimation=final>initial&&valuefinal;if(incrementAnimation||decrementAnimation){var id=requestAnimationFrame(frame);element.dataset.animation_id=id;}else{callback&&callback();}};frame();};ripe.getFrameKey=function(view,position,token){token=token||"-";return view+token+position;};ripe.parseFrameKey=function(frame,token){token=token||"-";return frame.split(token);};ripe.frameNameHack=function(frame){if(!frame){return"";} var _frame=ripe.parseFrameKey(frame);var view=_frame[0];var position=_frame[1];position=view==="side"?position:view;return position;};ripe.fixEvent=function(event){if(event.hasOwnProperty("offsetX")&&event.offsetX!==undefined){return event;} diff --git a/src/js/ripe.js b/src/js/ripe.js index f566aa068..066e98294 100644 --- a/src/js/ripe.js +++ b/src/js/ripe.js @@ -292,14 +292,14 @@ ripe.Ripe.prototype.init = function(brand, model, options) { return; } - if (ripe.equal(this.parts, this.partsHistory[this.partsHistoryPointer])) { + if (ripe.equal(this.parts, this.history[this.historyPointer])) { return; } var _parts = ripe.clone(this.parts); - this.partsHistory = this.partsHistory.slice(0, this.partsHistoryPointer + 1); - this.partsHistory.push(_parts); - this.partsHistoryPointer = this.partsHistory.length - 1; + this.history = this.history.slice(0, this.historyPointer + 1); + this.history.push(_parts); + this.historyPointer = this.history.length - 1; }); }; @@ -356,8 +356,8 @@ ripe.Ripe.prototype.config = function(brand, model, options) { this, function(result) { result = result || this.parts; - this.partsHistory = []; - this.partsHistoryPointer = -1; + this.history = []; + this.historyPointer = -1; if (this.ready === false) { this.ready = true; this.trigger("ready"); @@ -543,8 +543,8 @@ ripe.Ripe.prototype.undo = function() { return; } - this.partsHistoryPointer -= 1; - var parts = this.partsHistory[this.partsHistoryPointer]; + this.historyPointer -= 1; + var parts = this.history[this.historyPointer]; parts && this.setParts(parts, false, { action: "undo" }); }; @@ -559,8 +559,8 @@ ripe.Ripe.prototype.redo = function() { return; } - this.partsHistoryPointer += 1; - var parts = this.partsHistory[this.partsHistoryPointer]; + this.historyPointer += 1; + var parts = this.history[this.historyPointer]; parts && this.setParts(parts, false, { action: "redo" }); }; @@ -571,7 +571,7 @@ ripe.Ripe.prototype.redo = function() { * current parts history stack. */ ripe.Ripe.prototype.canUndo = function() { - return this.partsHistoryPointer > 0; + return this.historyPointer > 0; }; /** @@ -581,7 +581,7 @@ ripe.Ripe.prototype.canUndo = function() { * in the history stack. */ ripe.Ripe.prototype.canRedo = function() { - return this.partsHistory.length - 1 > this.partsHistoryPointer; + return this.history.length - 1 > this.historyPointer; }; ripe.Ripe.prototype.addPlugin = function(plugin) { diff --git a/src/python/ripe_demo/static/js/ripe.js b/src/python/ripe_demo/static/js/ripe.js index f566aa068..066e98294 100644 --- a/src/python/ripe_demo/static/js/ripe.js +++ b/src/python/ripe_demo/static/js/ripe.js @@ -292,14 +292,14 @@ ripe.Ripe.prototype.init = function(brand, model, options) { return; } - if (ripe.equal(this.parts, this.partsHistory[this.partsHistoryPointer])) { + if (ripe.equal(this.parts, this.history[this.historyPointer])) { return; } var _parts = ripe.clone(this.parts); - this.partsHistory = this.partsHistory.slice(0, this.partsHistoryPointer + 1); - this.partsHistory.push(_parts); - this.partsHistoryPointer = this.partsHistory.length - 1; + this.history = this.history.slice(0, this.historyPointer + 1); + this.history.push(_parts); + this.historyPointer = this.history.length - 1; }); }; @@ -356,8 +356,8 @@ ripe.Ripe.prototype.config = function(brand, model, options) { this, function(result) { result = result || this.parts; - this.partsHistory = []; - this.partsHistoryPointer = -1; + this.history = []; + this.historyPointer = -1; if (this.ready === false) { this.ready = true; this.trigger("ready"); @@ -543,8 +543,8 @@ ripe.Ripe.prototype.undo = function() { return; } - this.partsHistoryPointer -= 1; - var parts = this.partsHistory[this.partsHistoryPointer]; + this.historyPointer -= 1; + var parts = this.history[this.historyPointer]; parts && this.setParts(parts, false, { action: "undo" }); }; @@ -559,8 +559,8 @@ ripe.Ripe.prototype.redo = function() { return; } - this.partsHistoryPointer += 1; - var parts = this.partsHistory[this.partsHistoryPointer]; + this.historyPointer += 1; + var parts = this.history[this.historyPointer]; parts && this.setParts(parts, false, { action: "redo" }); }; @@ -571,7 +571,7 @@ ripe.Ripe.prototype.redo = function() { * current parts history stack. */ ripe.Ripe.prototype.canUndo = function() { - return this.partsHistoryPointer > 0; + return this.historyPointer > 0; }; /** @@ -581,7 +581,7 @@ ripe.Ripe.prototype.canUndo = function() { * in the history stack. */ ripe.Ripe.prototype.canRedo = function() { - return this.partsHistory.length - 1 > this.partsHistoryPointer; + return this.history.length - 1 > this.historyPointer; }; ripe.Ripe.prototype.addPlugin = function(plugin) {