Permalink
Browse files

API CHANGE Removed obsolete/broken ImageEditor functionality

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92575 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 4593120 commit edb8a0d1a1e7efd63223600f4034ea8a4d1436f3 @chillu chillu committed Nov 21, 2009
@@ -1,43 +0,0 @@
-ImageEditor = {};
-
-ImageEditor.Activator = {
- initialize: function() {
- this.onOpen = ImageEditor.Activator.onOpen.bind(this);
- },
-
- onOpen: function() {
- var windowWidth = Element.getDimensions(window.top.document.body).width;
- var windowHeight = Element.getDimensions(window.top.document.body).height;
- var iframe = window.top.document.getElementById('imageEditorIframe');
- if(iframe != null) {
- iframe.parentNode.removeChild(iframe);
- }
- iframe = window.top.document.createElement('iframe');
- var fileToEdit = $('ImageEditorActivator').firstChild.src;
- iframe.setAttribute("src","admin/ImageEditor?fileToEdit=" + fileToEdit);
- iframe.id = 'imageEditorIframe';
- iframe.style.width = windowWidth - 6 + 'px';
- iframe.style.height = windowHeight + 10 + 'px';
- iframe.style.zIndex = "1000";
- iframe.style.position = "absolute";
- iframe.style.top = "8px";
- iframe.style.left = "8px";
- window.top.document.body.appendChild(iframe);
- var divLeft = window.top.document.createElement('div');
- var divRight = window.top.document.createElement('div');
- divLeft.style.width = "8px";
- divLeft.style.height = "300%";
- divLeft.style.zIndex = "1000";
- divLeft.style.top = "0";
- divLeft.style.position = "absolute";
- divRight.style.width = "10px";
- divRight.style.height = "300%";
- divRight.style.zIndex = "1000";
- divRight.style.top = "0";
- divRight.style.position = "absolute";
- divRight.style.left = Element.getDimensions(divLeft).width + Element.getDimensions(iframe).width - 4 + 'px';
- window.top.document.body.appendChild(divLeft);
- window.top.document.body.appendChild(divRight);
- }
-
-}
@@ -1,16 +0,0 @@
-ImageEditor.Adjust = {
- initialize: function() {
- this.perform = ImageEditor.Adjust.perform.bind(this);
- this.setListener = ImageEditor.Adjust.setListener.bind(this);
- this.setListener();
- },
-
- setListener: function() {
- Element.toggle($('AdjustMenu'));
- Event.observe('AdjustButton','click',this.perform);
- },
-
- perform: function() {
- Element.toggle($('AdjustMenu'));
- }
-}
@@ -1,203 +0,0 @@
-/**
- * @author Mateusz
- */
-ImageEditor.Crop = {
-
- initialize: function() {
- this.cropBox = $('cropBox');
- new ImageEditor.Positioning.addBehaviour(this.cropBox);
- this.imageContainer = $('imageContainer');
- this.leftGreyBox = $('leftGreyBox');
- this.rightGreyBox = $('rightGreyBox');
- this.upperGreyBox = $('upperGreyBox');
- this.lowerGreyBox = $('lowerGreyBox');
- this.centerCropBox = ImageEditor.Crop.centerCropBox.bind(this);
- this.placeGreyBox = ImageEditor.Crop.placeGreyBox.bind(this);
- this.setListeners = ImageEditor.Crop.setListeners.bind(this);
- this.onCropStart = ImageEditor.Crop.onCropStart.bind(this);
- this.onCropOk = ImageEditor.Crop.onCropOk.bind(this);
- this.onCropCancel = ImageEditor.Crop.onCropCancel.bind(this);
- this.doCrop = ImageEditor.Crop.doCrop.bind(this);
- this.setVisible = ImageEditor.Crop.setVisible.bind(this);
- this.enable = ImageEditor.Crop.enable.bind(this);
- this.disable = ImageEditor.Crop.disable.bind(this);
- this.onImageLoadCallback = ImageEditor.Crop.onImageLoadCallback.bind(this);
- Event.observe('image','load',this.centerCropBox);
- var options = {
- resizeStop: ImageEditor.Crop.resizeStop.bind(this),
- onDrag: ImageEditor.Crop.onDrag.bind(this),
- onResize: ImageEditor.Crop.onResize.bind(this),
- getMousePos: ImageEditor.Crop.getMousePos.bind(this)
- };
- this.resizeCropBox = new ImageEditor.Resizeable.initialize(this.cropBox,options);
- Event.observe(this.cropBox,'dblclick',this.onCropOk.bind(this));
- this.setListeners();
- this.isVisible = false;
- this.setVisible(this.isVisible);
- this.isEnabled = true;
- this.lastCrop = {};
- },
-
- resizeStop: function(event) {
- if(this.isVisible) {
- ImageEditor.EventStack.clearStack();
- this.resizeCropBox.originalHeight = this.cropBox.getHeight();
- this.resizeCropBox.originalWidth = this.cropBox.getWidth();
- }
- },
-
- onDrag: function(event) {
- if(this.cropBox.getLeft() <= 0 ) this.cropBox.style.left = '0px';
- if(this.cropBox.getTop() <= 0 ) this.cropBox.style.top = '0px';
- if(this.cropBox.getLeft() + this.cropBox.getWidth() > this.cropBox.getParentWidth()) this.cropBox.style.left = this.cropBox.getParentWidth()- this.cropBox.getWidth() + 'px';
- if(this.cropBox.getTop() + this.cropBox.getHeight() > this.cropBox.getParentHeight()) this.cropBox.style.top = this.cropBox.getParentHeight() - this.cropBox.getHeight() + 'px';
- this.placeGreyBox(this.cropBox.getWidth(),this.cropBox.getHeight());
- },
-
- centerCropBox: function() {
- this.cropBox.style.width = this.cropBox.getParentWidth()/2 + 'px';
- this.cropBox.style.height = this.cropBox.getParentHeight()/2 + 'px';
- this.cropBox.style.left = (this.cropBox.getParentWidth() - this.cropBox.getWidth())/2 + "px";
- this.cropBox.style.top = (this.cropBox.getParentHeight() - this.cropBox.getHeight())/2 + "px";
- this.placeGreyBox(this.cropBox.getWidth(),this.cropBox.getHeight());
- this.leftBoxConstraint = this.cropBox.getParentLeft();
- this.topBoxConstraint = this.cropBox.getParentTop();
- this.rightBoxConstraint = this.cropBox.getParentLeft() + this.cropBox.getParentWidth();
- this.bottomBoxConstraint = this.cropBox.getParentTop() + this.cropBox.getParentHeight()-1;//hack without 1 doesn't work;
- },
-
- placeGreyBox: function(width,height) {
- if(this.isVisible) {
- this.lowerGreyBox.style.left = this.cropBox.getLeft() + 'px';
- this.lowerGreyBox.style.width = width + 'px';
- this.lowerGreyBox.style.height = this.cropBox.getParentHeight() - this.cropBox.getTop() - height + "px";
- this.lowerGreyBox.style.top = this.cropBox.getTop() + height + "px";
- this.leftGreyBox.style.width = this.cropBox.getLeft() + "px";
- this.leftGreyBox.style.height = $('imageContainer').getHeight() + 'px';
- this.rightGreyBox.style.width = this.cropBox.getParentWidth() - this.cropBox.getLeft() - width + "px";
- this.rightGreyBox.style.height = $('imageContainer').getHeight() + 'px';
- this.rightGreyBox.style.left = this.cropBox.getLeft() + width + "px";
- this.upperGreyBox.style.width = width + 'px';
- this.upperGreyBox.style.left = this.cropBox.getLeft() + 'px';
- this.upperGreyBox.style.height = this.cropBox.getTop() + 'px';
- this.resizeCropBox.placeClickBox();
- }
- },
-
- onResize: function(width,height) {
- if(width + parseInt(this.cropBox.style.left) > Element.getDimensions(this.imageContainer).width) {
- this.cropBox.style.left = parseInt(this.cropBox.style.left) - Math.abs(Element.getDimensions(this.imageContainer).width - (width + parseInt(this.cropBox.style.left))) + "px";
- }
- if(parseInt(this.cropBox.style.left) < 0) {
- this.cropBox.style.left = "0px";
- }
- if(width > Element.getDimensions(this.imageContainer).width) {
- this.cropBox.style.width = Element.getDimensions(this.imageContainer).width + "px";
- width = Element.getDimensions(this.imageContainer).width;
- }
- this.placeGreyBox(width,height);
- },
-
- getMousePos: function(event) {
- var x = Event.pointerX(event) + $('imageEditorContainer').scrollLeft;
- var y = Event.pointerY(event) + $('imageEditorContainer').scrollTop;
- if(x <= this.leftBoxConstraint) x = this.leftBoxConstraint;
- if(y <= this.topBoxConstraint) y = this.topBoxConstraint;
- if(x >= this.rightBoxConstraint) x = this.rightBoxConstraint;
- if(y >= this.bottomBoxConstraint) y = this.bottomBoxConstraint;
- return {x: x,y: y};
- },
-
- doCrop: function() {
- if(this.isEnabled) {
- var newWidth = this.cropBox.getWidth()
- var newHeight = this.cropBox.getHeight() ;
- var startTop = this.cropBox.getTop() ;
- var startLeft = this.cropBox.getLeft() ;
- if(newWidth > 35 && newHeight > 35) {
- this.lastCrop.top = startTop;
- this.lastCrop.left = startLeft;
- this.lastCrop.newWidth = newWidth;
- this.lastCrop.newHeight = newHeight;
- ImageEditor.transformation.crop(startTop,startLeft,newWidth,newHeight,ImageEditor.Crop.cropCallback.bind(this));
- this.disable();
- } else {
- ImageEditor.statusMessageWrapper.statusMessage("Crop area too small","bad");
- return false;
- }
- $('image').style.visibility = 'visible';//hack for IE for not selecting image during crop
- return true;
- }
- },
-
- cropCallback: function() {
- ImageEditor.history.addCrop($('image').src,
- this.lastCrop.top,
- this.lastCrop.left,
- this.lastCrop.newWidth,
- this.lastCrop.newHeight
- );
- ImageEditor.resize.imageContainerResize.placeClickBox();
- ImageEditor.resize.imageContainerResize.setVisible(true);
- Element.show($('CropText'));
- Element.hide(this.cropBox,this.leftGreyBox,this.rightGreyBox,this.upperGreyBox,this.lowerGreyBox,$('CurrentAction'));
- },
-
- setListeners: function() {
- Event.observe('CropButton','click',this.onCropStart);
- Event.observe('CancelButton','click',this.onCropCancel);
- Event.observe('ApplyButton','click',this.onCropOk);
- },
- onCropStart: function() {
- if(this.isEnabled) {
- $('image').style.visibility = "hidden";//hack for IE for not selecting image during crop
- this.setVisible(true);
- Element.show($('CurrentAction'));
- ImageEditor.Main.disableFunctionality();
- this.enable();
- }
- },
-
- onCropOk: function() {
- if(this.isEnabled) {
- if(this.doCrop()) Element.hide($('CurrentAction'));
- }
- },
-
- onCropCancel: function(event) {
- if(this.isEnabled) {
- Element.hide($('CurrentAction'));
- Element.show($('CropText'));
- this.setVisible(false);
- ImageEditor.Main.enableFunctionality();
- this.enable();
- }
- $('image').style.visibility = 'visible';//hack for IE for not selecting image during crop
- },
-
- setVisible: function(setVisible) {
- this.isVisible = setVisible;
- if(setVisible) {
- Element.show(this.cropBox,this.leftGreyBox,this.rightGreyBox,this.upperGreyBox,this.lowerGreyBox);
- this.centerCropBox();
- this.placeGreyBox(this.cropBox.getWidth(),this.cropBox.getHeight());
- } else {
- Element.hide(this.cropBox,this.leftGreyBox,this.rightGreyBox,this.upperGreyBox,this.lowerGreyBox,$('CurrentAction'));
- }
- ImageEditor.resize.imageContainerResize.setVisible(!setVisible);
- this.resizeCropBox.setVisible(setVisible);
- },
-
- enable: function() {
- this.isEnabled = true;
- },
-
- disable: function() {
- this.isEnabled = false;
- },
-
- onImageLoadCallback: function() {
- ImageEditor.crop.setVisible(false);
- }
-
-}
@@ -1,34 +0,0 @@
-/**
- * @author Mateusz
- */
-ImageEditor.DocumentBody = {
- initialize: function() {
- this.placeUI = ImageEditor.DocumentBody.placeUI.bind(this);
- this.placeUI();
- Event.observe(window.top,'resize',ImageEditor.DocumentBody.resizeIframe.bind(this));
- },
-
- resizeIframe: function(event) {
- var windowWidth = Element.getDimensions(window.top.document.body).width;
- var windowHeight = Element.getDimensions(window.top.document.body).height;
- var iframe = window.top.document.getElementById('imageEditorIframe');
- iframe.style.width = windowWidth - 6 + 'px';
- iframe.style.height = windowHeight + 10 + 'px';
- this.placeUI();
- },
-
- placeUI: function() {
- var iframe = window.top.document.getElementById('imageEditorIframe');
- $('imageEditorContainer').style.height = Element.getDimensions(iframe).height - Element.getDimensions($('TopRuler')).height - Element.getDimensions($('MenuBar')).height - 32 + 'px';
- $('imageEditorContainer').style.width = Element.getDimensions(iframe).width - Element.getDimensions($('LeftRuler')).width - 14 + 'px';
- $('LeftRuler').style.height = $('imageEditorContainer').style.height;
- $('TopLeft').style.width = Element.getDimensions($('MenuBar')).width -
- Element.getDimensions($('TopRight')).width + 'px';
- $('TopRight').style.left = Element.getDimensions($('TopLeft')).width + 'px';
-
- },
-
- onImageEditorScroll: function() {
- ImageEditor.imageBox.reCenterIndicator();
- }
-}
@@ -1,35 +0,0 @@
-/**
- * @author Mateusz
- */
-ImageEditor.Effects.Main = {
- initialize: function() {
- this.enable = ImageEditor.Effects.Main.enable.bind(this);
- this.disable = ImageEditor.Effects.Main.disable.bind(this);
- this.effects = Array();
- this.effects['rotate'] = new ImageEditor.Effects.Base.initialize('rotate');
- this.effects['greyscale'] = new ImageEditor.Effects.Base.initialize('greyscale');
- this.effects['sepia'] = new ImageEditor.Effects.Base.initialize('sepia');
- this.effects['blur'] = new ImageEditor.Effects.Base.initialize('blur');
- this.effects['adjust-contrast'] = new ImageEditor.Effects.AdjustBase.initialize('adjust-contrast',$R(-100, 100),0.1,62);
- this.effects['adjust-brightness'] = new ImageEditor.Effects.AdjustBase.initialize('adjust-brightness',$R(-255, 255),0.1,160);
- this.effects['adjust-gamma'] = new ImageEditor.Effects.AdjustBase.initialize('adjust-gamma',$R(0, 5),1.2,4);
- this.getEffect = ImageEditor.Effects.Main.getEffect.bind(this);
- },
-
- enable: function() {
- for (var name in this.effects) {
- if(this.effects.hasOwnProperty(name)) this.effects[name].enable();
- }
- },
-
- disable: function() {
- for (var name in this.effects) {
- if(this.effects.hasOwnProperty(name)) this.effects[name].disable();
- }
- },
-
- getEffect: function(name) {
- return this.effects[name];
- }
-
-}
Oops, something went wrong.

0 comments on commit edb8a0d

Please sign in to comment.