<commit_before>import React from 'react';
import {connectToStores} from 'fluxible-addons-react';
import { Button, Icon, Modal, Container, Segment, TextArea} from 'semantic-ui-react';
import UserProfileStore from '../../../../stores/UserProfileStore';
import AttachSubdeckModalStore from '../../../../stores/AttachSubdeckModalStore';
import FocusTrap from 'focus-trap-react';
import loadUserDecks  from '../../../../actions/attachSubdeck/loadUserDecks';
import loadRecentDecks  from '../../../../actions/attachSubdeck/loadRecentDecks';
import resetModalStore from '../../../../actions/attachSubdeck/resetModalStore';
import loadSlides from '../../../../actions/attachSubdeck/loadSlides';
import initModal from '../../../../actions/attachSubdeck/initModal';
import addTreeNodeListAndNavigate from '../../../../actions/decktree/addTreeNodeListAndNavigate';
import updateSelectedSlides  from '../../../../actions/attachSubdeck/updateSelectedSlides';
import AttachDeckList from './AttachDeckList';
import AttachMenu from './AttachMenu';
import AttachMyDecks from './AttachMyDecks';
import AttachSlideWiki from './AttachSlideWiki';
import AttachSearchForm from './AttachSearchForm';
import AttachSlides from './AttachSlides';

class AttachSubdeckModal extends React.Component{
  /*Props expected:
    buttonStyle = {
      classNames : string ->additional clases for the trigger button
      iconSize:  enum {large|small} -> final size for displaying the icon of the button. Medium is not accepted by react-semantic-ui component

   }*/

    constructor(props) {
        super(props);

        this.state = {
            modalOpen: false,
            activeItem: 'MyDecks',
            activeTrap: false,
            selectedDeckId: -1,
            selectedSlides:[],
            showSlides:false,
            deckSlides:[],

          //  selectedDeckTitle: 'Select one deck...',
          //  showSearchResults: false
        };

        this.handleOpen = this.handleOpen.bind(this);
        this.handleClose = this.handleClose.bind(this);
        this.unmountTrap = this.unmountTrap.bind(this);
        this.handleAttachButton = this.handleAttachButton.bind(this);
        this.handleNextButton = this.handleNextButton.bind(this);
        this.handlePreviousButton = this.handlePreviousButton.bind(this);

    }

    componentWillReceiveProps(nextProps){

        this.setState({
            selectedDeckId: nextProps.AttachSubdeckModalStore.selectedDeckId,
            activeItem: nextProps.AttachSubdeckModalStore.activeItem,
            selectedSlides: nextProps.AttachSubdeckModalStore.selectedSlides,
            deckSlides:nextProps.AttachSubdeckModalStore.deckSlides
        });

    }
    componentWillUnmount(){
        this.context.executeAction(resetModalStore,[]);

    }

    handleOpen(){

      //fETCH USER DECKS
        let payload = {params:{
            id2:this.props.UserProfileStore.userid,
            id:this.props.UserProfileStore.userid,
            jwt:this.props.UserProfileStore.jwt,
            loggedInUser:this.props.UserProfileStore.username,
            username:this.props.UserProfileStore.username
        }};
        let payload2 ={params: {
            limit: 20,
            offset: 0
        }};
        this.context.executeAction(loadUserDecks, payload);
        this.context.executeAction(loadRecentDecks, payload2);

        $('#app').attr('aria-hidden','true');
        this.setState({
            modalOpen:true,
            activeTrap:true
        });

    }

    handleClose(){

        $('#app').attr('aria-hidden','false');
        this.setState({
            modalOpen:false,
            activeTrap: false,
            activeItem: 'MyDecks',
            selectedSlides:[],
            showSlides:false

        });
        this.context.executeAction(initModal,[]);
    }

    unmountTrap(){
        if(this.state.activeTrap){
            this.setState({ activeTrap: false });
            $('#app').attr('aria-hidden','false');
        }

    }

    handleNextButton(){
        this.context.executeAction(loadSlides,{id:this.state.selectedDeckId});
        this.setState({
            showSlides:true
        });

    }
    handleAttachButton(){
        //selector: Object {id: "56", stype: "deck", sid: 67, spath: "67:2"}
        //nodeSec: Object { {type: "slide", id: 1245-2}, {type: "slide", id: 1585-2}}
        let nodeSpec = this.state.selectedSlides.map((slideId) => {
            return {
                type:'slide',
                id:slideId
            };
        });
        this.context.executeAction(addTreeNodeListAndNavigate, {selector: this.props.selector, nodeSpec:nodeSpec});
        this.handleClose();

    }
    handlePreviousButton(){
        this.setState({
            showSlides:false
        });
        this.context.executeAction(updateSelectedSlides,{selectedSlides:[]},null);

    }

    render() {

        //From my Decks option content
        let myDecksContent = <AttachMyDecks destinationDeckId={this.props.selector.id} actionButtonId={'#nextAttachModal'}/>;

        //From SlideWiki content
        let slideWikiContent = <AttachSlideWiki destinationDeckId={this.props.selector.id} actionButtonId={'#nextAttachModal'}/>;

        let segmentPanelContent;
        let searchForm;
        let actionButton;
        let actionButton2;
        let attachMenu;
        let modalDescription;

        if(!this.state.showSlides){//no deck selected, displaying next button
            attachMenu = <AttachMenu activeItem={this.state.activeItem}/>;
            modalDescription =  <TextArea className="sr-only" id="attachSlidesDescription" value="Select deck to attach from your  My Decks list or search SlideWiki" tabIndex ='-1'/>;
            if (this.state.activeItem === 'MyDecks'){
                searchForm ='';
                segmentPanelContent = myDecksContent;

            }else{
                searchForm =  <AttachSearchForm />;
                segmentPanelContent = slideWikiContent;
            }

            actionButton = <Button id="nextAttachModal" color="green" icon tabIndex="0" type="button" aria-label="Next Select slides"
                              data-tooltip="Attach" disabled={this.state.selectedDeckId===-1} onClick={this.handleNextButton}>
                               <Icon name="arrow right"/>
                                Next
                               <Icon name="arrow right"/>
                            </Button>;
            actionButton2='';
        } else{ //deck selected, diplay its slides, previous and attach button
            attachMenu ='';
            searchForm ='';
            modalDescription =  <TextArea className="sr-only" id="attachSlidesDescription" value="Select slides to attach" tabIndex ='-1'/>;
            segmentPanelContent = <AttachSlides numColumns="3" />;
            actionButton = <Button id="attachAttachModal" color="green" icon tabIndex="0" type="button" aria-label="Attach"
                            data-tooltip="Attach" disabled={this.state.selectedSlides.length===0} onClick={this.handleAttachButton}>
                             <Icon name="attach"/>
                              Attach
                             <Icon name="attach"/>
                          </Button>;
            actionButton2 =<Button id="previousAttachModal" color="green" icon tabIndex="0" type="button" aria-label="Previos"
                            data-tooltip="Previous" onClick={this.handlePreviousButton}>
                             <Icon name="arrow left"/>
                              Previous
                             <Icon name="arrow left"/>
                          </Button>;

        }

        return (
           <Modal trigger={
                    <Button as="button" className={this.props.buttonStyle.classNames}
                      type="button"
                      aria-label="Attach Slides"
                      data-tooltip="Attach Slides"
                      aria-hidden={this.state.modalOpen}
                      basic icon onClick={this.handleOpen}
                      tabIndex={this.props.buttonStyle.noTabIndex?-1:0} >
                        <Icon.Group size={this.props.buttonStyle.iconSize}>
                            <Icon className="grey" name="file text outline" />
                            <Icon className="corner black" name="attach" />
                        </Icon.Group>
                    </Button>
                   }
                open={this.state.modalOpen}
                onClose={this.handleClose}
                role="dialog"
                id="attachSubDeckModal"
                aria-labelledby="attachModalHeader"
                aria-describedby="attachSlidesDescription"
                aria-hidden = {!this.state.modalOpen}
                tabIndex="0">
                <FocusTrap
                        id="focus-trap-attachSubdeckModal"
                        focusTrapOptions={{
                            onDeactivate: this.unmountTrap,
                            clickOutsideDeactivates: true,
                            initialFocus: '#tabMyDecksId'
                        }}
                        active={this.state.activeTrap}
                        className = "header">

                <Modal.Header className="ui center aligned" as="h1" id="attachModalHeader">
                     Attach Slides
                </Modal.Header>
                <Modal.Content>
                    <Container text>
                         <Segment color="blue" textAlign="center" padded>
                            {attachMenu}
                            <Segment attached="bottom" textAlign="left" role="tabpanel">
                               {modalDescription}
                               {searchForm}
                               {segmentPanelContent}
                            </Segment>
                            <Modal.Actions>
                              {actionButton}
                              {actionButton2}
                              <Button color="red" tabIndex="0" type="button" aria-label="Cancel" data-tooltip="Cancel" onClick={this.handleClose} >
                                Cancel
                              </Button>
                            </Modal.Actions>
                         </Segment>
                   </Container>
                </Modal.Content>

                </FocusTrap>
            </Modal>

        );
    }

}

AttachSubdeckModal.contextTypes = {
    executeAction: React.PropTypes.func.isRequired
};

AttachSubdeckModal = connectToStores(AttachSubdeckModal,[UserProfileStore,AttachSubdeckModalStore],(context,props) => {
    return {
        UserProfileStore: context.getStore(UserProfileStore).getState(),
        AttachSubdeckModalStore: context.getStore(AttachSubdeckModalStore).getState()
    };
});

export default AttachSubdeckModal;
<commit_msg>SWIK-1426 Descritpion of the attach slides modal updated<commit_after>import React from 'react';
import {connectToStores} from 'fluxible-addons-react';
import { Button, Icon, Modal, Container, Segment, TextArea} from 'semantic-ui-react';
import UserProfileStore from '../../../../stores/UserProfileStore';
import AttachSubdeckModalStore from '../../../../stores/AttachSubdeckModalStore';
import FocusTrap from 'focus-trap-react';
import loadUserDecks  from '../../../../actions/attachSubdeck/loadUserDecks';
import loadRecentDecks  from '../../../../actions/attachSubdeck/loadRecentDecks';
import resetModalStore from '../../../../actions/attachSubdeck/resetModalStore';
import loadSlides from '../../../../actions/attachSubdeck/loadSlides';
import initModal from '../../../../actions/attachSubdeck/initModal';
import addTreeNodeListAndNavigate from '../../../../actions/decktree/addTreeNodeListAndNavigate';
import updateSelectedSlides  from '../../../../actions/attachSubdeck/updateSelectedSlides';
import AttachDeckList from './AttachDeckList';
import AttachMenu from './AttachMenu';
import AttachMyDecks from './AttachMyDecks';
import AttachSlideWiki from './AttachSlideWiki';
import AttachSearchForm from './AttachSearchForm';
import AttachSlides from './AttachSlides';

class AttachSubdeckModal extends React.Component{
  /*Props expected:
    buttonStyle = {
      classNames : string ->additional clases for the trigger button
      iconSize:  enum {large|small} -> final size for displaying the icon of the button. Medium is not accepted by react-semantic-ui component

   }*/

    constructor(props) {
        super(props);

        this.state = {
            modalOpen: false,
            activeItem: 'MyDecks',
            activeTrap: false,
            selectedDeckId: -1,
            selectedSlides:[],
            showSlides:false,
            deckSlides:[],

          //  selectedDeckTitle: 'Select one deck...',
          //  showSearchResults: false
        };

        this.handleOpen = this.handleOpen.bind(this);
        this.handleClose = this.handleClose.bind(this);
        this.unmountTrap = this.unmountTrap.bind(this);
        this.handleAttachButton = this.handleAttachButton.bind(this);
        this.handleNextButton = this.handleNextButton.bind(this);
        this.handlePreviousButton = this.handlePreviousButton.bind(this);

    }

    componentWillReceiveProps(nextProps){

        this.setState({
            selectedDeckId: nextProps.AttachSubdeckModalStore.selectedDeckId,
            activeItem: nextProps.AttachSubdeckModalStore.activeItem,
            selectedSlides: nextProps.AttachSubdeckModalStore.selectedSlides,
            deckSlides:nextProps.AttachSubdeckModalStore.deckSlides
        });

    }
    componentWillUnmount(){
        this.context.executeAction(resetModalStore,[]);

    }

    handleOpen(){

      //fETCH USER DECKS
        let payload = {params:{
            id2:this.props.UserProfileStore.userid,
            id:this.props.UserProfileStore.userid,
            jwt:this.props.UserProfileStore.jwt,
            loggedInUser:this.props.UserProfileStore.username,
            username:this.props.UserProfileStore.username
        }};
        let payload2 ={params: {
            limit: 20,
            offset: 0
        }};
        this.context.executeAction(loadUserDecks, payload);
        this.context.executeAction(loadRecentDecks, payload2);

        $('#app').attr('aria-hidden','true');
        this.setState({
            modalOpen:true,
            activeTrap:true
        });

    }

    handleClose(){

        $('#app').attr('aria-hidden','false');
        this.setState({
            modalOpen:false,
            activeTrap: false,
            activeItem: 'MyDecks',
            selectedSlides:[],
            showSlides:false

        });
        this.context.executeAction(initModal,[]);
    }

    unmountTrap(){
        if(this.state.activeTrap){
            this.setState({ activeTrap: false });
            $('#app').attr('aria-hidden','false');
        }

    }

    handleNextButton(){
        this.context.executeAction(loadSlides,{id:this.state.selectedDeckId});
        this.setState({
            showSlides:true
        });

    }
    handleAttachButton(){
        //selector: Object {id: "56", stype: "deck", sid: 67, spath: "67:2"}
        //nodeSec: Object { {type: "slide", id: 1245-2}, {type: "slide", id: 1585-2}}
        let nodeSpec = this.state.selectedSlides.map((slideId) => {
            return {
                type:'slide',
                id:slideId
            };
        });
        this.context.executeAction(addTreeNodeListAndNavigate, {selector: this.props.selector, nodeSpec:nodeSpec});
        this.handleClose();

    }
    handlePreviousButton(){
        this.setState({
            showSlides:false
        });
        this.context.executeAction(updateSelectedSlides,{selectedSlides:[]},null);

    }

    render() {

        //From my Decks option content
        let myDecksContent = <AttachMyDecks destinationDeckId={this.props.selector.id} actionButtonId={'#nextAttachModal'}/>;

        //From SlideWiki content
        let slideWikiContent = <AttachSlideWiki destinationDeckId={this.props.selector.id} actionButtonId={'#nextAttachModal'}/>;

        let segmentPanelContent;
        let searchForm;
        let actionButton;
        let actionButton2;
        let attachMenu;
        let modalDescription;

        if(!this.state.showSlides){//no deck selected, displaying next button
            attachMenu = <AttachMenu activeItem={this.state.activeItem}/>;
            modalDescription =  <TextArea className="sr-only" id="attachSlidesDescription" value="You can attach one or more slides from another deck. First select your deck containing the slides or search SlideWiki for a deck." tabIndex ='-1'/>;
            if (this.state.activeItem === 'MyDecks'){
                searchForm ='';
                segmentPanelContent = myDecksContent;

            }else{
                searchForm =  <AttachSearchForm />;
                segmentPanelContent = slideWikiContent;
            }

            actionButton = <Button id="nextAttachModal" color="green" icon tabIndex="0" type="button" aria-label="Next Select slides"
                              data-tooltip="Attach" disabled={this.state.selectedDeckId===-1} onClick={this.handleNextButton}>
                               <Icon name="arrow right"/>
                                Next
                               <Icon name="arrow right"/>
                            </Button>;
            actionButton2='';
        } else{ //deck selected, diplay its slides, previous and attach button
            attachMenu ='';
            searchForm ='';
            modalDescription =  <TextArea className="sr-only" id="attachSlidesDescription" value="Select slides to attach" tabIndex ='-1'/>;
            segmentPanelContent = <AttachSlides numColumns="3" />;
            actionButton = <Button id="attachAttachModal" color="green" icon tabIndex="0" type="button" aria-label="Attach"
                            data-tooltip="Attach" disabled={this.state.selectedSlides.length===0} onClick={this.handleAttachButton}>
                             <Icon name="attach"/>
                              Attach
                             <Icon name="attach"/>
                          </Button>;
            actionButton2 =<Button id="previousAttachModal" color="green" icon tabIndex="0" type="button" aria-label="Previos"
                            data-tooltip="Previous" onClick={this.handlePreviousButton}>
                             <Icon name="arrow left"/>
                              Previous
                             <Icon name="arrow left"/>
                          </Button>;

        }

        return (
           <Modal trigger={
                    <Button as="button" className={this.props.buttonStyle.classNames}
                      type="button"
                      aria-label="Attach Slides"
                      data-tooltip="Attach Slides"
                      aria-hidden={this.state.modalOpen}
                      basic icon onClick={this.handleOpen}
                      tabIndex={this.props.buttonStyle.noTabIndex?-1:0} >
                        <Icon.Group size={this.props.buttonStyle.iconSize}>
                            <Icon className="grey" name="file text outline" />
                            <Icon className="corner black" name="attach" />
                        </Icon.Group>
                    </Button>
                   }
                open={this.state.modalOpen}
                onClose={this.handleClose}
                role="dialog"
                id="attachSubDeckModal"
                aria-labelledby="attachModalHeader"
                aria-describedby="attachSlidesDescription"
                aria-hidden = {!this.state.modalOpen}
                tabIndex="0">
                <FocusTrap
                        id="focus-trap-attachSubdeckModal"
                        focusTrapOptions={{
                            onDeactivate: this.unmountTrap,
                            clickOutsideDeactivates: true,
                            initialFocus: '#tabMyDecksId'
                        }}
                        active={this.state.activeTrap}
                        className = "header">

                <Modal.Header className="ui center aligned" as="h1" id="attachModalHeader">
                     Attach Slides
                </Modal.Header>
                <Modal.Content>
                    <Container text>
                         <Segment color="blue" textAlign="center" padded>
                            {attachMenu}
                            <Segment attached="bottom" textAlign="left" role="tabpanel">
                               {modalDescription}
                               {searchForm}
                               {segmentPanelContent}
                            </Segment>
                            <Modal.Actions>
                              {actionButton}
                              {actionButton2}
                              <Button color="red" tabIndex="0" type="button" aria-label="Cancel" data-tooltip="Cancel" onClick={this.handleClose} >
                                Cancel
                              </Button>
                            </Modal.Actions>
                         </Segment>
                   </Container>
                </Modal.Content>

                </FocusTrap>
            </Modal>

        );
    }

}

AttachSubdeckModal.contextTypes = {
    executeAction: React.PropTypes.func.isRequired
};

AttachSubdeckModal = connectToStores(AttachSubdeckModal,[UserProfileStore,AttachSubdeckModalStore],(context,props) => {
    return {
        UserProfileStore: context.getStore(UserProfileStore).getState(),
        AttachSubdeckModalStore: context.getStore(AttachSubdeckModalStore).getState()
    };
});

export default AttachSubdeckModal;
<|endoftext|>


<commit_before>import captions from './captions';

export default {
  namespaced: true,
  state: {
    player: null,
  },
  mutations: {
    SET_PLAYER(state, player) {
      state.player = player;
    },
  },
  getters: {},
  actions: {
    setPlayer(store, player) {
      store.dispatch('resetState');

      player.one('loadstart', () => {
        store.dispatch('captions/setTrackList', player.textTracks());

        const onTrackChange = () => {
          store.dispatch('captions/updateTrackList', player.textTracks());
        };
        player.on('texttrackchange', onTrackChange);
        player.on('dispose', () => player.off('texttrackchange', onTrackChange));
      });

      player.one('play', () => {
        store.dispatch('captions/initState');
      });

      store.commit('SET_PLAYER', player);
    },
    withPlayer(store, callback) {
      return callback(store.state.player);
    },
    resetState(store) {
      if (store.state.player) {
        store.state.player.dispose();
        store.commit('SET_PLAYER', null);
      }

      store.dispatch('captions/resetState');
    },
  },
  modules: {
    captions,
  },
};
<commit_msg>Change event to loadedmetadata<commit_after>import captions from './captions';

export default {
  namespaced: true,
  state: {
    player: null,
  },
  mutations: {
    SET_PLAYER(state, player) {
      state.player = player;
    },
  },
  getters: {},
  actions: {
    setPlayer(store, player) {
      store.dispatch('resetState');

      player.one('loadstart', () => {
        store.dispatch('captions/setTrackList', player.textTracks());

        const onTrackChange = () => {
          store.dispatch('captions/updateTrackList', player.textTracks());
        };
        player.on('texttrackchange', onTrackChange);
        player.on('dispose', () => player.off('texttrackchange', onTrackChange));
      });

      player.one('loadedmetadata', () => {
        store.dispatch('captions/initState');
      });

      store.commit('SET_PLAYER', player);
    },
    withPlayer(store, callback) {
      return callback(store.state.player);
    },
    resetState(store) {
      if (store.state.player) {
        store.state.player.dispose();
        store.commit('SET_PLAYER', null);
      }

      store.dispatch('captions/resetState');
    },
  },
  modules: {
    captions,
  },
};
<|endoftext|>


<commit_before>var
    esPhinx;

(function($, $module) {
    "use strict";

    var
        CSS_CLASS = "esphinx ui",
        CSS_CLASS_QUERY = "." + CSS_CLASS.replace(/ +/g, ".");

    $module.extend({
        panels: {autocomplete: {}}
    });

    $.Extender.extend($module.panels.autocomplete, true, {
        // new: function(searchTextBox, originalList, options = {}, callback) {
        new: function(searchTextBox, originalList, options, callback) {
            var
                ConstructorReference = $module.panels.autocomplete.new,
                self = this,
                nodeListFound,
                referenceElement,
                created = false,

                spanize = function(mapped) {
                    var
                        spanizedSliceFound;

                    Object.keys(mapped).forEach(function(i) {
                        spanizedSliceFound = $(mapped[i].span());
                        spanizedSliceFound.addClass(CSS_CLASS + " slice-found");

                        mapped[i] = spanizedSliceFound;
                    });

                    return mapped;
                },

                composeMatch = function(mapped, nodeText, nodeTextAsArr) {
                    var
                        leftUnitName,
                        rightUnitName,
                        searchIndex,
                        sliceFound,
                        span,
                        composedArr = [];

                    nodeTextAsArr.spaceOut().forEach(function(value, i) {
                        if (mapped.hasOwnProperty(i)) {
                            span = mapped[i];
                            sliceFound = span.text();
                            searchIndex = value.search(sliceFound);
                            leftUnitName = value.slice(0, searchIndex);
                            rightUnitName = value
                                .slice(searchIndex + sliceFound.length,
                                       value.length);

                            if (!leftUnitName.isEmpty()) {
                                composedArr.push(window.document
                                    .createTextNode(leftUnitName));
                            } else {
                                span.text(span.text());
                            }

                            composedArr.push(span.asNode());

                            if (!rightUnitName.isEmpty()) {
                                composedArr.push(window.document
                                    .createTextNode(rightUnitName));
                            }
                        } else {
                            composedArr.push(window.document
                                             .createTextNode(value));
                        }

                    });

                    return composedArr;
                },

                resolveResponse = function(found, maps) {
                    var
                        resolved = $(),
                        composed,
                        nodeText,
                        nodeTextAsArr,
                        mapped;

                    found.each(function(node, i) {
                        nodeText = $(node).text().trim();
                        nodeTextAsArr = nodeText.split(" ");
                        mapped = spanize(maps[i]);
                        composed = composeMatch(mapped, nodeText,
                                                nodeTextAsArr);
                        resolved.concat(true, composeName(composed, node));
                    });

                    return resolved;
                },

                composeName = function(composedArr, node) {
                    var
                        copy = $(node).clone();

                    composedArr.forEach(function(v) {
                        copy.append(v);
                    });

                    return copy;
                },

                create = function(referenceElement) {
                    var
                        nodeListFound = $("

")
                            .addClass(CSS_CLASS + " list-built-found"),
                        width,
                        borderBottom,
                        border,
                        marginBottom,

                        hitTarget = function(target) {
                            return target.is(nodeListFound.childElements()) ||
                                target.is(referenceElement);
                        };

                    if (referenceElement.isA(window.HTMLInputElement)) {

                        referenceElement.on("focus", function() {
                            if (nodeListFound.childElements().some()) {
                                nodeListFound.show();
                            }
                        });

                        referenceElement.on("blur", function(e) {
                            if (e.relatedTarget) {
                                if (!$(e.relatedTarget).is(nodeListFound)) {
                                    self.hide();
                                }
                            }

                         });

                        // clicking outside the panel
                        $(window.document).on("mouseup", function(e) {
                            var
                                target = $(e.target);

                            // debugger
                            if (!target.isA(window.HTMLInputElement) &&
                                !target.isA(window.HTMLLIElement)) {
                                target = target.parent("ol" + CSS_CLASS_QUERY +
                                            ".list-built-found li");
                            }

                            if (!hitTarget(target)) {
                                self.hide();
                            } else if (target
                                       .isA(window.HTMLLIElement)) {
                                if (target.hasClass("selected")) {
                                    target.removeClass("selected");
                                } else {
                                    target.addClass("selected");
                                }
                            }

                        });

                        marginBottom = referenceElement.css("margin-bottom");
                        width = referenceElement.width();
                        borderBottom = referenceElement.css("border-bottom");
                        border = referenceElement.css("border");

                        nodeListFound.css("margin-top", -marginBottom + "px");

                        // only after set width, otherwise doesn't can get your border
                        nodeListFound.insertAfter(referenceElement);
                        if (width) {
                            nodeListFound.css("position", "absolute");
                            // nodeListFound.width(width);
                            nodeListFound.css("min-width", width);
                        }

                        nodeListFound.show();
                    } else {
                        nodeListFound.insertAfter(referenceElement);
                    }

                    return nodeListFound;
                },

                show = function(autocompletedList) {
                    $(nodeListFound).clean();

                    if (searchTextBox.value()) {
                        if (originalList instanceof $) {
                            originalList.hide();
                        }

                        autocompletedList.each(function(li) {
                            nodeListFound.append(li);
                        });

                        if (nodeListFound.childElements().some()) {
                            nodeListFound.show();
                        } else {
                            nodeListFound.hide();
                        }
                    } else {
                        if (originalList instanceof $) {
                            originalList.show();
                        }
                        self.hide();
                    }

                    return nodeListFound.childElements();
                };

            if (!(this instanceof ConstructorReference)) {
                return new ConstructorReference(searchTextBox, originalList,
                                                options, callback);
            }

            if (Object.isFromClass(originalList, Object)) {
                referenceElement = searchTextBox;
                callback = options;
                options = originalList;
            } else {
                referenceElement = originalList;
            }

            searchTextBox.autocomplete(originalList, options,
                                       function(found, mapped) {
                var
                    resolvedResponse;

                if (!created) {
                    created = true;

                    nodeListFound = create(referenceElement);
                }

                if (typeof callback == "function") {
                    callback = function() {};
                }

                resolvedResponse = resolveResponse(found, mapped);
                callback.call(self, show(resolvedResponse));
            });

            this.hide = function() {
                nodeListFound.hide();
            };

        }
    });

})(esPhinx, esPhinx.ui);
<commit_msg>adequations<commit_after>var
    esPhinx;

(function($, $module) {
    "use strict";

    var
        CSS_CLASS = "esphinx ui",
        CSS_CLASS_QUERY = "." + CSS_CLASS.replace(/ +/g, ".");

    $module.extend({
        panels: {autocomplete: {}}
    });

    $.Extender.extend($module.panels.autocomplete, true, {
        // new: function(searchTextBox, originalList, options = {}, callback) {
        new: function(searchTextBox, originalList, options, callback) {
            var
                ConstructorReference = $module.panels.autocomplete.new,
                self = this,
                nodeListFound,
                referenceElement,
                created = false,

                spanize = function(mapped) {
                    var
                        spanizedSliceFound;

                    Object.keys(mapped).forEach(function(i) {
                        spanizedSliceFound = $(mapped[i].span());
                        spanizedSliceFound.addClass(CSS_CLASS + " slice-found");

                        mapped[i] = spanizedSliceFound;
                    });

                    return mapped;
                },

                composeMatch = function(mapped, nodeText, nodeTextAsArr) {
                    var
                        leftUnitName,
                        rightUnitName,
                        searchIndex,
                        sliceFound,
                        span,
                        composedArr = [];

                    nodeTextAsArr.spaceOut().forEach(function(value, i) {
                        if (mapped.hasOwnProperty(i)) {
                            span = mapped[i];
                            sliceFound = span.text();
                            searchIndex = value.search(sliceFound);
                            leftUnitName = value.slice(0, searchIndex);
                            rightUnitName = value
                                .slice(searchIndex + sliceFound.length,
                                       value.length);

                            if (!leftUnitName.isEmpty()) {
                                composedArr.push(window.document
                                    .createTextNode(leftUnitName));
                            } else {
                                span.text(span.text());
                            }

                            composedArr.push(span.asNode());

                            if (!rightUnitName.isEmpty()) {
                                composedArr.push(window.document
                                    .createTextNode(rightUnitName));
                            }
                        } else {
                            composedArr.push(window.document
                                             .createTextNode(value));
                        }

                    });

                    return composedArr;
                },

                resolveResponse = function(found, maps) {
                    var
                        resolved = $(),
                        composed,
                        nodeText,
                        nodeTextAsArr,
                        mapped;

                    found.each(function(node, i) {
                        nodeText = $(node).text().trim();
                        nodeTextAsArr = nodeText.split(" ");
                        mapped = spanize(maps[i]);
                        composed = composeMatch(mapped, nodeText,
                                                nodeTextAsArr);
                        resolved.concat(true, composeName(composed, node));
                    });

                    return resolved;
                },

                composeName = function(composedArr, node) {
                    var
                        copy = $(node).clone();

                    composedArr.forEach(function(v) {
                        copy.append(v);
                    });

                    return copy;
                },

                create = function(referenceElement) {
                    var
                        nodeListFound = $("

")
                            .addClass(CSS_CLASS + " list-built-found"),
                        width,
                        borderBottom,
                        border,
                        marginBottom,

                        hitTarget = function(target) {
                            return target.is(nodeListFound.childElements()) ||
                                target.is(referenceElement);
                        };

                    if (referenceElement.isA(window.HTMLInputElement)) {

                        referenceElement.on("focus", function() {
                            if (nodeListFound.childElements().some()) {
                                nodeListFound.show();
                            }
                        });

                        referenceElement.on("blur", function(e) {
                            if (e.relatedTarget) {
                                if (!$(e.relatedTarget).is(nodeListFound)) {
                                    self.hide();
                                }
                            }

                         });

                        // clicking outside the panel
                        $(window.document).on("mouseup", function(e) {
                            var
                                target = $(e.target);

                            // debugger
                            if (!target.isA(window.HTMLInputElement) &&
                                !target.isA(window.HTMLLIElement)) {
                                target = target.parent("ol" + CSS_CLASS_QUERY +
                                            ".list-built-found li");
                            }

                            if (!hitTarget(target)) {
                                self.hide();
                            } else if (target
                                       .isA(window.HTMLLIElement)) {
                                if (target.hasClass("selected")) {
                                    target.removeClass("selected");
                                } else {
                                    target.addClass("selected");
                                }
                            }

                        });

                        marginBottom = referenceElement.css("margin-bottom");
                        width = referenceElement.width();
                        borderBottom = referenceElement.css("border-bottom");
                        border = referenceElement.css("border");

                        nodeListFound.css("margin-top", -marginBottom + "px");

                        // only after set width, otherwise doesn't can get your border
                        nodeListFound.insertAfter(referenceElement);
                        if (width) {
                            nodeListFound.css("position", "absolute");
                            // nodeListFound.width(width);
                            nodeListFound.css("min-width", width);
                        }

                        nodeListFound.show();
                    } else {
                        nodeListFound.insertAfter(referenceElement);
                    }

                    return nodeListFound;
                },

                show = function(autocompletedList) {
                    $(nodeListFound).clean();

                    if (searchTextBox.value()) {
                        if (originalList instanceof $) {
                            originalList.hide();
                        }

                        autocompletedList.each(function(li) {
                            nodeListFound.append(li);
                        });

                        if (nodeListFound.childElements().some()) {
                            nodeListFound.show();
                        } else {
                            nodeListFound.hide();
                        }
                    } else {
                        if (originalList instanceof $) {
                            originalList.show();
                        }
                        self.hide();
                    }

                    return nodeListFound.childElements();
                };

            if (!(this instanceof ConstructorReference)) {
                return new ConstructorReference(searchTextBox, originalList,
                                                options, callback);
            }

            if (Object.areFromClass(originalList, Object)) {
                referenceElement = searchTextBox;
                callback = options;
                options = originalList;
            } else {
                referenceElement = originalList;
            }

            searchTextBox.autocomplete(originalList, options,
                                       function(found, mapped) {
                var
                    resolvedResponse;

                if (!created) {
                    created = true;

                    nodeListFound = create(referenceElement);
                }

                if (typeof callback == "function") {
                    callback = function() {};
                }

                resolvedResponse = resolveResponse(found, mapped);
                callback.call(self, show(resolvedResponse));
            });

            this.hide = function() {
                nodeListFound.hide();
            };

        }
    });

})(esPhinx, esPhinx.ui);
<|endoftext|>


<commit_before>/**
 * Copyright 2013 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @providesModule SimpleEventPlugin
 */

"use strict";

var EventConstants = require('EventConstants');
var EventPropagators = require('EventPropagators');
var SyntheticClipboardEvent = require('SyntheticClipboardEvent');
var SyntheticEvent = require('SyntheticEvent');
var SyntheticFocusEvent = require('SyntheticFocusEvent');
var SyntheticKeyboardEvent = require('SyntheticKeyboardEvent');
var SyntheticMouseEvent = require('SyntheticMouseEvent');
var SyntheticMutationEvent = require('SyntheticMutationEvent');
var SyntheticTouchEvent = require('SyntheticTouchEvent');
var SyntheticUIEvent = require('SyntheticUIEvent');
var SyntheticWheelEvent = require('SyntheticWheelEvent');

var invariant = require('invariant');
var keyOf = require('keyOf');

var topLevelTypes = EventConstants.topLevelTypes;

var eventTypes = {
  blur: {
    phasedRegistrationNames: {
      bubbled: keyOf({onBlur: true}),
      captured: keyOf({onBlurCapture: true})
    }
  },
  click: {
    phasedRegistrationNames: {
      bubbled: keyOf({onClick: true}),
      captured: keyOf({onClickCapture: true})
    }
  },
  copy: {
    phasedRegistrationNames: {
      bubbled: keyOf({onCopy: true}),
      captured: keyOf({onCopyCapture: true})
    }
  },
  cut: {
    phasedRegistrationNames: {
      bubbled: keyOf({onCut: true}),
      captured: keyOf({onCutCapture: true})
    }
  },
  doubleClick: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDoubleClick: true}),
      captured: keyOf({onDoubleClickCapture: true})
    }
  },
  drag: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDrag: true}),
      captured: keyOf({onDragCapture: true})
    }
  },
  dragEnd: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragEnd: true}),
      captured: keyOf({onDragEndCapture: true})
    }
  },
  dragEnter: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragEnter: true}),
      captured: keyOf({onDragEnterCapture: true})
    }
  },
  dragExit: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragExit: true}),
      captured: keyOf({onDragExitCapture: true})
    }
  },
  dragLeave: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragLeave: true}),
      captured: keyOf({onDragLeaveCapture: true})
    }
  },
  dragOver: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragOver: true}),
      captured: keyOf({onDragOverCapture: true})
    }
  },
  dragStart: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragStart: true}),
      captured: keyOf({onDragStartCapture: true})
    }
  },
  drop: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDrop: true}),
      captured: keyOf({onDropCapture: true})
    }
  },
  DOMCharacterDataModified: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDOMCharacterDataModified: true}),
      captured: keyOf({onDOMCharacterDataModifiedCapture: true})
    }
  },
  focus: {
    phasedRegistrationNames: {
      bubbled: keyOf({onFocus: true}),
      captured: keyOf({onFocusCapture: true})
    }
  },
  input: {
    phasedRegistrationNames: {
      bubbled: keyOf({onInput: true}),
      captured: keyOf({onInputCapture: true})
    }
  },
  keyDown: {
    phasedRegistrationNames: {
      bubbled: keyOf({onKeyDown: true}),
      captured: keyOf({onKeyDownCapture: true})
    }
  },
  keyPress: {
    phasedRegistrationNames: {
      bubbled: keyOf({onKeyPress: true}),
      captured: keyOf({onKeyPressCapture: true})
    }
  },
  keyUp: {
    phasedRegistrationNames: {
      bubbled: keyOf({onKeyUp: true}),
      captured: keyOf({onKeyUpCapture: true})
    }
  },
  // Note: We do not allow listening to mouseOver events. Instead, use the
  // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
  mouseDown: {
    phasedRegistrationNames: {
      bubbled: keyOf({onMouseDown: true}),
      captured: keyOf({onMouseDownCapture: true})
    }
  },
  mouseMove: {
    phasedRegistrationNames: {
      bubbled: keyOf({onMouseMove: true}),
      captured: keyOf({onMouseMoveCapture: true})
    }
  },
  mouseUp: {
    phasedRegistrationNames: {
      bubbled: keyOf({onMouseUp: true}),
      captured: keyOf({onMouseUpCapture: true})
    }
  },
  paste: {
    phasedRegistrationNames: {
      bubbled: keyOf({onPaste: true}),
      captured: keyOf({onPasteCapture: true})
    }
  },
  scroll: {
    phasedRegistrationNames: {
      bubbled: keyOf({onScroll: true}),
      captured: keyOf({onScrollCapture: true})
    }
  },
  submit: {
    phasedRegistrationNames: {
      bubbled: keyOf({onSubmit: true}),
      captured: keyOf({onSubmitCapture: true})
    }
  },
  touchCancel: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchCancel: true}),
      captured: keyOf({onTouchCancelCapture: true})
    }
  },
  touchEnd: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchEnd: true}),
      captured: keyOf({onTouchEndCapture: true})
    }
  },
  touchMove: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchMove: true}),
      captured: keyOf({onTouchMoveCapture: true})
    }
  },
  touchStart: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchStart: true}),
      captured: keyOf({onTouchStartCapture: true})
    }
  },
  wheel: {
    phasedRegistrationNames: {
      bubbled: keyOf({onWheel: true}),
      captured: keyOf({onWheelCapture: true})
    }
  }
};

var topLevelEventsToDispatchConfig = {
  topBlur:        eventTypes.blur,
  topClick:       eventTypes.click,
  topCopy:        eventTypes.copy,
  topCut:         eventTypes.cut,
  topDoubleClick: eventTypes.doubleClick,
  topDOMCharacterDataModified: eventTypes.DOMCharacterDataModified,
  topDrag:        eventTypes.drag,
  topDragEnd:     eventTypes.dragEnd,
  topDragEnter:   eventTypes.dragEnter,
  topDragExit:    eventTypes.dragExit,
  topDragLeave:   eventTypes.dragLeave,
  topDragOver:    eventTypes.dragOver,
  topDragStart:   eventTypes.dragStart,
  topDrop:        eventTypes.drop,
  topFocus:       eventTypes.focus,
  topInput:       eventTypes.input,
  topKeyDown:     eventTypes.keyDown,
  topKeyPress:    eventTypes.keyPress,
  topKeyUp:       eventTypes.keyUp,
  topMouseDown:   eventTypes.mouseDown,
  topMouseMove:   eventTypes.mouseMove,
  topMouseUp:     eventTypes.mouseUp,
  topPaste:       eventTypes.paste,
  topScroll:      eventTypes.scroll,
  topSubmit:      eventTypes.submit,
  topTouchCancel: eventTypes.touchCancel,
  topTouchEnd:    eventTypes.touchEnd,
  topTouchMove:   eventTypes.touchMove,
  topTouchStart:  eventTypes.touchStart,
  topWheel:       eventTypes.wheel
};

var SimpleEventPlugin = {

  eventTypes: eventTypes,

  /**
   * Same as the default implementation, except cancels the event when return
   * value is false.
   *
   * @param {object} Event to be dispatched.
   * @param {function} Application-level callback.
   * @param {string} domID DOM ID to pass to the callback.
   */
  executeDispatch: function(event, listener, domID) {
    var returnValue = listener(event, domID);
    if (returnValue === false) {
      event.stopPropagation();
      event.preventDefault();
    }
  },

  /**
   * @param {string} topLevelType Record from `EventConstants`.
   * @param {DOMEventTarget} topLevelTarget The listening component root node.
   * @param {string} topLevelTargetID ID of `topLevelTarget`.
   * @param {object} nativeEvent Native browser event.
   * @return {*} An accumulation of synthetic events.
   * @see {EventPluginHub.extractEvents}
   */
  extractEvents: function(
      topLevelType,
      topLevelTarget,
      topLevelTargetID,
      nativeEvent) {
    var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
    if (!dispatchConfig) {
      return null;
    }
    var EventConstructor;
    switch(topLevelType) {
      case topLevelTypes.topInput:
      case topLevelTypes.topSubmit:
        // HTML Events
        // @see http://www.w3.org/TR/html5/index.html#events-0
        EventConstructor = SyntheticEvent;
        break;
      case topLevelTypes.topKeyDown:
      case topLevelTypes.topKeyPress:
      case topLevelTypes.topKeyUp:
        EventConstructor = SyntheticKeyboardEvent;
        break;
      case topLevelTypes.topBlur:
      case topLevelTypes.topFocus:
        EventConstructor = SyntheticFocusEvent;
        break;
      case topLevelTypes.topClick:
      case topLevelTypes.topDoubleClick:
      case topLevelTypes.topDrag:
      case topLevelTypes.topDragEnd:
      case topLevelTypes.topDragEnter:
      case topLevelTypes.topDragExit:
      case topLevelTypes.topDragLeave:
      case topLevelTypes.topDragOver:
      case topLevelTypes.topDragStart:
      case topLevelTypes.topDrop:
      case topLevelTypes.topMouseDown:
      case topLevelTypes.topMouseMove:
      case topLevelTypes.topMouseUp:
        EventConstructor = SyntheticMouseEvent;
        break;
      case topLevelTypes.topDOMCharacterDataModified:
        EventConstructor = SyntheticMutationEvent;
        break;
      case topLevelTypes.topTouchCancel:
      case topLevelTypes.topTouchEnd:
      case topLevelTypes.topTouchMove:
      case topLevelTypes.topTouchStart:
        EventConstructor = SyntheticTouchEvent;
        break;
      case topLevelTypes.topScroll:
        EventConstructor = SyntheticUIEvent;
        break;
      case topLevelTypes.topWheel:
        EventConstructor = SyntheticWheelEvent;
        break;
      case topLevelTypes.topCopy:
      case topLevelTypes.topCut:
      case topLevelTypes.topPaste:
        EventConstructor = SyntheticClipboardEvent;
        break;
    }
    invariant(
      EventConstructor,
      'SimpleEventPlugin: Unhandled event type, `%s`.',
      topLevelType
    );
    var event = EventConstructor.getPooled(
      dispatchConfig,
      topLevelTargetID,
      nativeEvent
    );
    EventPropagators.accumulateTwoPhaseDispatches(event);
    return event;
  }

};

module.exports = SimpleEventPlugin;
<commit_msg>Better click behavior for ff<commit_after>/**
 * Copyright 2013 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @providesModule SimpleEventPlugin
 */

"use strict";

var EventConstants = require('EventConstants');
var EventPropagators = require('EventPropagators');
var SyntheticClipboardEvent = require('SyntheticClipboardEvent');
var SyntheticEvent = require('SyntheticEvent');
var SyntheticFocusEvent = require('SyntheticFocusEvent');
var SyntheticKeyboardEvent = require('SyntheticKeyboardEvent');
var SyntheticMouseEvent = require('SyntheticMouseEvent');
var SyntheticMutationEvent = require('SyntheticMutationEvent');
var SyntheticTouchEvent = require('SyntheticTouchEvent');
var SyntheticUIEvent = require('SyntheticUIEvent');
var SyntheticWheelEvent = require('SyntheticWheelEvent');

var invariant = require('invariant');
var keyOf = require('keyOf');

var topLevelTypes = EventConstants.topLevelTypes;

var eventTypes = {
  blur: {
    phasedRegistrationNames: {
      bubbled: keyOf({onBlur: true}),
      captured: keyOf({onBlurCapture: true})
    }
  },
  click: {
    phasedRegistrationNames: {
      bubbled: keyOf({onClick: true}),
      captured: keyOf({onClickCapture: true})
    }
  },
  copy: {
    phasedRegistrationNames: {
      bubbled: keyOf({onCopy: true}),
      captured: keyOf({onCopyCapture: true})
    }
  },
  cut: {
    phasedRegistrationNames: {
      bubbled: keyOf({onCut: true}),
      captured: keyOf({onCutCapture: true})
    }
  },
  doubleClick: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDoubleClick: true}),
      captured: keyOf({onDoubleClickCapture: true})
    }
  },
  drag: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDrag: true}),
      captured: keyOf({onDragCapture: true})
    }
  },
  dragEnd: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragEnd: true}),
      captured: keyOf({onDragEndCapture: true})
    }
  },
  dragEnter: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragEnter: true}),
      captured: keyOf({onDragEnterCapture: true})
    }
  },
  dragExit: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragExit: true}),
      captured: keyOf({onDragExitCapture: true})
    }
  },
  dragLeave: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragLeave: true}),
      captured: keyOf({onDragLeaveCapture: true})
    }
  },
  dragOver: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragOver: true}),
      captured: keyOf({onDragOverCapture: true})
    }
  },
  dragStart: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDragStart: true}),
      captured: keyOf({onDragStartCapture: true})
    }
  },
  drop: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDrop: true}),
      captured: keyOf({onDropCapture: true})
    }
  },
  DOMCharacterDataModified: {
    phasedRegistrationNames: {
      bubbled: keyOf({onDOMCharacterDataModified: true}),
      captured: keyOf({onDOMCharacterDataModifiedCapture: true})
    }
  },
  focus: {
    phasedRegistrationNames: {
      bubbled: keyOf({onFocus: true}),
      captured: keyOf({onFocusCapture: true})
    }
  },
  input: {
    phasedRegistrationNames: {
      bubbled: keyOf({onInput: true}),
      captured: keyOf({onInputCapture: true})
    }
  },
  keyDown: {
    phasedRegistrationNames: {
      bubbled: keyOf({onKeyDown: true}),
      captured: keyOf({onKeyDownCapture: true})
    }
  },
  keyPress: {
    phasedRegistrationNames: {
      bubbled: keyOf({onKeyPress: true}),
      captured: keyOf({onKeyPressCapture: true})
    }
  },
  keyUp: {
    phasedRegistrationNames: {
      bubbled: keyOf({onKeyUp: true}),
      captured: keyOf({onKeyUpCapture: true})
    }
  },
  // Note: We do not allow listening to mouseOver events. Instead, use the
  // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
  mouseDown: {
    phasedRegistrationNames: {
      bubbled: keyOf({onMouseDown: true}),
      captured: keyOf({onMouseDownCapture: true})
    }
  },
  mouseMove: {
    phasedRegistrationNames: {
      bubbled: keyOf({onMouseMove: true}),
      captured: keyOf({onMouseMoveCapture: true})
    }
  },
  mouseUp: {
    phasedRegistrationNames: {
      bubbled: keyOf({onMouseUp: true}),
      captured: keyOf({onMouseUpCapture: true})
    }
  },
  paste: {
    phasedRegistrationNames: {
      bubbled: keyOf({onPaste: true}),
      captured: keyOf({onPasteCapture: true})
    }
  },
  scroll: {
    phasedRegistrationNames: {
      bubbled: keyOf({onScroll: true}),
      captured: keyOf({onScrollCapture: true})
    }
  },
  submit: {
    phasedRegistrationNames: {
      bubbled: keyOf({onSubmit: true}),
      captured: keyOf({onSubmitCapture: true})
    }
  },
  touchCancel: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchCancel: true}),
      captured: keyOf({onTouchCancelCapture: true})
    }
  },
  touchEnd: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchEnd: true}),
      captured: keyOf({onTouchEndCapture: true})
    }
  },
  touchMove: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchMove: true}),
      captured: keyOf({onTouchMoveCapture: true})
    }
  },
  touchStart: {
    phasedRegistrationNames: {
      bubbled: keyOf({onTouchStart: true}),
      captured: keyOf({onTouchStartCapture: true})
    }
  },
  wheel: {
    phasedRegistrationNames: {
      bubbled: keyOf({onWheel: true}),
      captured: keyOf({onWheelCapture: true})
    }
  }
};

var topLevelEventsToDispatchConfig = {
  topBlur:        eventTypes.blur,
  topClick:       eventTypes.click,
  topCopy:        eventTypes.copy,
  topCut:         eventTypes.cut,
  topDoubleClick: eventTypes.doubleClick,
  topDOMCharacterDataModified: eventTypes.DOMCharacterDataModified,
  topDrag:        eventTypes.drag,
  topDragEnd:     eventTypes.dragEnd,
  topDragEnter:   eventTypes.dragEnter,
  topDragExit:    eventTypes.dragExit,
  topDragLeave:   eventTypes.dragLeave,
  topDragOver:    eventTypes.dragOver,
  topDragStart:   eventTypes.dragStart,
  topDrop:        eventTypes.drop,
  topFocus:       eventTypes.focus,
  topInput:       eventTypes.input,
  topKeyDown:     eventTypes.keyDown,
  topKeyPress:    eventTypes.keyPress,
  topKeyUp:       eventTypes.keyUp,
  topMouseDown:   eventTypes.mouseDown,
  topMouseMove:   eventTypes.mouseMove,
  topMouseUp:     eventTypes.mouseUp,
  topPaste:       eventTypes.paste,
  topScroll:      eventTypes.scroll,
  topSubmit:      eventTypes.submit,
  topTouchCancel: eventTypes.touchCancel,
  topTouchEnd:    eventTypes.touchEnd,
  topTouchMove:   eventTypes.touchMove,
  topTouchStart:  eventTypes.touchStart,
  topWheel:       eventTypes.wheel
};

var SimpleEventPlugin = {

  eventTypes: eventTypes,

  /**
   * Same as the default implementation, except cancels the event when return
   * value is false.
   *
   * @param {object} Event to be dispatched.
   * @param {function} Application-level callback.
   * @param {string} domID DOM ID to pass to the callback.
   */
  executeDispatch: function(event, listener, domID) {
    var returnValue = listener(event, domID);
    if (returnValue === false) {
      event.stopPropagation();
      event.preventDefault();
    }
  },

  /**
   * @param {string} topLevelType Record from `EventConstants`.
   * @param {DOMEventTarget} topLevelTarget The listening component root node.
   * @param {string} topLevelTargetID ID of `topLevelTarget`.
   * @param {object} nativeEvent Native browser event.
   * @return {*} An accumulation of synthetic events.
   * @see {EventPluginHub.extractEvents}
   */
  extractEvents: function(
      topLevelType,
      topLevelTarget,
      topLevelTargetID,
      nativeEvent) {
    var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
    if (!dispatchConfig) {
      return null;
    }
    var EventConstructor;
    switch(topLevelType) {
      case topLevelTypes.topInput:
      case topLevelTypes.topSubmit:
        // HTML Events
        // @see http://www.w3.org/TR/html5/index.html#events-0
        EventConstructor = SyntheticEvent;
        break;
      case topLevelTypes.topKeyDown:
      case topLevelTypes.topKeyPress:
      case topLevelTypes.topKeyUp:
        EventConstructor = SyntheticKeyboardEvent;
        break;
      case topLevelTypes.topBlur:
      case topLevelTypes.topFocus:
        EventConstructor = SyntheticFocusEvent;
        break;
      case topLevelTypes.topClick:
        // Firefox creates a click event on right mouse clicks. This removes the
        // unwanted click events.
        if (nativeEvent.button === 2) {
          return null;
        }
        /* falls through */
      case topLevelTypes.topDoubleClick:
      case topLevelTypes.topDrag:
      case topLevelTypes.topDragEnd:
      case topLevelTypes.topDragEnter:
      case topLevelTypes.topDragExit:
      case topLevelTypes.topDragLeave:
      case topLevelTypes.topDragOver:
      case topLevelTypes.topDragStart:
      case topLevelTypes.topDrop:
      case topLevelTypes.topMouseDown:
      case topLevelTypes.topMouseMove:
      case topLevelTypes.topMouseUp:
        EventConstructor = SyntheticMouseEvent;
        break;
      case topLevelTypes.topDOMCharacterDataModified:
        EventConstructor = SyntheticMutationEvent;
        break;
      case topLevelTypes.topTouchCancel:
      case topLevelTypes.topTouchEnd:
      case topLevelTypes.topTouchMove:
      case topLevelTypes.topTouchStart:
        EventConstructor = SyntheticTouchEvent;
        break;
      case topLevelTypes.topScroll:
        EventConstructor = SyntheticUIEvent;
        break;
      case topLevelTypes.topWheel:
        EventConstructor = SyntheticWheelEvent;
        break;
      case topLevelTypes.topCopy:
      case topLevelTypes.topCut:
      case topLevelTypes.topPaste:
        EventConstructor = SyntheticClipboardEvent;
        break;
    }
    invariant(
      EventConstructor,
      'SimpleEventPlugin: Unhandled event type, `%s`.',
      topLevelType
    );
    var event = EventConstructor.getPooled(
      dispatchConfig,
      topLevelTargetID,
      nativeEvent
    );
    EventPropagators.accumulateTwoPhaseDispatches(event);
    return event;
  }

};

module.exports = SimpleEventPlugin;
<|endoftext|>


<commit_before>import { Vector3 } from '../../math/Vector3.js';
import { Curve } from '../core/Curve.js';

/**
 * @author zz85 https://github.com/zz85
 *
 * Centripetal CatmullRom Curve - which is useful for avoiding
 * cusps and self-intersections in non-uniform catmull rom curves.
 * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf
 *
 * curve.type accepts centripetal(default), chordal and catmullrom
 * curve.tension is used for catmullrom which defaults to 0.5
 */

/*
Based on an optimized c++ solution in
 - http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/
 - http://ideone.com/NoEbVM

This CubicPoly class could be used for reusing some variables and calculations,
but for three.js curve use, it could be possible inlined and flatten into a single function call
which can be placed in CurveUtils.
*/

function CubicPoly() {

	var c0 = 0, c1 = 0, c2 = 0, c3 = 0;

	/*
	 * Compute coefficients for a cubic polynomial
	 *   p(s) = c0 + c1*s + c2*s^2 + c3*s^3
	 * such that
	 *   p(0) = x0, p(1) = x1
	 *  and
	 *   p'(0) = t0, p'(1) = t1.
	 */
	function init( x0, x1, t0, t1 ) {

		c0 = x0;
		c1 = t0;
		c2 = - 3 * x0 + 3 * x1 - 2 * t0 - t1;
		c3 = 2 * x0 - 2 * x1 + t0 + t1;

	}

	return {

		initCatmullRom: function ( x0, x1, x2, x3, tension ) {

			init( x1, x2, tension * ( x2 - x0 ), tension * ( x3 - x1 ) );

		},

		initNonuniformCatmullRom: function ( x0, x1, x2, x3, dt0, dt1, dt2 ) {

			// compute tangents when parameterized in [t1,t2]
			var t1 = ( x1 - x0 ) / dt0 - ( x2 - x0 ) / ( dt0 + dt1 ) + ( x2 - x1 ) / dt1;
			var t2 = ( x2 - x1 ) / dt1 - ( x3 - x1 ) / ( dt1 + dt2 ) + ( x3 - x2 ) / dt2;

			// rescale tangents for parametrization in [0,1]
			t1 *= dt1;
			t2 *= dt1;

			init( x1, x2, t1, t2 );

		},

		calc: function ( t ) {

			var t2 = t * t;
			var t3 = t2 * t;
			return c0 + c1 * t + c2 * t2 + c3 * t3;

		}

	};

}

//

var tmp = new Vector3();
var px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();

function CatmullRomCurve3( points, closed, curveType, tension ) {

	Curve.call( this );

	this.type = 'CatmullRomCurve3';

	this.points = points || [];
	this.closed = closed || false;
	this.curveType = curveType || 'centripetal';
	this.tension = tension || 0.5;

}

CatmullRomCurve3.prototype = Object.create( Curve.prototype );
CatmullRomCurve3.prototype.constructor = CatmullRomCurve3;

CatmullRomCurve3.prototype.isCatmullRomCurve3 = true;

CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {

	var point = optionalTarget || new Vector3();

	var points = this.points;
	var l = points.length;

	var p = ( l - ( this.closed ? 0 : 1 ) ) * t;
	var intPoint = Math.floor( p );
	var weight = p - intPoint;

	if ( this.closed ) {

		intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / points.length ) + 1 ) * points.length;

	} else if ( weight === 0 && intPoint === l - 1 ) {

		intPoint = l - 2;
		weight = 1;

	}

	var p0, p1, p2, p3; // 4 points

	if ( this.closed || intPoint > 0 ) {

		p0 = points[ ( intPoint - 1 ) % l ];

	} else {

		// extrapolate first point
		tmp.subVectors( points[ 0 ], points[ 1 ] ).add( points[ 0 ] );
		p0 = tmp;

	}

	p1 = points[ intPoint % l ];
	p2 = points[ ( intPoint + 1 ) % l ];

	if ( this.closed || intPoint + 2 < l ) {

		p3 = points[ ( intPoint + 2 ) % l ];

	} else {

		// extrapolate last point
		tmp.subVectors( points[ l - 1 ], points[ l - 2 ] ).add( points[ l - 1 ] );
		p3 = tmp;

	}

	if ( this.curveType === 'centripetal' || this.curveType === 'chordal' ) {

		// init Centripetal / Chordal Catmull-Rom
		var pow = this.curveType === 'chordal' ? 0.5 : 0.25;
		var dt0 = Math.pow( p0.distanceToSquared( p1 ), pow );
		var dt1 = Math.pow( p1.distanceToSquared( p2 ), pow );
		var dt2 = Math.pow( p2.distanceToSquared( p3 ), pow );

		// safety check for repeated points
		if ( dt1 < 1e-4 ) dt1 = 1.0;
		if ( dt0 < 1e-4 ) dt0 = dt1;
		if ( dt2 < 1e-4 ) dt2 = dt1;

		px.initNonuniformCatmullRom( p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2 );
		py.initNonuniformCatmullRom( p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2 );
		pz.initNonuniformCatmullRom( p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2 );

	} else if ( this.curveType === 'catmullrom' ) {

		px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, this.tension );
		py.initCatmullRom( p0.y, p1.y, p2.y, p3.y, this.tension );
		pz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, this.tension );

	}

	point.set(
		px.calc( weight ),
		py.calc( weight ),
		pz.calc( weight )
	);

	return point;

};

CatmullRomCurve3.prototype.copy = function ( source ) {

	Curve.prototype.copy.call( this, source );

	this.points = [];

	for ( var i = 0, l = source.points.length; i < l; i ++ ) {

		var point = source.points[ i ];

		this.points.push( point.clone() );

	}

	this.closed = source.closed;
	this.curveType = source.curveType;
	this.tension = source.tension;

	return this;

};

CatmullRomCurve3.prototype.toJSON = function () {

	var data = Curve.prototype.toJSON.call( this );

	data.points = [];

	for ( var i = 0, l = this.points.length; i < l; i ++ ) {

		var point = this.points[ i ];
		data.points.push( point.toArray() );

	}

	data.closed = this.closed;
	data.curveType = this.curveType;
	data.tension = this.tension;

	return data;

};

CatmullRomCurve3.prototype.fromJSON = function ( json ) {

	Curve.prototype.fromJSON.call( this, json );

	this.points = [];

	for ( var i = 0, l = json.points.length; i < l; i ++ ) {

		var point = json.points[ i ];
		this.points.push( new Vector3().fromArray( point ) );

	}

	this.closed = json.closed;
	this.curveType = json.curveType;
	this.tension = json.tension;

	return this;

};

export { CatmullRomCurve3 };
<commit_msg>replace .length with variable<commit_after>import { Vector3 } from '../../math/Vector3.js';
import { Curve } from '../core/Curve.js';

/**
 * @author zz85 https://github.com/zz85
 *
 * Centripetal CatmullRom Curve - which is useful for avoiding
 * cusps and self-intersections in non-uniform catmull rom curves.
 * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf
 *
 * curve.type accepts centripetal(default), chordal and catmullrom
 * curve.tension is used for catmullrom which defaults to 0.5
 */

/*
Based on an optimized c++ solution in
 - http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/
 - http://ideone.com/NoEbVM

This CubicPoly class could be used for reusing some variables and calculations,
but for three.js curve use, it could be possible inlined and flatten into a single function call
which can be placed in CurveUtils.
*/

function CubicPoly() {

	var c0 = 0, c1 = 0, c2 = 0, c3 = 0;

	/*
	 * Compute coefficients for a cubic polynomial
	 *   p(s) = c0 + c1*s + c2*s^2 + c3*s^3
	 * such that
	 *   p(0) = x0, p(1) = x1
	 *  and
	 *   p'(0) = t0, p'(1) = t1.
	 */
	function init( x0, x1, t0, t1 ) {

		c0 = x0;
		c1 = t0;
		c2 = - 3 * x0 + 3 * x1 - 2 * t0 - t1;
		c3 = 2 * x0 - 2 * x1 + t0 + t1;

	}

	return {

		initCatmullRom: function ( x0, x1, x2, x3, tension ) {

			init( x1, x2, tension * ( x2 - x0 ), tension * ( x3 - x1 ) );

		},

		initNonuniformCatmullRom: function ( x0, x1, x2, x3, dt0, dt1, dt2 ) {

			// compute tangents when parameterized in [t1,t2]
			var t1 = ( x1 - x0 ) / dt0 - ( x2 - x0 ) / ( dt0 + dt1 ) + ( x2 - x1 ) / dt1;
			var t2 = ( x2 - x1 ) / dt1 - ( x3 - x1 ) / ( dt1 + dt2 ) + ( x3 - x2 ) / dt2;

			// rescale tangents for parametrization in [0,1]
			t1 *= dt1;
			t2 *= dt1;

			init( x1, x2, t1, t2 );

		},

		calc: function ( t ) {

			var t2 = t * t;
			var t3 = t2 * t;
			return c0 + c1 * t + c2 * t2 + c3 * t3;

		}

	};

}

//

var tmp = new Vector3();
var px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();

function CatmullRomCurve3( points, closed, curveType, tension ) {

	Curve.call( this );

	this.type = 'CatmullRomCurve3';

	this.points = points || [];
	this.closed = closed || false;
	this.curveType = curveType || 'centripetal';
	this.tension = tension || 0.5;

}

CatmullRomCurve3.prototype = Object.create( Curve.prototype );
CatmullRomCurve3.prototype.constructor = CatmullRomCurve3;

CatmullRomCurve3.prototype.isCatmullRomCurve3 = true;

CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {

	var point = optionalTarget || new Vector3();

	var points = this.points;
	var l = points.length;

	var p = ( l - ( this.closed ? 0 : 1 ) ) * t;
	var intPoint = Math.floor( p );
	var weight = p - intPoint;

	if ( this.closed ) {

		intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / l ) + 1 ) * l;

	} else if ( weight === 0 && intPoint === l - 1 ) {

		intPoint = l - 2;
		weight = 1;

	}

	var p0, p1, p2, p3; // 4 points

	if ( this.closed || intPoint > 0 ) {

		p0 = points[ ( intPoint - 1 ) % l ];

	} else {

		// extrapolate first point
		tmp.subVectors( points[ 0 ], points[ 1 ] ).add( points[ 0 ] );
		p0 = tmp;

	}

	p1 = points[ intPoint % l ];
	p2 = points[ ( intPoint + 1 ) % l ];

	if ( this.closed || intPoint + 2 < l ) {

		p3 = points[ ( intPoint + 2 ) % l ];

	} else {

		// extrapolate last point
		tmp.subVectors( points[ l - 1 ], points[ l - 2 ] ).add( points[ l - 1 ] );
		p3 = tmp;

	}

	if ( this.curveType === 'centripetal' || this.curveType === 'chordal' ) {

		// init Centripetal / Chordal Catmull-Rom
		var pow = this.curveType === 'chordal' ? 0.5 : 0.25;
		var dt0 = Math.pow( p0.distanceToSquared( p1 ), pow );
		var dt1 = Math.pow( p1.distanceToSquared( p2 ), pow );
		var dt2 = Math.pow( p2.distanceToSquared( p3 ), pow );

		// safety check for repeated points
		if ( dt1 < 1e-4 ) dt1 = 1.0;
		if ( dt0 < 1e-4 ) dt0 = dt1;
		if ( dt2 < 1e-4 ) dt2 = dt1;

		px.initNonuniformCatmullRom( p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2 );
		py.initNonuniformCatmullRom( p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2 );
		pz.initNonuniformCatmullRom( p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2 );

	} else if ( this.curveType === 'catmullrom' ) {

		px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, this.tension );
		py.initCatmullRom( p0.y, p1.y, p2.y, p3.y, this.tension );
		pz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, this.tension );

	}

	point.set(
		px.calc( weight ),
		py.calc( weight ),
		pz.calc( weight )
	);

	return point;

};

CatmullRomCurve3.prototype.copy = function ( source ) {

	Curve.prototype.copy.call( this, source );

	this.points = [];

	for ( var i = 0, l = source.points.length; i < l; i ++ ) {

		var point = source.points[ i ];

		this.points.push( point.clone() );

	}

	this.closed = source.closed;
	this.curveType = source.curveType;
	this.tension = source.tension;

	return this;

};

CatmullRomCurve3.prototype.toJSON = function () {

	var data = Curve.prototype.toJSON.call( this );

	data.points = [];

	for ( var i = 0, l = this.points.length; i < l; i ++ ) {

		var point = this.points[ i ];
		data.points.push( point.toArray() );

	}

	data.closed = this.closed;
	data.curveType = this.curveType;
	data.tension = this.tension;

	return data;

};

CatmullRomCurve3.prototype.fromJSON = function ( json ) {

	Curve.prototype.fromJSON.call( this, json );

	this.points = [];

	for ( var i = 0, l = json.points.length; i < l; i ++ ) {

		var point = json.points[ i ];
		this.points.push( new Vector3().fromArray( point ) );

	}

	this.closed = json.closed;
	this.curveType = json.curveType;
	this.tension = json.tension;

	return this;

};

export { CatmullRomCurve3 };
<|endoftext|>


<commit_before>var request = require('request-promise');

module.exports = function (context, message) {

    // connect to facebook graph
    let myPath = '/' + message.facebook.id + '?fields=email,first_name,last_name,birthday,locale,location,picture.width(500),about,education,friends,hometown,photos,relationship_status,religion,political,tagged_places,work';

    let options = {
        uri: "https://graph.facebook.com" + myPath,
        method: 'GET',
        headers: {
            'Authorization': 'OAuth ' + message.facebook.token
        }
    };

    request(options)
        .then((response) => {
            context.bindings.out = response;
        })
        .catch((error) => context.log(error))
        .finally(() => context.done());
}<commit_msg>try fat!<commit_after>var request = require('request-promise');

module.exports = function (context, message) {

    // connect to facebook graph
    let myPath = '/' + message.facebook.id + '?fields=email,first_name,last_name,birthday,locale,location,picture.width(500),about,education,friends,hometown,photos,relationship_status,religion,political,tagged_places,work';

    let options = {
        uri: "https://graph.facebook.com" + myPath,
        method: 'GET',
        headers: {
            'Authorization': 'OAuth ' + message.facebook.token
        }
    };

    request(options)
        .then((response) => {
            let data = message;
            message.facebook.profile = response;
            context.bindings.out = data;
        })
        .catch((error) => context.log(error))
        .finally(() => context.done());
}<|endoftext|>


<commit_before>'use strict';

/**
* Allocate a buffer containing a provided string.
*
* @module @stdlib/buffer/from-string
*
* @example
* var string2buffer = require( '@stdlib/buffer/from-string' );
*
* var buf = string2buffer( 'beep boop' );
* // returns <Buffer>
*/

// MODULES //

var hasFrom = require( './has_from.js' );

// MAIN //

var string2buffer;
if ( hasFrom ) {
	string2buffer = require( './main.js' );
} else {
	string2buffer = require( './polyfill.js' );
}

// EXPORTS //

module.exports = string2buffer;
<commit_msg>Refactor to avoid dynamic module resolution<commit_after>'use strict';

/**
* Allocate a buffer containing a provided string.
*
* @module @stdlib/buffer/from-string
*
* @example
* var string2buffer = require( '@stdlib/buffer/from-string' );
*
* var buf = string2buffer( 'beep boop' );
* // returns <Buffer>
*/

// MODULES //

var hasFrom = require( './has_from.js' );
var main = require( './main.js' );
var polyfill = require( './polyfill.js' );

// MAIN //

var string2buffer;
if ( hasFrom ) {
	string2buffer = main;
} else {
	string2buffer = polyfill;
}

// EXPORTS //

module.exports = string2buffer;
<|endoftext|>


<commit_before>'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name bind2vind
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/bind2vind}
*/
setReadOnly( ns, 'bind2vind', require( '@stdlib/types/ndarray/base/bind2vind' ) );

/**
* @name ind2sub
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/ind2sub}
*/
setReadOnly( ns, 'ind2sub', require( '@stdlib/types/ndarray/base/ind2sub' ) );

/**
* @name numel
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/numel}
*/
setReadOnly( ns, 'numel', require( '@stdlib/types/ndarray/base/numel' ) );

/**
* @name shape2strides
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/shape2strides}
*/
setReadOnly( ns, 'shape2strides', require( '@stdlib/types/ndarray/base/shape2strides' ) );

/**
* @name strides2offset
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/strides2offset}
*/
setReadOnly( ns, 'strides2offset', require( '@stdlib/types/ndarray/base/strides2offset' ) );

// EXPORTS //

module.exports = ns;
<commit_msg>Update namespace<commit_after>'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name bind2vind
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/bind2vind}
*/
setReadOnly( ns, 'bind2vind', require( '@stdlib/types/ndarray/base/bind2vind' ) );

/**
* @name ind2sub
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/ind2sub}
*/
setReadOnly( ns, 'ind2sub', require( '@stdlib/types/ndarray/base/ind2sub' ) );

/**
* @name numel
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/numel}
*/
setReadOnly( ns, 'numel', require( '@stdlib/types/ndarray/base/numel' ) );

/**
* @name shape2strides
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/shape2strides}
*/
setReadOnly( ns, 'shape2strides', require( '@stdlib/types/ndarray/base/shape2strides' ) );

/**
* @name strides2offset
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/strides2offset}
*/
setReadOnly( ns, 'strides2offset', require( '@stdlib/types/ndarray/base/strides2offset' ) );

/**
* @name sub2ind
* @memberof ns
* @readonly
* @constructor
* @see {@link module:@stdlib/types/ndarray/base/sub2ind}
*/
setReadOnly( ns, 'sub2ind', require( '@stdlib/types/ndarray/base/sub2ind' ) );

// EXPORTS //

module.exports = ns;
<|endoftext|>


<commit_before>/* eslint-env browser */
import React, { Component } from 'react';
import QuestionDetail from '../parts/QuestionDetail';
import * as CommonQuestionParts from '../parts/CommonQuestionParts';
import * as Rows from './PersonalInfoQuestion/Rows';

/** 設問：個人情報 */
export default class PersonalInfoQuestion extends Component {
  generateRow(survey, question, item) {
    switch (item.getRowType()) {
      case 'AgeRow':
        return <Rows.AgeRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'BirthYearRow':
        return <Rows.BirthYearRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ContactEasyTimeRow':
        return <Rows.ContactEasyTimeRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ContactMeansRow':
        return <Rows.ContactMeansRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'EmailRow':
        return <Rows.EmailRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'FaxRow':
        return <Rows.FaxRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'FuriganaRow':
        return <Rows.FuriganaRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'HomeTelRow':
        return <Rows.HomeTelRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'HospitalNameRow':
        return <Rows.HospitalNameRow key={item.getId()} survey={survey} item={item} question={question} />;
      case 'InterviewPlaceRow':
        return <Rows.InterviewPlaceRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'InterviewMeansRow':
        return <Rows.InterviewMeansRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'InterviewRow':
        const homeTelInInterview = question.getItems().filter(i => i.isHomeTelRow()).get(0);
        const mobileTelInInterview = question.getItems().filter(i => i.isMobileTelRow()).get(0);
        const workTelInInterview = question.getItems().filter(i => i.isWorkTelRow()).get(0);
        return (<Rows.InterviewRow
          key={item.getId()}
          survey={survey}
          question={question}
          item={item}
          homeTel={homeTelInInterview}
          mobileTel={mobileTelInInterview}
          workTel={workTelInInterview}
        />);
      case 'MobileTelRow':
        return <Rows.MobileTelRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'HospitalPrefectureRow':
        return <Rows.HospitalPrefectureRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'NameRow':
        return <Rows.NameRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'PositionRow':
        return <Rows.PositionRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ProfessionalAreaRow':
        return <Rows.ProfessionalAreaRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'RequestEtcRow':
        return <Rows.RequestEtcRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ScheduleRow':
        const homeTelInSchedule = question.getItems().filter(i => i.isHomeTelRow()).get(0);
        const mobileTelInSchedule = question.getItems().filter(i => i.isMobileTelRow()).get(0);
        const workTelInSchedule = question.getItems().filter(i => i.isWorkTelRow()).get(0);
        const emailInSchedule = question.getItems().filter(i => i.isEmailRow()).get(0);
        return (<Rows.ScheduleRow
          key={item.getId()}
          survey={survey}
          question={question}
          item={item}
          homeTel={homeTelInSchedule}
          mobileTel={mobileTelInSchedule}
          workTel={workTelInSchedule}
          email={emailInSchedule}
        />);
      case 'SexRow':
        return <Rows.SexRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'SpecialityRow':
        return <Rows.SpecialityRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'WorkPostalCodeRow':
        return <Rows.WorkPostalCodeRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'WorkTelRow':
        return <Rows.WorkTelRow key={item.getId()} survey={survey} question={question} item={item} />;
      default:
        throw new Error(`NotImplementedError: ${item.getRowType()}`);
    }
  }

  render() {
    const { replacer, survey, question, options } = this.props;

    return (

        { CommonQuestionParts.title(question, replacer) }
        { CommonQuestionParts.description(question, replacer) }

              {question.getItems().map(item => this.generateRow(survey, question, item))}

        { options.isShowDetail() ? <QuestionDetail {...this.props} /> : null }

    );
  }
}
<commit_msg>Fix to add block for local variables in swich func<commit_after>/* eslint-env browser */
import React, { Component } from 'react';
import QuestionDetail from '../parts/QuestionDetail';
import * as CommonQuestionParts from '../parts/CommonQuestionParts';
import * as Rows from './PersonalInfoQuestion/Rows';

/** 設問：個人情報 */
export default class PersonalInfoQuestion extends Component {
  generateRow(survey, question, item) {
    switch (item.getRowType()) {
      case 'AgeRow':
        return <Rows.AgeRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'BirthYearRow':
        return <Rows.BirthYearRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ContactEasyTimeRow':
        return <Rows.ContactEasyTimeRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ContactMeansRow':
        return <Rows.ContactMeansRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'EmailRow':
        return <Rows.EmailRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'FaxRow':
        return <Rows.FaxRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'FuriganaRow':
        return <Rows.FuriganaRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'HomeTelRow':
        return <Rows.HomeTelRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'HospitalNameRow':
        return <Rows.HospitalNameRow key={item.getId()} survey={survey} item={item} question={question} />;
      case 'InterviewPlaceRow':
        return <Rows.InterviewPlaceRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'InterviewMeansRow':
        return <Rows.InterviewMeansRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'InterviewRow':
        {
          const homeTel = question.getItems().filter(i => i.isHomeTelRow()).get(0);
          const mobileTel = question.getItems().filter(i => i.isMobileTelRow()).get(0);
          const workTel = question.getItems().filter(i => i.isWorkTelRow()).get(0);
          return (<Rows.InterviewRow
            key={item.getId()}
            survey={survey}
            question={question}
            item={item}
            homeTel={homeTel}
            mobileTel={mobileTel}
            workTel={workTel}
          />);
        }
      case 'MobileTelRow':
        return <Rows.MobileTelRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'HospitalPrefectureRow':
        return <Rows.HospitalPrefectureRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'NameRow':
        return <Rows.NameRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'PositionRow':
        return <Rows.PositionRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ProfessionalAreaRow':
        return <Rows.ProfessionalAreaRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'RequestEtcRow':
        return <Rows.RequestEtcRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'ScheduleRow':
        {
          const homeTel = question.getItems().filter(i => i.isHomeTelRow()).get(0);
          const mobileTel = question.getItems().filter(i => i.isMobileTelRow()).get(0);
          const workTel = question.getItems().filter(i => i.isWorkTelRow()).get(0);
          const email = question.getItems().filter(i => i.isEmailRow()).get(0);
          return (<Rows.ScheduleRow
            key={item.getId()}
            survey={survey}
            question={question}
            item={item}
            homeTel={homeTel}
            mobileTel={mobileTel}
            workTel={workTel}
            email={email}
          />);
        }
      case 'SexRow':
        return <Rows.SexRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'SpecialityRow':
        return <Rows.SpecialityRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'WorkPostalCodeRow':
        return <Rows.WorkPostalCodeRow key={item.getId()} survey={survey} question={question} item={item} />;
      case 'WorkTelRow':
        return <Rows.WorkTelRow key={item.getId()} survey={survey} question={question} item={item} />;
      default:
        throw new Error(`NotImplementedError: ${item.getRowType()}`);
    }
  }

  render() {
    const { replacer, survey, question, options } = this.props;

    return (

        { CommonQuestionParts.title(question, replacer) }
        { CommonQuestionParts.description(question, replacer) }

              {question.getItems().map(item => this.generateRow(survey, question, item))}

        { options.isShowDetail() ? <QuestionDetail {...this.props} /> : null }

    );
  }
}
<|endoftext|>