Вход Регистрация
Файл: js/al/owner_photo.js
Строк: 653
<?php
var OwnerPhoto = {
  
canRotate: function() {
    var 
browserintval(b.version);
    return (
      
b.msie && !b.mobile && ||
      
b.opera && !b.mobile && 10 ||
      
b.mozilla && !b.mobile && ||
      
b.chrome && 17 ||
      
b.safari && ||
      
b.android && !b.mozilla && 2
    
);
  },
  
init: function(blng) {
    
cur.lang extend(cur.lang || {}, lng);
    if (
cur.pvShown) {
      
hide(layerWrap);
      
cur._inLayer true;
    } else {
      
addClass(boxLayerBG'bg_dark');
    }
    
b.removeButtons();
    
b.setOptions({hideButtonstruewidth644bodyStyle'padding:0px;border:0px;'onHide: function() {
      if (
cur.pvShown) {
        
show(layerWrap);
        
cur._inLayer false;
      } else {
        
removeClass(boxLayerBG'bg_dark');
      }
    }, 
onShow: function() {
      if (
cur.pvShown) {
        
hide(layerWrap);
        
cur._inLayer true;
      } else {
        
addClass(boxLayerBG'bg_dark');
      }
    }, 
onClean: function() {
      if (
cur.ownerPhotoEditTagger) {
        
cur.ownerPhotoEditTagger.destroy();
        
cur.ownerPhotoEditTagger false;
      }
      if (
cur.ownerPhotoCropTagger) {
        
cur.ownerPhotoCropTagger.destroy();
        
cur.ownerPhotoCropTagger false;
      }
      if (
cur.ownerPhotoUploadId) {
        
Upload.deinit(cur.ownerPhotoUploadId);
        
cur.ownerPhotoUploadId false;
      }
      
clearTimeout(cur.ownerPhotoCropTimer);
    }});
    
cur.ownerPhotoBoxRefresh b.setOptions.pbind({});
    
stManager.add(['tagger.css''tagger.js']);
  },
  
showError: function(steperr) {
    if (!
err.match(/^ERR_[A-Z0-9_]+(:|$)/)) err 'ERR_CLIENT_BAD_ERROR: error "' clean(err.toString()) + '"';
    var 
err.match(/^(ERR_[A-Z0-9_]+)(:s*|$)([Ss]*)s*$/), code e[1], el ge('owner_photo_error'), msg;
    switch (
code) {
      case 
'ERR_UPLOAD_FILE_NOT_SUPPORTED'msg getLang('profile_oph_err_format'); break;
      case 
'ERR_UPLOAD_FILE_NOT_UPLOADED':
        
msg getLang('profile_oph_err_upload').replace('{link}''<a href="/support">').replace('{/link}''</a>'); break;
      case 
'ERR_UPLOAD_BAD_IMAGE_SIZE':
        
msg getLang('profile_oph_err_size').replace('{min}''200').replace('{max}''7<span class="num_delim"> </span>000'); break;
      case 
'ERR_STORAGE_ENGINE_NOT_CONNECTED':
      case 
'ERR_STORAGE_ENGINE_SAVE_FAILED':
        if (!
isVisible('owner_photo_upload_return')) {
          
msg getLang('profile_oph_error_server'); break;
        }
      default:
        
msg getLang('profile_oph_err_unknown').replace('{link}''<a href="/support">').replace('{/link}''</a>'); break;
    }
    
msg msg.replace('{sorry}''<b>' getLang('global_sorry_error') + '</b>') + '<br><a onclick="OwnerPhoto.detailsError(this);">' getLang('global_error_details') + '</a><div class="unshown">Error: ' code + (e[3] ? ('. Details: ' e[3]) : '.') + '</div>';
    
val(elmsg);
    if (
isVisible(el)) {
      
cssAnim(el, {backgroundColor'#EEDB7F'}, {duration150}, cssAnim.pbind(el, {backgroundColor'#F9F6E7'/*#F3E7AC*/}, {duration2000}));
    } else {
      
slideDown(el150);
    }
    if (
step == 1) {
      
Upload.embed(cur.ownerPhotoUploadId);
    }
  },
  
detailsError: function(el) {
    var 
vis isVisible(domNS(el));
    (
vis slideUp slideDown)(domNS(el), 150);
    
val(elgetLang(vis 'global_error_details' 'global_error_hide_details'));
  },

  
cameraInit: function() {
    var 
vars = {
      
's_noCamera'   getLang('profile_no_camera'),
      
's_noAccess'   getLang('profile_no_camera_access'),
      
's_setAccess'  getLang('profile_set_camera_access'),
      
's_capture'    getLang('profile_capture_image'),
      
's_videoMode'  getLang('profile_to_video_mode'),
      
'upload_url'   : (Upload.uploadUrls || [])[cur.ownerPhotoUploadId] || '',
      
'saveClbk'     'OwnerPhoto.cameraPhotoDone',
      
'hideClbk'     'OwnerPhoto.uploadReturn',
      
'overClbk'     'OwnerPhoto.cameraBtnOver',
      
'outClbk'      'OwnerPhoto.cameraBtnOut',
      
'downClbk'     'OwnerPhoto.cameraBtnDown',
      
'upClbk'       'OwnerPhoto.cameraBtnUp',
      
'showSaveClbk' 'OwnerPhoto.showCameraSaveBtn',
      
'hideSaveClbk' 'OwnerPhoto.hideCameraSaveBtn',
      
'hideCaptureClbk''OwnerPhoto.hideCameraCaptureBtn',
      
'progressClbk' 'OwnerPhoto.cameraSaveProgress',
      
'getBtnsPos'   'OwnerPhoto.updateCameraButtonsPos',
      
'jpgQuality'   '95'
    
}
    for (var 
i in vars) {
      
vars[i] = winToUtf(vars[i]);
    }
    var 
opts = {
      
url'/swf/CaptureImg.swf',
      
id'flash_camera',
      
width604,
      
height480,
      
preventhide1,
      
style'visibility: visible',
      
version9
    
}
    var 
params = {
      
allownetworking'true',
      
wmode'transparent'
    
}

    
setStyle(ge('owner_photo_cam_ctrls'), {visibility'hidden'});
    
hide('owner_photo_edit''owner_photo_upload');
    
show('owner_photo_camera''owner_photo_camera_return');
    
removeClass(ge('camera_button_no'), 'hover');
    
renderFlash('owner_photo_webcam'optsparamsvars);
    
this.hideCameraSaveBtn(true);
    
cur.ownerPhotoBoxRefresh();
    return 
false;
  },
  
cameraPhotoDone: function(res) {
    
unlockButton(ge('camera_button_yes'));
    
cur.cameraShotLoaded true;
    var 
wc ge('owner_photo_webcam');
    if (
wcwc.innerHTML '';
    
Upload.onUploadComplete(cur.ownerPhotoUploadIdres);
  },
  
updateCameraButtonsPos: function() {
    var 
butnsWrap ge('owner_photo_cam_ctrls'), pos = [];
    var 
wrapXY getXY(butnsWrap), wrapSize getSize(butnsWrap);
    
setStyle(ge('owner_photo_cam_ctrls'), {visibility'visible'});
    var 
detectPos = function(iel) {
      if (!
isVisible(el.parentNode)) return;
      var 
buttonXY getXY(el), buttonSize getSize(el);
      
pos.push([buttonXY[0] - wrapXY[0], buttonXY[1] - wrapXY[1], buttonSize[0] + 2buttonSize[1] + 2]);
    }
    
each(geByTag('button'butnsWrap), detectPos);
    
each(geByClass('button'butnsWrap), detectPos);
    if (
ge('flash_camera').setButtonsPosge('flash_camera').setButtonsPos(pos);
  },
  
showCameraSaveBtn: function() {
    
ge('camera_button_yes').innerHTML getLang('profile_oph_camera_save');
    
ge('camera_button_no').innerHTML getLang('profile_to_video_mode');
    
this.updateCameraButtonsPos();
  },
  
hideCameraSaveBtn: function(noUpdate) {
    
ge('camera_button_yes').innerHTML getLang('profile_capture_image');
    
ge('camera_button_no').innerHTML getLang('profile_oph_camera_back');
    if (!
noUpdatethis.updateCameraButtonsPos();
  },
  
hideCameraCaptureBtn: function() {
    
hide(ge('camera_button_no').parentNode);
    
ge('camera_button_yes').innerHTML getLang('profile_no_camera_back');
    
this.updateCameraButtonsPos();
  },
  
cameraSaveProgress: function(val) {
    var 
button ge('camera_button_yes');
    if (!
button) return;
    if (
val) {
      
lockButton(button);
    } else {
      
unlockButton(button);
    }
  },
  
cameraBtnOver: function(btn_class) {
    var 
button geByClass1(btn_classge('owner_photo_cam_ctrls')).firstChild;
    if (
buttonaddClass(button'hover');
  },
  
cameraBtnOut: function(btn_class) {
    var 
button geByClass1(btn_classge('owner_photo_cam_ctrls')).firstChild;
    if (
button) {
      
removeClass(button'hover');
      
removeClass(button'active');
    }
  },
  
cameraBtnDown: function(btn_class) {
    var 
button geByClass1(btn_classge('owner_photo_cam_ctrls')).firstChild;
    if (
buttonaddClass(button'active');
  },
  
cameraBtnUp: function(btn_class) {
    var 
button geByClass1(btn_classge('owner_photo_cam_ctrls')).firstChild;
    if (
buttonremoveClass(button'active');
  },

  
uploadInit: function(opts) {
    
cur.ownerPhotoUploadId Upload.init('owner_photo_input'opts.url, {}, {
      
file_name'photo',

      
file_size_limit1024*1024*5// 5Mb
      
file_types_description'Image files (*.jpg, *.png, *.gif)',
      
file_types'*.jpg;*.JPG;*.png;*.PNG;*.gif;*.GIF;*.bmp;*.BMP',

      
langopts.lang,

      
onUploadStart: function(ires) {
        
curBox().changed true;
        if (
Upload.types[i] == 'form') {
          
// show(box.progress);
        
}
      },

      
onUploadComplete: function(ireserrorAdd) {
        var 
obj parseJSON(res) || {};
        if (
obj.error) {
          
OwnerPhoto.showError(1obj.error + (errorAdd || ''));
        } else if (!
obj.x_src || !obj.x_size || !obj.size) {
          var 
txt = (res === false) ? '[FALSE]' : ((res === null) ? '[NULL]' : ((res === undefined) ? '[UNDEFINED]' : ('&laquo;' clean(res.toString().substr(01024)) + '&raquo;')));
          
OwnerPhoto.showError(1'ERR_CLIENT_BAD_RESPONSE: bad upload owner photo response, recv ' txt);
        } else {
          var 
url Upload.options[cur.ownerPhotoUploadId].base_url 'upload.php?act=owner_photo_edit&_query=' encodeURIComponent(res) + '&_origin=' encodeURIComponent(locProtocol '//' locHost);

          
hide('owner_photo_upload''owner_photo_camera');
          
ge('owner_photo_upload_return').className 'button_cancel inl_bl';
          
OwnerPhoto.edit({
            
thumbUpload.options[cur.ownerPhotoUploadId].static_url obj.x_src,
            
thumbSizeobj.x_size,
            
sizeobj.size,
            
uploadUrlurl
          
});
        }
      },

      
onUploadProgress: function(ibytesLoadedbytesTotal) {
        if (!
ge('form'+i+'_progress')) {
          var 
obj Upload.obj[i], objHeight getSize(obj)[1], tm objHeight 10;
          var 
node obj.firstChild;
          while (
node) {
            if (
node.nodeType == 1) {
              if (
node.id == 'uploader'+&& browser.msie) {
                
setStyle(node, {position'relative'left'-5000px'});
              } else {
                
setStyle(node, {visibility'hidden'});
              }
            }
            
node node.nextSibling;
          }
          
obj.appendChild(ce('div', {innerHTML'<div class="page_upload_progress_wrap">
            <div id="form' 
'_progress" class="page_upload_progress" style="width: 0%;"></div>
          </div></div>'
}, {heighttm 'px'marginTop: -tm 'px'}));
        }
        var 
percent intval(bytesLoaded bytesTotal 100);
        
setStyle(ge('form' '_progress'), {widthpercent '%'});
      },

      
clear1,
      
type'photo',
      
noFlash1,
      
max_attempts3,
      
signed1,
      
file_inputcurBox().inp,
      
static_urlopts.static_url,
      
check_urlopts.check_url,
      
base_urlopts.base_url,
      
dropbox'owner_dropbox'
    
});
  },
  
uploadReturn: function() {
    if (
cur.ownerPhotoEditTagger) {
      
cur.ownerPhotoEditTagger.destroy();
      
cur.ownerPhotoEditTagger false;
    }
    var 
cont ge('owner_photo_upload'), wrap ge('owner_photo_input')
    
re('owner_photo_error');
    
cont.insertBefore(ce('div', {className'msg'id'owner_photo_error'}), wrap);
    if (
cur.cameraShotLoaded) {
      
cur.cameraShotLoaded false;
      
this.cameraInit();
      return;
    }
    
show(cont);
    
hide('owner_photo_edit''owner_photo_camera');
    
val('owner_photo_thumb''');
    
Upload.embed(cur.ownerPhotoUploadId);
    
cur.ownerPhotoBoxRefresh();
  },

  
edit: function(opts) {
    if (!
optscurBox().hide();
    var 
cont ge('owner_photo_edit'), wrap ge('owner_photo_thumb'), opts.thumbSize;
    var 
st 'width: ' s[0] + 'px; height: ' s[1] + 'px;' '';
    if (!
opts.size) {
      
clearTimeout(cur.ownerPhotoEditTimer);
      
cur.ownerPhotoEditTimer setTimeout(OwnerPhoto.editInit100);
      (
cur.ownerPhotoOrigin vkImage()).src opts.url;
    } else {
      
cur.ownerPhotoEditTimer = -1;
    }
    
show(cont);
    
re('owner_photo_error');
    
cont.insertBefore(ce('div', {className'msg'id'owner_photo_error'}), wrap);
    
setStyle(wrap, {width''height''});
    
val(wrap'<div id="owner_photo_rotate"><div style="' st 'margin: 0px auto;"><img id="owner_photo_img" src="' opts.thumb '" style="' st '" onload="OwnerPhoto.editInit();" /></div></div>');
    
cur.ownerPhotoThumb ge('owner_photo_img');
    
cur.ownerPhotoEditOpts opts;
    
cur.ownerPhotoRotation 0;

    
cur.ownerPhotoBoxRefresh();
    
setTimeout(cur.ownerPhotoBoxRefresh0);
  },
  
editInit: function() {
    if (!
cur.ownerPhotoEditTimer) return;
    var 
opts cur.ownerPhotoEditOptssize opts.sizetsize opts.thumbSize;
    if (!
tsize && cur.ownerPhotoThumb.width && cur.ownerPhotoThumb.height) {
      
tsize opts.thumbSize = [cur.ownerPhotoThumb.widthcur.ownerPhotoThumb.height];
      
cur.ownerPhotoBoxRefresh();
    }
    if (!
size && cur.ownerPhotoOrigin.width && cur.ownerPhotoOrigin.height) {
      
size opts.size = [cur.ownerPhotoOrigin.widthcur.ownerPhotoOrigin.height];
    }
    
clearTimeout(cur.ownerPhotoEditTimer);
    if (!
size || !tsize) {
      return 
cur.ownerPhotoEditTimer setTimeout(OwnerPhoto.editInit100);
    }
    
cur.ownerPhotoEditTimer false;

    
stManager.add(['tagger.css''tagger.js'], OwnerPhoto.editTagger);
  },
  
rotate: function(c) {
    
cur.ownerPhotoEditTagger.rotate(c);
    var 
was intval(cur.ownerPhotoRotation), el ge('owner_photo_rotate'), wrap ge('owner_photo_thumb');
    
cur.ownerPhotoRotation = (= (was c) % 4);
    if (
wasremoveClass(el'owner_photo_rotate' was);
    if (
caddClass(el'owner_photo_rotate' c);
    var 
tsize cur.ownerPhotoEditOpts.thumbSize= (2) * Math.floor((tsize[0] - tsize[1]) / 2);
    
wrap.style.margin = (20) + 'px auto';
    
setStyle(domLC(wrap), extend(vk.rtl ? {leftd} : {rightd}, {bottom: -d}));
  },
  
editTagger: function() {
    var 
opts cur.ownerPhotoEditOptssize opts.sizetsize opts.thumbSizeminSize = [
      
Math.max(100Math.ceil(200 tsize[0] / size[0])),
      
Math.max(100Math.ceil(200 tsize[1] / size[1]))
    ], 
rect;
    if (
tsize[0] < minSize[0] || tsize[1] < minSize[1]) nav.reload();
    if (
opts.rect) {
      if (
opts.strict) {
        
rect = {
          
leftMath.floor(opts.rect[0] * tsize[0] / size[0]),
          
topMath.floor(opts.rect[1] * tsize[1] / size[1]),
          
widthMath.ceil(opts.rect[2] * tsize[0] / size[0]),
          
heightMath.ceil(opts.rect[3] * tsize[1] / size[1])
        }
      } else {
        
rect = {
          
leftMath.floor(opts.rect[0] * tsize[0] / 100.0),
          
topMath.floor(opts.rect[1] * tsize[1] / 100.0),
          
widthMath.ceil(opts.rect[2] * tsize[0] / 100.0),
          
heightMath.ceil(opts.rect[3] * tsize[1] / 100.0)
        }
        if (
rect.width minSize[0]) {
          
rect.left Math.max(0rect.left Math.floor((minSize[0] - rect.width) / 2));
          
rect.width minSize[0];
        }
        if (
rect.width 1.5 rect.height) {
          if (
rect.width 1.5 tsize[1]) {
            if (
tsize[1] / 1.5 minSize[0]) {
              
rect = {leftrect.left Math.floor((rect.width minSize[0]) / 2), top0widthminSize[0], heighttsize[1]};
            } else {
              
rect = {leftrect.left Math.floor((rect.width tsize[1] / 1.5) / 2), top0widthMath.floor(tsize[1] / 1.5), heighttsize[1]};
            }
          } else {
            
rect.top Math.max(0rect.top Math.floor((rect.width 1.5 rect.height) / 4));
            
rect.height Math.ceil(rect.width 1.5);
            if (
rect.top rect.height tsize[1]) {
              
rect.top tsize[1] - rect.height;
            }
          }
        }
        if (
rect.height rect.width 2.5) {
          if (
rect.height tsize[0] * 2.5) {
            
rect = {left0toprect.top Math.floor((rect.height tsize[0] * 2.5) / 2), widthtsize[0], heightMath.floor(tsize[0] * 2.5)};
          } else {
            
rect.left Math.max(0rect.left Math.floor((rect.height 2.5 rect.width) / 2));
            
rect.width Math.ceil(rect.height 2.5);
            if (
rect.left rect.width tsize[0]) {
              
rect.left tsize[0] - rect.width;
            }
          }
        }
      }
    } else {
      
rect = {widthMath.max(minSize[0], tsize[0] - 40), heightMath.max(minSize[1], tsize[1] - 40)};
      if (
rect.width rect.height) {
        
rect.width rect.height;
      }
      if (
rect.height rect.width 2.5) {
        
rect.height Math.floor(rect.width 2.5);
      }
      
rect.left Math.floor((tsize[0] - rect.width) / 2);
      
rect.top Math.floor((tsize[1] - rect.height) / 2);
    }
    if (
cur.ownerPhotoEditTagger) {
      
cur.ownerPhotoEditTagger.destroy();
    }
    
cur.ownerPhotoEditTagger photoTagger('owner_photo_img', {
      
minwminSize[0],
      
minhminSize[1],
      
mina0.4,
      
maxa1,
      
rectrect,
      
zstart1000
    
});

    if (
OwnerPhoto.canRotate()) {
      
re('owner_photo_rotate_c');
      var 
wrap ge('owner_photo_thumb');
      
setStyle(wrap, {widthtsize[0], heighttsize[1]});
      
setStyle(domFC(wrap), {widthtsize[0], heighttsize[1]});
      
wrap.appendChild(ce('div', {id'owner_photo_rotate_c'innerHTML'<div id="owner_photo_rotate_c1" onclick="OwnerPhoto.rotate(1)"></div><div id="owner_photo_rotate_c3" onclick="OwnerPhoto.rotate(3)"></div>'}));
    }
  },
  
editDone: function() {
    var 
rect cur.ownerPhotoEditTagger.result(), opts cur.ownerPhotoEditOpts;
    var 
cx opts.size[0] / opts.thumbSize[0], cy opts.size[1] / opts.thumbSize[1], crop = [
      
Math.floor(rect[0] * cx),
      
Math.floor(rect[1] * cy),
      
Math.ceil(rect[2] * cx),
      
Math.ceil(rect[3] * cy)
    ], 
url cur.ownerPhotoEditOpts.uploadUrl '&_full=' encodeURIComponent(crop.join(',')) + '&_rot=' intval(cur.ownerPhotoRotation);
    
hide('owner_photo_edit');
    
re('owner_photo_error');
    
ge('owner_photo_edit_return').className 'button_cancel inl_bl';
    
OwnerPhoto.crop({
      
uploadUrlurl,
      
thumburl '&_proxy=1',
      
thumbSize: [200intval(200 crop[3] / crop[2])],
      
size: [crop[2], crop[3]]
    });
  },
  
editReturn: function() {
    if (
cur.ownerPhotoCropTagger) {
      
cur.ownerPhotoCropTagger.destroy();
      
cur.ownerPhotoCropTagger false;
    }
    var 
cont ge('owner_photo_edit'), wrap ge('owner_photo_thumb')
    
re('owner_photo_error');
    
cont.insertBefore(ce('div', {className'msg'id'owner_photo_error'}), wrap);
    
show(cont);
    
hide('owner_photo_crop');
    
val('owner_photo_crop_thumb''');
    
cur.ownerPhotoBoxRefresh();
  },

  
thumbError: function() {
    if (!
isVisible('owner_photo_edit_return') || cur.ownerPhotoCropOpts.thumb.indexOf('_proxy=1') == -1) {
      return;
    }

    
OwnerPhoto.editReturn();
    
stManager.add(['upload.js'], function() {
      
utilsNode.appendChild(ce('iframe', {
        
srccur.ownerPhotoCropOpts.thumb.replace('_proxy=1''_proxy=2') + '&_jsonp=' jsonpManager.reg(OwnerPhoto.thumbErrorShow) + '&_origin=' encodeURIComponent(locProtocol '//' locHost)
      }));
    });
  },
  
thumbErrorShow: function(res) {
    var 
obj parseJSON(res) || {};
    if (!
obj.error) return;

    
OwnerPhoto.showError(2obj.error Upload.getErrorAdditional(obj));
  },

  
crop: function(opts) {
    var 
cont ge('owner_photo_crop'), wrap ge('owner_photo_crop_thumb'), opts.thumbSize;
    
cur.ownerPhotoCropOpts opts;

    
show(cont);
    
cont.insertBefore(ce('div', {className'msg'id'owner_photo_error'}), wrap);
    
val(wrap'
<div id="owner_photo_crop_wrap" class="clear_fix">
  <div class="fl_l"><img id="owner_photo_crop_img" src="' 
opts.thumb '" style="width: ' s[0] + 'px; height: ' s[1] + 'px;" onload="stManager.add(['tagger.css', 'tagger.js'], OwnerPhoto.cropInit)" onerror="OwnerPhoto.thumbError()" /></div>
  <div class="fl_l"><div id="owner_photo_preview100"></div></div>
  <div class="fl_l"><div id="owner_photo_preview50"></div></div>
</div>'
);

    
cur.ownerPhotoBoxRefresh();
    
setTimeout(cur.ownerPhotoBoxRefresh0);
  },
  
cropInit: function() {
    var 
opts cur.ownerPhotoCropOptssize opts.sizetsize opts.thumbSizeminSize = [
      
Math.max(75Math.ceil(200 tsize[0] / size[0])),
      
Math.max(75Math.ceil(200 tsize[1] / size[1]))
    ], 
rect;
    if (
opts.rect) {
      
rect = {
        
leftMath.floor(opts.rect[0] * tsize[0] / size[0]),
        
topMath.floor(opts.rect[1] * tsize[1] / size[1]),
        
widthMath.ceil(opts.rect[2] * tsize[0] / size[0]),
        
heightMath.ceil(opts.rect[2] * tsize[1] / size[1])
      }
    } else {
      
rect = {widthMath.max(minSize[0], tsize[0] - 40), heightMath.max(minSize[1], tsize[1] - 40)};
      if (
rect.width rect.height) {
        
rect.width rect.height;
      } else if (
rect.height rect.width) {
        
rect.height rect.width;
      }
      
rect.left Math.floor((tsize[0] - rect.width) / 2);
      
rect.top Math.min(Math.floor((tsize[1] - rect.height) / 2), 20);
    }
    if (
cur.ownerPhotoCropTagger) {
      
cur.ownerPhotoCropTagger.destroy();
    }
    
cur.ownerPhotoCropTagger photoTagger('owner_photo_crop_img', {
      
minwminSize[0],
      
minhminSize[1],
      
preview50'owner_photo_preview50',
      
preview100'owner_photo_preview100',
      
square1,
      
rectrect,
      
zstart1000
    
});
  },
  
cropDone: function() {
    
lockButton('owner_photo_done');
    
clearTimeout(cur.ownerPhotoCropTimer);
    
cur.ownerPhotoCropTimer setTimeout(OwnerPhoto.cropSuccess.pbind('{"error":"ERR_CLIENT_UPLOAD_TIMEOUT: no response on owner_photo_crop iframe request"}'), 10000);
    
stManager.add(['upload.js'], function() {
      var 
rect cur.ownerPhotoCropTagger.result(), opts cur.ownerPhotoCropOpts;
      var 
cx opts.size[0] / opts.thumbSize[0], cy opts.size[1] / opts.thumbSize[1], crop = [
        
Math.floor(rect[0] * cx),
        
Math.floor(rect[1] * cy),
        
Math.ceil(rect[2] * cx// or Math.ceil(rect[3] * cy), must be almost equal
      
], jsonp jsonpManager.reg(OwnerPhoto.cropSuccess);
      
utilsNode.appendChild(ce('iframe', {
        
srcopts.uploadUrl '&_crop=' crop.join(',') + '&_jsonp=' jsonp '&_origin=' encodeURIComponent(locProtocol '//' locHost)
      }));
    });
  },
  
cropSuccess: function(res) {
    
clearTimeout(cur.ownerPhotoCropTimer);
    var 
obj parseJSON(res) || {};
    if (
obj.error) {
      
unlockButton('owner_photo_done');
      
OwnerPhoto.showError(3obj.error Upload.getErrorAdditional(obj));
    } else {
      if (
cur.photoTooltipHide) {
        
cur.photoTooltipHide(true);
      }
      
ajax.post('al_page.php', {act'owner_photo_save'_queryres}, {
        
onDonenav.reload,
        
onFail: function(text) {
          
OwnerPhoto.showError(3text);
          return 
true;
        },
        
showProgresslockButton.pbind('owner_photo_done'),
        
hideProgressunlockButton.pbind('owner_photo_done')
      });
    }
  }
}

try {
stManager.done('owner_photo.js');}catch(e){}
?>
Онлайн: 0
Реклама