I want to create image Editor with functionality of Image Rotation, Image Color Changer (Sepia/Gray) and Price Calculator on Height and Width. Also I want to add Image Selector(Image Crop) in this editor.
Can Anyone help me to correct this code.
img css is overriding in this code when I click on Rotate button it rotates image but also when I click on color button it changes color as well rotates image.. I dont know how to remove this overriding or use something else.
Also need help to rotate image in particular div.
$('input[name="color"]').on('change', function() {
$('div.imageDiv')
.removeClass('original sepia gray')
.addClass($(this).val());
});
function calculate() {
var myBox1 = document.getElementById('box1').value;
var myBox2 = document.getElementById('box2').value;
var result = document.getElementById('result');
var myResult = [(myBox1 * myBox2 * 0.69) / 100];
result.value = myResult;
}
$('input').click(function() {
var img = $('img');
if (img.hasClass('north')) {
img.attr('class', 'west');
} else if (img.hasClass('west')) {
img.attr('class', 'south');
} else if (img.hasClass('south')) {
img.attr('class', 'east');
} else if (img.hasClass('east')) {
img.attr('class', 'north');
}
});
img {
display: block;
width: 50%;
}
.original {} .sepia {
-webkit-filter: sepia(1);
filter: sepia(1);
}
.gray {
-webkit-filter: grayscale(1);
filter: grayscale(1);
}
.north {
transform: rotate(0deg);
-ms-transform: rotate(0deg);
/* IE 9 */
-webkit-transform: rotate(0deg);
/* Safari and Chrome */
}
.west {
transform: rotate(90deg);
-ms-transform: rotate(90deg);
/* IE 9 */
-webkit-transform: rotate(90deg);
/* Safari and Chrome */
}
.south {
transform: rotate(180deg);
-ms-transform: rotate(180deg);
/* IE 9 */
-webkit-transform: rotate(180deg);
/* Safari and Chrome */
}
.east {
transform: rotate(270deg);
-ms-transform: rotate(270deg);
/* IE 9 */
-webkit-transform: rotate(270deg);
/* Safari and Chrome */
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<input type="radio" checked="checked" value="original" name="color" />Color
<br />
<input type="radio" value="gray" name="color" />Gray
<br />
<input type="radio" value="sepia" name="color" />Sepia</p>
<div class="imageDiv original">
<img class="north" alt="" src="https://blog.stackexchange.com/images/wordpress/stackoverflow-logo-alt2-300.png" />
</div>
<br>
<br>
<input type="button" value="Rotate">
<table border="0">
<tbody>
<tr>
<th>Length in cm</th>
<th>Width in cm</th>
<th>Total Price in A$</th>
</tr>
<tr>
<td>
<input id="box1" type="text" />
</td>
<td>
<input id="box2" type="text" />
</td>
<td>
<input id="result" type="text" />
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
<p>