/**
    WorkPhoto Model
**/
'use strict';
var Model = require('./Model');
var ko = require('knockout');

function WorkPhoto(values) {
    Model(this);

    this.model.defProperties({
        workPhotoID: 0,
        userID: 0,
        jobTitleID: 0,
        caption: '',
        fileName: '',
        url: '',
        rankPosition: 0,
        updatedDate: null,
        rotationAngle: 0,
        // Additional local data:
        // path to local file, unsaved/not-uploaded still (native file/camera support)
        localTempFilePath: null,
        // data of local file, unsaved/not-uploaded still (web file picker support)
        localTempFileData: null,
        // data for generated preview for the localTempFileData (web file picker support; generated by the fileuploader plugin)
        localTempPhotoPreview: null
    }, values);

    /**
     * Computed helper that return the CSS values for use inline
     * visually rotating the image, to preview result.
     */
    this.photoRotationStyle = ko.pureComputed(function() {
        var d = this.rotationAngle() |0;
        return 'transform: rotate(' + d + 'deg);';
    }, this);
}
module.exports = WorkPhoto;

@@ -96,16 +96,138 @@
 ckout');
+%0Avar FIXED_IMAGE_WIDTH = 442;%0Avar FIXED_IMAGE_HEIGHT = 332;%0Avar FIXED_IMAGE_RATE = FIXED_IMAGE_HEIGHT / FIXED_IMAGE_WIDTH;
 %0A%0Afuncti
@@ -1161,90 +1161,720 @@
     
-var d = this.rotationAngle() %7C0;%0A        return 'transform: rotate(' + d + 'deg);'
+// We need to rotate, but too to scale the image by the original proportion,%0A        // since the behavior implemented is to keep image as landscape with%0A        // fixed width and height even if rotated or originally portrait.%0A        var r = this.rotationAngle() %7C0;%0A        var sr = 'rotate(' + r + 'deg)';%0A        // Since we know the fixed size, we calculated the ratio and apply it as%0A        // a downscale when image is rotated in portrait.%0A        // It's simple since we only allow 90 degrees rotations at UI%0A        var s = 1;%0A        if (r === 90 %7C%7C r === 270) %7B%0A            s = FIXED_IMAGE_RATE;%0A        %7D%0A        var ss = 'scale(' + s + ', ' + s + ')';%0A%0A        return 'transform: ' + sr + ' ' + ss
 ;%0A  

Work Photos #95: fixed preview size when applying a rotation