Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
fix aslant issues
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoddox committed Dec 30, 2015
1 parent 1c0d7d0 commit c715c61
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib
node_modules
node_modules
demo
2 changes: 1 addition & 1 deletion src/Button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {Component} from 'react';
import ReactTransitionEvents from 'react/lib/ReactTransitionEvents';
import CSSCore from 'fbjs/lib/CSSCore';

import {_bind, onCSSTransitionEnd} from './utils';
Expand All @@ -13,6 +12,7 @@ export default class Button extends Component {
}

handleClick(e) {
e.preventDefault();
CSSCore.addClass(this.toastrButton, 'active');

/*
Expand Down
8 changes: 4 additions & 4 deletions src/ReduxToastr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React,{Component, PropTypes} from 'react';
import React, {Component, PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import classnames from 'classnames';
Expand Down Expand Up @@ -100,11 +100,11 @@ export class ReduxToastr extends Component {
okText={confirmOkText}
cancelText={confirmCancelText}/>

{toastr.toastrs.map((toastr) => {
{toastr.toastrs.map((item) => {
return (
<ToastrBox
key={toastr.id}
toastr={toastr}
key={item.id}
toastr={item}
timeOut={this.props.timeOut}
remove={this.handleRemoveToastr}/>
);
Expand Down
14 changes: 6 additions & 8 deletions src/ToastrBox.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import CSSCore from 'fbjs/lib/CSSCore';
import ReactTransitionEvents from 'react/lib/ReactTransitionEvents';
import React, {Component, PropTypes, dangerouslySetInnerHTML} from 'react';
import classnames from 'classnames';
import {config} from './config';

import {_bind, hasProperty, mapToIcon, onCSSTransitionEnd} from './utils';
import {_bind, hasProperty, mapToIcon, onCSSTransitionEnd, returnFuncFromObj} from './utils';


export default class ToastrBox extends Component {
Expand Down Expand Up @@ -52,7 +50,7 @@ export default class ToastrBox extends Component {

if (toastr.type !== 'message') {
this._setIntervalId(setTimeout(this._removeToastr, time));
}
}

this._setTransition();
onCSSTransitionEnd(this.toastrBox, this._onAnimationComplite);
Expand Down Expand Up @@ -81,14 +79,14 @@ export default class ToastrBox extends Component {

mouseLeave() {
const {toastr} = this.props;
if(this.isHiding || toastr.type == 'message') {
if (this.isHiding || toastr.type == 'message') {
return;
}

this._setIntervalId(setTimeout(this._removeToastr, 1000));
}

_onAnimationComplite(e) {
_onAnimationComplite() {
const {remove, toastr} = this.props;
const {options} = toastr;

Expand Down Expand Up @@ -146,10 +144,10 @@ export default class ToastrBox extends Component {
const {toastr} = this.props;

if (toastr.type == 'message') {
return <div className="message"><p dangerouslySetInnerHTML={{__html: toastr.message}}></p></div>
return <div className="message"><p dangerouslySetInnerHTML={{__html: toastr.message}}></p></div>;
}

return <div className="message">{toastr.message}</div>
return <div className="message">{toastr.message}</div>;
}

render() {
Expand Down
9 changes: 5 additions & 4 deletions src/ToastrConfirm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {Component, PropTypes} from 'react';
import ReactTransitionEvents from 'react/lib/ReactTransitionEvents';
import CSSCore from 'fbjs/lib/CSSCore';
import {_bind, hasProperty, onCSSTransitionEnd, returnFuncFromObj} from './utils';
import {_bind, onCSSTransitionEnd, returnFuncFromObj} from './utils';
import Button from './Button';

export default class ToastrConfirm extends Component {
Expand Down Expand Up @@ -33,13 +32,15 @@ export default class ToastrConfirm extends Component {
}
}

handleConfirmClick() {
handleConfirmClick(e) {
e.preventDefault();
const {options} = this.props.confirm;
returnFuncFromObj(options, 'onOk');
this._setTransition();
}

handleCancelClick(e) {
e.preventDefault();
const {options} = this.props.confirm;
returnFuncFromObj(options, 'onCancel');
this._setTransition();
Expand All @@ -62,7 +63,7 @@ export default class ToastrConfirm extends Component {
onCSSTransitionEnd(this.confirm, this._onConfirmAnimationComplete);
}

_onConfirmAnimationComplete(e) {
_onConfirmAnimationComplete() {
if (this.isHiding) {
this._removeConfirm();
}
Expand Down
6 changes: 3 additions & 3 deletions src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default createReducer(initialState, {
return {
...state,
toastrs: state.toastrs.filter(toastr => toastr.id !== payload.id)
}
};
},
[CLEAN_TOASTR]: (state) => {
return {
Expand All @@ -57,7 +57,7 @@ export default createReducer(initialState, {
message: payload.message,
options: payload.options || null
}
}
};
},
[HIDE_CONFIRM]: (state) => {
return {
Expand All @@ -66,6 +66,6 @@ export default createReducer(initialState, {
show: false,
options: null
}
}
};
}
});
23 changes: 11 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function mapToToastrMessage(type, array) {
options: {}
};

if(!array.length) {
if (!array.length) {
console.error('REDUX-TOASTR ERROR:: The toastr method: ' + type + ' cannot be empty', array);
return false;
}
Expand All @@ -42,7 +42,7 @@ export function mapToToastrMessage(type, array) {
if (array.length > 1 && isString(array[0]) && isString(array[1])) {
obj.title = array[0];
obj.message = array[1];
} else if (isString(array[0])){
} else if (isString(array[0])) {
if (type == 'message') {
obj.title = 'Message';
}
Expand All @@ -56,7 +56,7 @@ export function mapToToastrMessage(type, array) {
}

export function mapToIcon(icon) {
switch(icon) {
switch (icon) {
case 'info':
return 'icon-information-circle';
case 'success':
Expand Down Expand Up @@ -108,20 +108,19 @@ function isString(obj) {
}
return false;
}


function hasObject(item) {
return item.icon || item.timeOut || item.onShowComplete || item.onHideComplete || item.icon;
}

function detectIsMobile() {
if (navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
function detectIsMobile() {
if (navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
) {
return true;
}else {
Expand Down

0 comments on commit c715c61

Please sign in to comment.