|
459 | 459 | }); |
460 | 460 |
|
461 | 461 |
|
| 462 | + api.Image && _inherit(api.Image, { |
| 463 | + fromDataURL: function (dataURL, size, callback){ |
| 464 | + if( !api.support.dataURI || dataURL.length > 3e4 ){ |
| 465 | + _makeFlashImage( |
| 466 | + api.extend({ scale: 'exactFit' }, size) |
| 467 | + , dataURL.replace(/^data:[^,]+,/, '') |
| 468 | + , function (err, el){ callback(el); } |
| 469 | + ); |
| 470 | + } |
| 471 | + else { |
| 472 | + this.parent(dataURL, size, callback); |
| 473 | + } |
| 474 | + } |
| 475 | + }); |
| 476 | + |
| 477 | + |
| 478 | + |
462 | 479 | // FileAPI.Camera:statics |
463 | 480 | api.Camera.fallback = function (el, options, callback){ |
464 | 481 | var camId = api.uid(); |
|
720 | 737 |
|
721 | 738 |
|
722 | 739 | function _makeFlashImage(opts, base64, fn){ |
723 | | - var _id, flashId = api.uid(), el = document.createElement('div'); |
| 740 | + var |
| 741 | + key |
| 742 | + , flashId = api.uid() |
| 743 | + , el = document.createElement('div') |
| 744 | +// , attempts = 10 |
| 745 | + ; |
724 | 746 |
|
725 | | - for( _id in opts ){ |
726 | | - el.setAttribute(_id, opts[_id]); |
727 | | - el[_id] = opts[_id]; |
| 747 | + for( key in opts ){ |
| 748 | + el.setAttribute(key, opts[key]); |
| 749 | + el[key] = opts[key]; |
728 | 750 | } |
729 | 751 |
|
730 | 752 | _css(el, opts); |
|
736 | 758 | id: flashId |
737 | 759 | , src: _getUrl(api.flashImageUrl, 'r='+ api.uid()) |
738 | 760 | , wmode: 'opaque' |
739 | | - , flashvars: 'scale='+ opts.scale +'&callback='+_wrap(function _setData(){ |
740 | | - _unwrap(_setData); |
741 | | - setTimeout(_setImage, 99); |
| 761 | + , flashvars: 'scale='+ opts.scale +'&callback='+_wrap(function _(){ |
| 762 | + _unwrap(_); |
| 763 | + _setImage(); |
742 | 764 | return true; |
743 | 765 | }) |
744 | 766 | }, opts)); |
|
0 commit comments