@upendradevsingh/webcore
Version:
UI Core Components for web
82 lines (61 loc) • 3.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _utils = require('../utils');
var utils = _interopRequireWildcard(_utils);
var _Modal = require('../Modal');
var _Modal2 = _interopRequireDefault(_Modal);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* =======================================================
* WebCore: Smart Anchor Component 1.0.0
* https://webcore.jabong.com/components/smartanchor
* =======================================================
* * Copyright 2017 Jabong, Inc.
* Licensed under MIT (https://github.com/jabong/webcore/blob/master/LICENSE)
*/
var SmartAnchor = function (_Component) {
_inherits(SmartAnchor, _Component);
function SmartAnchor() {
_classCallCheck(this, SmartAnchor);
return _possibleConstructorReturn(this, (SmartAnchor.__proto__ || Object.getPrototypeOf(SmartAnchor)).apply(this, arguments));
}
_createClass(SmartAnchor, [{
key: 'onClick',
value: function onClick(event) {
// Navigate user to new page in mobile devices
if (utils.browser.isMobile()) {
return true;
} else {
// Open a dialog for given url
event.preventDefault();
var url = utils.browser.isSecureProtocol() ? this.props.secureUrl : this.props.nonSecureUrl;
//@todo Add dialog support late
_react2.default.render(_react2.default.createElement(_Modal2.default, { dataUrl: url }), document.body);
}
}
}, {
key: 'render',
value: function render() {
var attrs = {
href: '' + this.props.baseUrl + this.props.to
};
if (typeof this.props.gaq !== 'undefined') attrs['data-gaq-event'] = this.props.gaq;
return _react2.default.createElement(
'a',
attrs,
this.props.children
);
}
}]);
return SmartAnchor;
}(_react.Component);
exports.default = SmartAnchor;