Merge pull request #371 from nickago/MM-1229
MM-1229 Mobile client display public link in same tab instead of new tab
Этот коммит содержится в:
@@ -6,6 +6,13 @@ var utils = require('../utils/utils.jsx');
|
|||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'ViewImageModal',
|
displayName: 'ViewImageModal',
|
||||||
|
propTypes: {
|
||||||
|
filenames: React.PropTypes.array,
|
||||||
|
modalId: React.PropTypes.string,
|
||||||
|
channelId: React.PropTypes.string,
|
||||||
|
userId: React.PropTypes.string,
|
||||||
|
startId: React.PropTypes.number
|
||||||
|
},
|
||||||
canSetState: false,
|
canSetState: false,
|
||||||
handleNext: function() {
|
handleNext: function() {
|
||||||
var id = this.state.imgId + 1;
|
var id = this.state.imgId + 1;
|
||||||
@@ -56,8 +63,8 @@ module.exports = React.createClass({
|
|||||||
progress[id] = img.completedPercentage;
|
progress[id] = img.completedPercentage;
|
||||||
self.setState({progress: progress});
|
self.setState({progress: progress});
|
||||||
});
|
});
|
||||||
img.onload = function(imgid) {
|
img.onload = function onload(imgid) {
|
||||||
return function() {
|
return function onloadReturn() {
|
||||||
var loaded = self.state.loaded;
|
var loaded = self.state.loaded;
|
||||||
loaded[imgid] = true;
|
loaded[imgid] = true;
|
||||||
self.setState({loaded: loaded});
|
self.setState({loaded: loaded});
|
||||||
@@ -83,21 +90,21 @@ module.exports = React.createClass({
|
|||||||
},
|
},
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
$('#' + this.props.modalId).on('shown.bs.modal', function() {
|
$('#' + this.props.modalId).on('shown.bs.modal', function onModalShow() {
|
||||||
self.setState({viewed: true});
|
self.setState({viewed: true});
|
||||||
self.loadImage(self.state.imgId);
|
self.loadImage(self.state.imgId);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(this.refs.modal.getDOMNode()).click(function(e) {
|
$(this.refs.modal.getDOMNode()).click(function onModalClick(e) {
|
||||||
if (e.target === this || e.target === self.refs.imageBody.getDOMNode()) {
|
if (e.target === this || e.target === self.refs.imageBody.getDOMNode()) {
|
||||||
$('.image_modal').modal('hide');
|
$('.image_modal').modal('hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(this.refs.imageWrap.getDOMNode()).hover(
|
$(this.refs.imageWrap.getDOMNode()).hover(
|
||||||
function() {
|
function onModalHover() {
|
||||||
$(self.refs.imageFooter.getDOMNode()).addClass('footer--show');
|
$(self.refs.imageFooter.getDOMNode()).addClass('footer--show');
|
||||||
}, function() {
|
}, function offModalHover() {
|
||||||
$(self.refs.imageFooter.getDOMNode()).removeClass('footer--show');
|
$(self.refs.imageFooter.getDOMNode()).removeClass('footer--show');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -117,10 +124,14 @@ module.exports = React.createClass({
|
|||||||
data.user_id = this.props.userId;
|
data.user_id = this.props.userId;
|
||||||
data.filename = this.props.filenames[this.state.imgId];
|
data.filename = this.props.filenames[this.state.imgId];
|
||||||
Client.getPublicLink(data,
|
Client.getPublicLink(data,
|
||||||
function(serverData) {
|
function sucess(serverData) {
|
||||||
window.open(serverData.public_link);
|
if (utils.isMobile()) {
|
||||||
|
window.location.href = serverData.public_link;
|
||||||
|
} else {
|
||||||
|
window.open(serverData.public_link);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
function() {
|
function error() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -145,7 +156,7 @@ module.exports = React.createClass({
|
|||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
var loaded = [];
|
var loaded = [];
|
||||||
var progress = [];
|
var progress = [];
|
||||||
for (var i = 0; i < this.props.filenames.length; i ++) {
|
for (var i = 0; i < this.props.filenames.length; i++) {
|
||||||
loaded.push(false);
|
loaded.push(false);
|
||||||
progress.push(0);
|
progress.push(0);
|
||||||
}
|
}
|
||||||
@@ -198,7 +209,7 @@ module.exports = React.createClass({
|
|||||||
if (!(filename in this.state.fileSizes)) {
|
if (!(filename in this.state.fileSizes)) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
utils.getFileSize(utils.getFileUrl(filename), function(fileSize) {
|
utils.getFileSize(utils.getFileUrl(filename), function fileSizeOp(fileSize) {
|
||||||
if (self.canSetState) {
|
if (self.canSetState) {
|
||||||
var fileSizes = self.state.fileSizes;
|
var fileSizes = self.state.fileSizes;
|
||||||
fileSizes[filename] = fileSize;
|
fileSizes[filename] = fileSize;
|
||||||
@@ -210,14 +221,20 @@ module.exports = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
// display a progress indicator when the preview for an image is still loading
|
// display a progress indicator when the preview for an image is still loading
|
||||||
var percentage = Math.floor(this.state.progress[this.state.imgId]);
|
var percentage = Math.floor(this.state.progress[this.state.imgId]);
|
||||||
content = (
|
if (percentage) {
|
||||||
<div>
|
content = (
|
||||||
<img className='loader-image' src='/static/images/load.gif' />
|
<div>
|
||||||
{ percentage > 0 ?
|
<img className='loader-image' src='/static/images/load.gif' />
|
||||||
<span className='loader-percent' >{'Previewing ' + percentage + '%'}</span>
|
<span className='loader-percent' >{'Previewing ' + percentage + '%'}</span>
|
||||||
: ''}
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
} else {
|
||||||
|
content = (
|
||||||
|
<div>
|
||||||
|
<img className='loader-image' src='/static/images/load.gif' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
bgClass = 'black-bg';
|
bgClass = 'black-bg';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user