UNPKG

16.3 kBJavaScriptView Raw
1module.exports =
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId])
11/******/ return installedModules[moduleId].exports;
12
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ exports: {},
16/******/ id: moduleId,
17/******/ loaded: false
18/******/ };
19
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
23/******/ // Flag the module as loaded
24/******/ module.loaded = true;
25
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29
30
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36
37/******/ // __webpack_public_path__
38/******/ __webpack_require__.p = "/";
39
40/******/ // Load entry module and return exports
41/******/ return __webpack_require__(0);
42/******/ })
43/************************************************************************/
44/******/ ([
45/* 0 */
46/***/ function(module, exports, __webpack_require__) {
47
48 "use strict";
49
50 var React = __webpack_require__(1);
51 var cx = __webpack_require__(2);
52
53 var TooltipApi = __webpack_require__(3).api;
54 var SearchableApi = __webpack_require__(4).api;
55
56 module.exports = React.createClass({
57 displayName: "exports",
58
59 propTypes: {
60 displayBy: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.func]).isRequired,
61 imageBy: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.func]).isRequired,
62
63 size: React.PropTypes.number,
64 crop: React.PropTypes.number,
65 round: React.PropTypes.bool,
66
67 data: React.PropTypes.object,
68 dataset: React.PropTypes.arrayOf(React.PropTypes.object),
69 default: React.PropTypes.string,
70 onDataChange: React.PropTypes.func
71 },
72 componentWillMount: function componentWillMount() {
73 __webpack_require__(5);
74 },
75 componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
76 this.setState({
77 data: nextProps.data
78 });
79 },
80 getInitialState: function getInitialState() {
81 return {
82 data: this.props.data
83 };
84 },
85 handleClick: function handleClick(event) {
86 var _this = this;
87
88 if (!this.props.dataset) return;
89 SearchableApi.show(this.refs.main, this.props.dataset, this.props.displayBy, this.props.imageBy, this.state.data ? true : false, this.props.default, function (item) {
90
91 if (_this.props.onDataChange) _this.props.onDataChange(item);
92 _this.setState({
93 data: item
94 });
95 });
96 },
97 handleMouseEnter: function handleMouseEnter() {
98 if (!this.state.data && !this.props.default) return;
99
100 var name = null;
101 if (this.state.data) {
102 name = this.state.data[this.props.displayBy];
103 if (typeof name === "function") name = name.bind(this.state.data)();
104 }
105
106 TooltipApi.showTooltip(name || this.props.default);
107 },
108 handleMouseLeave: function handleMouseLeave() {
109 if (!this.state.data && !this.props.default) return;
110 TooltipApi.hideTooltip();
111 },
112 render: function render() {
113 var name = null;
114 var image = null;
115
116 if (this.state.data) {
117 name = this.state.data[this.props.displayBy];
118 if (typeof name === "function") name = name.bind(this.state.data)();
119
120 image = this.state.data[this.props.imageBy];
121 if (typeof image === "function") image = image.bind(this.state.data)();
122 }
123
124 var size = 50;
125 if (this.props.size >= 0) size = this.props.size;
126
127 var crop = 12;
128 if (this.props.crop >= 0) crop = this.props.crop;
129
130 var style = {
131 width: size - (this.state.data ? 0 : 2) + "px",
132 height: size - (this.state.data ? 0 : 2) + "px",
133 cursor: this.props.dataset ? "pointer" : "default"
134 };
135
136 var imgStyle = {
137 top: -crop / 2 + "px",
138 left: -crop / 2 + "px",
139 width: size + crop + "px",
140 height: size + crop + "px"
141 };
142
143 var className = cx("component-object-image", {
144 changeable: this.props.dataset,
145 populated: this.state.data,
146 round: this.props.round
147 }, this.props.className);
148
149 return React.createElement(
150 "div",
151 { className: className, ref: "main" },
152 React.createElement(
153 "div",
154 { style: style, onClick: this.handleClick, onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave },
155 this.state.data ? React.createElement("img", { src: image, style: imgStyle }) : null
156 )
157 );
158 }
159 });
160
161/***/ },
162/* 1 */
163/***/ function(module, exports) {
164
165 module.exports = require("react");
166
167/***/ },
168/* 2 */
169/***/ function(module, exports) {
170
171 module.exports = require("classnames");
172
173/***/ },
174/* 3 */
175/***/ function(module, exports) {
176
177 module.exports = require("../tooltip");
178
179/***/ },
180/* 4 */
181/***/ function(module, exports) {
182
183 module.exports = require("../searchable-modal");
184
185/***/ },
186/* 5 */
187/***/ function(module, exports, __webpack_require__) {
188
189 // style-loader: Adds some css to the DOM by adding a <style> tag
190
191 // load the styles
192 var content = __webpack_require__(6);
193 if(typeof content === 'string') content = [[module.id, content, '']];
194 // add the styles to the DOM
195 var update = __webpack_require__(8)(content, {});
196 if(content.locals) module.exports = content.locals;
197 // Hot Module Replacement
198 if(false) {
199 // When the styles change, update the <style> tags
200 if(!content.locals) {
201 module.hot.accept("!!./../../node_modules/css-loader/index.js!./../../node_modules/sass-loader/index.js!./style.scss", function() {
202 var newContent = require("!!./../../node_modules/css-loader/index.js!./../../node_modules/sass-loader/index.js!./style.scss");
203 if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
204 update(newContent);
205 });
206 }
207 // When the module is disposed, remove the <style> tags
208 module.hot.dispose(function() { update(); });
209 }
210
211/***/ },
212/* 6 */
213/***/ function(module, exports, __webpack_require__) {
214
215 exports = module.exports = __webpack_require__(7)();
216 // imports
217
218
219 // module
220 exports.push([module.id, ".component-object-image {\n border: 1px dashed rgba(255, 255, 255, 0.5);\n overflow: hidden;\n display: inline-block;\n vertical-align: middle; }\n .component-object-image img {\n position: relative; }\n .component-object-image.round {\n border-radius: 200px; }\n .component-object-image.populated {\n border: none;\n opacity: 1; }\n .component-object-image.populated:not(.round) {\n border-radius: 5px; }\n .component-object-image.changeable .component-object-image:hover {\n background-color: rgba(255, 255, 255, 0.1); }\n\n.object-tooltip {\n height: 20px;\n position: fixed;\n padding: 5px 10px 0px;\n z-index: 5000;\n pointer-events: none;\n background-color: white;\n color: #14083f;\n text-transform: uppercase;\n font-size: 10px;\n letter-spacing: 0.05em;\n box-shadow: 0px 0px 5px 4px rgba(0, 0, 0, 0.25);\n opacity: 0;\n transition: opacity 0.05s; }\n .object-tooltip.show {\n opacity: 1; }\n", ""]);
221
222 // exports
223
224
225/***/ },
226/* 7 */
227/***/ function(module, exports) {
228
229 /*
230 MIT License http://www.opensource.org/licenses/mit-license.php
231 Author Tobias Koppers @sokra
232 */
233 // css base code, injected by the css-loader
234 module.exports = function() {
235 var list = [];
236
237 // return the list of modules as css string
238 list.toString = function toString() {
239 var result = [];
240 for(var i = 0; i < this.length; i++) {
241 var item = this[i];
242 if(item[2]) {
243 result.push("@media " + item[2] + "{" + item[1] + "}");
244 } else {
245 result.push(item[1]);
246 }
247 }
248 return result.join("");
249 };
250
251 // import a list of modules into the list
252 list.i = function(modules, mediaQuery) {
253 if(typeof modules === "string")
254 modules = [[null, modules, ""]];
255 var alreadyImportedModules = {};
256 for(var i = 0; i < this.length; i++) {
257 var id = this[i][0];
258 if(typeof id === "number")
259 alreadyImportedModules[id] = true;
260 }
261 for(i = 0; i < modules.length; i++) {
262 var item = modules[i];
263 // skip already imported module
264 // this implementation is not 100% perfect for weird media query combinations
265 // when a module is imported multiple times with different media queries.
266 // I hope this will never occur (Hey this way we have smaller bundles)
267 if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
268 if(mediaQuery && !item[2]) {
269 item[2] = mediaQuery;
270 } else if(mediaQuery) {
271 item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
272 }
273 list.push(item);
274 }
275 }
276 };
277 return list;
278 };
279
280
281/***/ },
282/* 8 */
283/***/ function(module, exports, __webpack_require__) {
284
285 /*
286 MIT License http://www.opensource.org/licenses/mit-license.php
287 Author Tobias Koppers @sokra
288 */
289 var stylesInDom = {},
290 memoize = function(fn) {
291 var memo;
292 return function () {
293 if (typeof memo === "undefined") memo = fn.apply(this, arguments);
294 return memo;
295 };
296 },
297 isOldIE = memoize(function() {
298 return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
299 }),
300 getHeadElement = memoize(function () {
301 return document.head || document.getElementsByTagName("head")[0];
302 }),
303 singletonElement = null,
304 singletonCounter = 0,
305 styleElementsInsertedAtTop = [];
306
307 module.exports = function(list, options) {
308 if(false) {
309 if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
310 }
311
312 options = options || {};
313 // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
314 // tags it will allow on a page
315 if (typeof options.singleton === "undefined") options.singleton = isOldIE();
316
317 // By default, add <style> tags to the bottom of <head>.
318 if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
319
320 var styles = listToStyles(list);
321 addStylesToDom(styles, options);
322
323 return function update(newList) {
324 var mayRemove = [];
325 for(var i = 0; i < styles.length; i++) {
326 var item = styles[i];
327 var domStyle = stylesInDom[item.id];
328 domStyle.refs--;
329 mayRemove.push(domStyle);
330 }
331 if(newList) {
332 var newStyles = listToStyles(newList);
333 addStylesToDom(newStyles, options);
334 }
335 for(var i = 0; i < mayRemove.length; i++) {
336 var domStyle = mayRemove[i];
337 if(domStyle.refs === 0) {
338 for(var j = 0; j < domStyle.parts.length; j++)
339 domStyle.parts[j]();
340 delete stylesInDom[domStyle.id];
341 }
342 }
343 };
344 }
345
346 function addStylesToDom(styles, options) {
347 for(var i = 0; i < styles.length; i++) {
348 var item = styles[i];
349 var domStyle = stylesInDom[item.id];
350 if(domStyle) {
351 domStyle.refs++;
352 for(var j = 0; j < domStyle.parts.length; j++) {
353 domStyle.parts[j](item.parts[j]);
354 }
355 for(; j < item.parts.length; j++) {
356 domStyle.parts.push(addStyle(item.parts[j], options));
357 }
358 } else {
359 var parts = [];
360 for(var j = 0; j < item.parts.length; j++) {
361 parts.push(addStyle(item.parts[j], options));
362 }
363 stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
364 }
365 }
366 }
367
368 function listToStyles(list) {
369 var styles = [];
370 var newStyles = {};
371 for(var i = 0; i < list.length; i++) {
372 var item = list[i];
373 var id = item[0];
374 var css = item[1];
375 var media = item[2];
376 var sourceMap = item[3];
377 var part = {css: css, media: media, sourceMap: sourceMap};
378 if(!newStyles[id])
379 styles.push(newStyles[id] = {id: id, parts: [part]});
380 else
381 newStyles[id].parts.push(part);
382 }
383 return styles;
384 }
385
386 function insertStyleElement(options, styleElement) {
387 var head = getHeadElement();
388 var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
389 if (options.insertAt === "top") {
390 if(!lastStyleElementInsertedAtTop) {
391 head.insertBefore(styleElement, head.firstChild);
392 } else if(lastStyleElementInsertedAtTop.nextSibling) {
393 head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
394 } else {
395 head.appendChild(styleElement);
396 }
397 styleElementsInsertedAtTop.push(styleElement);
398 } else if (options.insertAt === "bottom") {
399 head.appendChild(styleElement);
400 } else {
401 throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
402 }
403 }
404
405 function removeStyleElement(styleElement) {
406 styleElement.parentNode.removeChild(styleElement);
407 var idx = styleElementsInsertedAtTop.indexOf(styleElement);
408 if(idx >= 0) {
409 styleElementsInsertedAtTop.splice(idx, 1);
410 }
411 }
412
413 function createStyleElement(options) {
414 var styleElement = document.createElement("style");
415 styleElement.type = "text/css";
416 insertStyleElement(options, styleElement);
417 return styleElement;
418 }
419
420 function createLinkElement(options) {
421 var linkElement = document.createElement("link");
422 linkElement.rel = "stylesheet";
423 insertStyleElement(options, linkElement);
424 return linkElement;
425 }
426
427 function addStyle(obj, options) {
428 var styleElement, update, remove;
429
430 if (options.singleton) {
431 var styleIndex = singletonCounter++;
432 styleElement = singletonElement || (singletonElement = createStyleElement(options));
433 update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
434 remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
435 } else if(obj.sourceMap &&
436 typeof URL === "function" &&
437 typeof URL.createObjectURL === "function" &&
438 typeof URL.revokeObjectURL === "function" &&
439 typeof Blob === "function" &&
440 typeof btoa === "function") {
441 styleElement = createLinkElement(options);
442 update = updateLink.bind(null, styleElement);
443 remove = function() {
444 removeStyleElement(styleElement);
445 if(styleElement.href)
446 URL.revokeObjectURL(styleElement.href);
447 };
448 } else {
449 styleElement = createStyleElement(options);
450 update = applyToTag.bind(null, styleElement);
451 remove = function() {
452 removeStyleElement(styleElement);
453 };
454 }
455
456 update(obj);
457
458 return function updateStyle(newObj) {
459 if(newObj) {
460 if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
461 return;
462 update(obj = newObj);
463 } else {
464 remove();
465 }
466 };
467 }
468
469 var replaceText = (function () {
470 var textStore = [];
471
472 return function (index, replacement) {
473 textStore[index] = replacement;
474 return textStore.filter(Boolean).join('\n');
475 };
476 })();
477
478 function applyToSingletonTag(styleElement, index, remove, obj) {
479 var css = remove ? "" : obj.css;
480
481 if (styleElement.styleSheet) {
482 styleElement.styleSheet.cssText = replaceText(index, css);
483 } else {
484 var cssNode = document.createTextNode(css);
485 var childNodes = styleElement.childNodes;
486 if (childNodes[index]) styleElement.removeChild(childNodes[index]);
487 if (childNodes.length) {
488 styleElement.insertBefore(cssNode, childNodes[index]);
489 } else {
490 styleElement.appendChild(cssNode);
491 }
492 }
493 }
494
495 function applyToTag(styleElement, obj) {
496 var css = obj.css;
497 var media = obj.media;
498
499 if(media) {
500 styleElement.setAttribute("media", media)
501 }
502
503 if(styleElement.styleSheet) {
504 styleElement.styleSheet.cssText = css;
505 } else {
506 while(styleElement.firstChild) {
507 styleElement.removeChild(styleElement.firstChild);
508 }
509 styleElement.appendChild(document.createTextNode(css));
510 }
511 }
512
513 function updateLink(linkElement, obj) {
514 var css = obj.css;
515 var sourceMap = obj.sourceMap;
516
517 if(sourceMap) {
518 // http://stackoverflow.com/a/26603875
519 css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
520 }
521
522 var blob = new Blob([css], { type: "text/css" });
523
524 var oldSrc = linkElement.href;
525
526 linkElement.href = URL.createObjectURL(blob);
527
528 if(oldSrc)
529 URL.revokeObjectURL(oldSrc);
530 }
531
532
533/***/ }
534/******/ ]);
\No newline at end of file