<commit_before>                        $(document).ready(function() {
                            $('.poshytip').poshytip({
                                className: 'tip-twitter',
                                showTimeout: 1,
                                alignTo: 'target',
                                alignX: 'center',
                                alignY: 'bottom',
                                offsetY: 5,
                                allowTipHover: true,
                            });
                            //Responsive Menu
                            $("#responsive-menu select").change(function() {
                                window.location = jQuery(this).find("option:selected").val();
                            });
                            //Hook up the FlexSlider
                            $('.flexslider').flexslider({
                                animation: "fade", //String: Select your animation type, "fade" or "slide"
                                slideDirection: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical"
                                slideshow: true, //Boolean: Animate slider automatically
                                slideshowSpeed: 2000, //Integer: Set the speed of the slideshow cycling, in milliseconds
                                animationDuration: 3000, //Integer: Set the speed of animations, in milliseconds
                                directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false)
                                controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
                                keyboardNav: true, //Boolean: Allow slider navigating via keyboard left/right keys
                                mousewheel: false, //Boolean: Allow slider navigating via mousewheel
                                prevText: "Anterior", //String: Set the text for the "previous" directionNav item
                                nextText: "Siguiente", //String: Set the text for the "next" directionNav item
                                pausePlay: false, //Boolean: Create pause/play dynamic element
                                randomize: false, //Boolean: Randomize slide order
                                slideToStart: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide)
                                animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
                                pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
                                pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
                                start: function() {
                                }, //Callback: function(slider) - Fires when the slider loads the first slide
                                before: function() {
                                }, //Callback: function(slider) - Fires asynchronously with each slider animation
                                after: function() {
                                }, //Callback: function(slider) - Fires after each slider animation completes
                                end: function() {
                                }  //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
                            });
                            //Twitter
                            $(function() {
                                $('#tweets').tweetable({username: 'anariel77', time: true, limit: 1, replies: true, position: 'append'});
                            });
                            //Activate the contactform
                            $(function() {
                                $('#contact-form').submit(function(e) {
                                    e.preventDefault();
                                    var form = $(this);
                                    var post_url = form.attr('action');
                                    var post_data = form.serialize();
                                    $('#loader', form).html('<img src="images/loader.gif" /> Please Wait...');
                                    $.ajax({
                                        type: 'POST',
                                        url: post_url,
                                        data: post_data,
                                        success: function(msg) {
                                            $(form).fadeOut(500, function() {
                                                form.html(msg).fadeIn();
                                            });
                                        }
                                    });
                                });
                            });
                            //Activate the prettyPhoto
                            $("a[class^='prettyPhoto']").prettyPhoto();
                            //Activate the MainMenu
                            $("ul.sf-menu").superfish();
                            //Toggle box
                            $('.toggle-trigger').click(function() {
                                $(this).next().toggle('slow');
                                $(this).toggleClass("active");
                                return false;
                            }).next().hide();

                            $(function() {
                                $("form .send-button").live('click', function(e) {
                                    e.preventDefault();
                                    var nombre = $("input#nombre"),
                                        apellidos = $("input#apellidos"),
                                        email = $("input#email"),
                                        comentario = $("textarea#comentario"),
                                        telefono     = $("input#telefono"),
                                        dni = $("input#dni"),
                                        nameRegex = /^[a-zA-Záéíóú]+$/,
                                        emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/,
                                        phoneRegex   = /[0-9-()+]{3,20}/;

                                    if (nombre.val() == "") {
                                        inlineMsg('nombre','Debe ingresar su nombre.',3);
                                        nombre.focus();
                                        return false;
                                    } else if(!nombre.val().match(nameRegex)) {
                                        inlineMsg('nombre','Ha ingresado un nombre no válido.',3);
                                        nombre.focus();
                                        return false;
                                    } else if (apellidos.val() != '' && !apellidos.val().match(nameRegex)) {
                                        inlineMsg('apellidos','Ha ingresado un apellido no válido.',3);
                                        apellidos.focus();
                                        return false;
                                    } else if (email.val() == "") {
                                        inlineMsg('email','Debe ingresar su correo electrónico.',3);
                                        email.focus();
                                        return false;
                                    } else if (!email.val().match(emailRegex)) {
                                        inlineMsg('email','Ha ingresado un correo no válido.',3);
                                        email.focus();
                                        return false;
                                    } else if (telefono.val() != '' && !telefono.val().match(phoneRegex)) {
                                        inlineMsg('telefono','Ha ingresado un teléfono no válido.',3);
                                        telefono.focus();
                                        return false;
                                    } else if (dni.val() != '' && !dni.val().match(phoneRegex)) {
                                        inlineMsg('dni','Ha ingresado un DNI no válido.',3);
                                        dni.focus();
                                        return false;
                                    } else if (comentario.val() == "") {
                                        inlineMsg('comentario','Debe ingresar un comentario.',3);
                                        comentario.focus();
                                        return false;
                                    }
                                    $form = $('form#contact-form');
                                    $.ajax({
                                        type: "POST",
                                        url: $form.attr("action"),
                                        data: $form.serialize(),
                                        dataType: "json"
                                    }).done(function(data){
                                        var response = data.responseCode == 200 ? 'success' : 'fail';
                                        $("#" + response).append($("<span />").text(data.response)).slideDown(500, function(){
                                            setTimeout(function(){
                                                $("#" + response).slideUp(1000, function() {
                                                    $("#" + response + ' span').remove();
                                                });
                                            }, 1500);
                                        });
                                        if (response == 'success') {
                                            $form.each (function(){
                                                this.reset();
                                            });
                                        }
                                    }).fail(function(data){
                                        $("#fail").append($("<span />").text(data.statusText)).slideDown(500, function(){
                                            setTimeout(function(){
                                                $("#fail").slideUp(1000, function() {
                                                    $("#fail" + ' span').remove();
                                                });
                                            }, 1500);
                                        });
                                    });
                                });
                            });

                            var MSGTIMER = 20,
                                MSGSPEED = 5,
                                MSGOFFSET = 3,
                                MSGHIDE = 3;

                            // face the message box //
                            function fadeMsg(flag) {
                                if(flag == null) {
                                    flag = 1;
                                }
                                var msg = document.getElementById('msg');
                                var value;
                                if(flag == 1) {
                                    value = msg.alpha + MSGSPEED;
                                } else {
                                    value = msg.alpha - MSGSPEED;
                                }
                                msg.alpha = value;
                                msg.style.opacity = (value / 100);
                                msg.style.filter = 'alpha(opacity=' + value + ')';
                                if(value >= 99) {
                                    clearInterval(msg.timer);
                                    msg.timer = null;
                                } else if(value <= 1) {
                                    msg.style.display = "none";
                                    clearInterval(msg.timer);
                                }
                            }
                            // build out the divs, set attributes and call the fade function //
                            function inlineMsg(target,string,autohide) {
                                var msg;
                                var msgcontent;
                                if(!document.getElementById('msg')) {
                                    msg = document.createElement('div');
                                    msg.id = 'msg';
                                    msgcontent = document.createElement('div');
                                    msgcontent.id = 'msgcontent';
                                    document.body.appendChild(msg);
                                    msg.appendChild(msgcontent);
                                    msg.style.filter = 'alpha(opacity=0)';
                                    msg.style.opacity = 0;
                                    msg.alpha = 0;
                                } else {
                                    msg = document.getElementById('msg');
                                    msgcontent = document.getElementById('msgcontent');
                                }
                                msgcontent.innerHTML = string;
                                msg.style.display = 'block';
                                var msgheight = msg.offsetHeight;
                                var targetdiv = document.getElementById(target);
                                targetdiv.focus();
                                var targetheight = targetdiv.offsetHeight;
                                var targetwidth = targetdiv.offsetWidth;
                                var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
                                var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
                                msg.style.top = topposition + 'px';
                                msg.style.left = leftposition + 'px';
                                clearInterval(msg.timer);
                                msg.timer = setInterval(function(){fadeMsg(1)}, MSGTIMER);
                                if(!autohide) {
                                    autohide = MSGHIDE;
                                }
                                window.setTimeout(function(){hideMsg()}, (autohide * 1000));
                            }

                            // hide the form alert //
                            function hideMsg(msg) {
                                var msg = document.getElementById('msg');
                                if(!msg.timer) {
                                    msg.timer = setInterval(function(){fadeMsg(0)}, MSGTIMER);
                                }
                            }

                            // calculate the position of the element in relation to the left of the browser //
                            function leftPosition(target) {
                                var left = 0;
                                if(target.offsetParent) {
                                    while(1) {
                                        left += target.offsetLeft;
                                        if(!target.offsetParent) {
                                              break;
                                        }
                                        target = target.offsetParent;
                                    }
                                } else if(target.x) {
                                    left += target.x;
                                }
                                return left;
                            }

                            // calculate the position of the element in relation to the top of the browser window //
                            function topPosition(target) {
                                var top = 0;
                                if(target.offsetParent) {
                                    while(1) {
                                        top += target.offsetTop;
                                        if(!target.offsetParent) {
                                            break;
                                        }
                                        target = target.offsetParent;
                                    }
                                } else if(target.y) {
                                    top += target.y;
                                }
                                return top;
                            }

                            // preload the arrow //
                            if(document.images) {
                                arrow = new Image(7,80);
                                arrow.src = "../images/msg_arrow.gif";
                            }
                            var time = 4000;
                            var slides = $('.slide');
                            var numberSlides = slides.length;
                            var slideWidth = $('.slide').width();
                            var wrap = $('.info');
                            var sum = parseInt(slideWidth) + parseInt(38);

                            wrap.width(parseInt(numberSlides * slideWidth) + (38 * numberSlides));

                            function moveMent() {
                                for (var r = 0; r < 100; r++) {
                                    for (var i = 0; i < numberSlides - 3; i++) {
                                        wrap
                                            .delay(time)
                                            .animate({
                                            left: '-=' + sum + 'px'
                                            })
                                            .fadeTo(500, 1)
                                    }
                                    wrap.animate({
                                        left: '0'
                                    }, 0);
                                }
                            };
                            moveMent();

                            var timea = 2000;
                            var slidesa = $('.slidea');
                            var numberSlidesa = slidesa.length;
                            var slideWidtha = $('.slidea').width();
                            var wrapa = $('.clients');
                            var suma = parseInt(slideWidtha) + parseInt(34);

                            wrapa.width(parseInt(numberSlidesa * slideWidtha) + (34 * numberSlidesa));

                            function moveMentAreas() {
                                for (var r = 0; r < 100; r++) {
                                    for (var i = 0; i < numberSlidesa - 4; i++) {
                                        wrapa
                                            .delay(timea)
                                            .animate({
                                            left: '-=' + suma + 'px'
                                            })
                                            .fadeTo(500, 1)
                                    }
                                    wrapa.animate({
                                        left: '0'
                                    }, 0);
                                }
                            };
                            moveMentAreas();

                            $(function() {
                                $( "#abogados" ).tabs();
                            });
                            $("#slideToggle").click(function () {
                                $('.slideTogglebox').slideToggle(500);
                                $("html, body").animate({ scrollTop: $(document).height() }, 500);
                            });
                        });<commit_msg>padding added<commit_after>                        $(document).ready(function() {
                            $('.poshytip').poshytip({
                                className: 'tip-twitter',
                                showTimeout: 1,
                                alignTo: 'target',
                                alignX: 'center',
                                alignY: 'bottom',
                                offsetY: 5,
                                allowTipHover: true,
                            });
                            //Responsive Menu
                            $("#responsive-menu select").change(function() {
                                window.location = jQuery(this).find("option:selected").val();
                            });
                            //Hook up the FlexSlider
                            $('.flexslider').flexslider({
                                animation: "fade", //String: Select your animation type, "fade" or "slide"
                                slideDirection: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical"
                                slideshow: true, //Boolean: Animate slider automatically
                                slideshowSpeed: 2000, //Integer: Set the speed of the slideshow cycling, in milliseconds
                                animationDuration: 3000, //Integer: Set the speed of animations, in milliseconds
                                directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false)
                                controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
                                keyboardNav: true, //Boolean: Allow slider navigating via keyboard left/right keys
                                mousewheel: false, //Boolean: Allow slider navigating via mousewheel
                                prevText: "Anterior", //String: Set the text for the "previous" directionNav item
                                nextText: "Siguiente", //String: Set the text for the "next" directionNav item
                                pausePlay: false, //Boolean: Create pause/play dynamic element
                                randomize: false, //Boolean: Randomize slide order
                                slideToStart: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide)
                                animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
                                pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
                                pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
                                start: function() {
                                }, //Callback: function(slider) - Fires when the slider loads the first slide
                                before: function() {
                                }, //Callback: function(slider) - Fires asynchronously with each slider animation
                                after: function() {
                                }, //Callback: function(slider) - Fires after each slider animation completes
                                end: function() {
                                }  //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
                            });
                            //Twitter
                            $(function() {
                                $('#tweets').tweetable({username: 'anariel77', time: true, limit: 1, replies: true, position: 'append'});
                            });
                            //Activate the contactform
                            $(function() {
                                $('#contact-form').submit(function(e) {
                                    e.preventDefault();
                                    var form = $(this);
                                    var post_url = form.attr('action');
                                    var post_data = form.serialize();
                                    $('#loader', form).html('<img src="images/loader.gif" /> Please Wait...');
                                    $.ajax({
                                        type: 'POST',
                                        url: post_url,
                                        data: post_data,
                                        success: function(msg) {
                                            $(form).fadeOut(500, function() {
                                                form.html(msg).fadeIn();
                                            });
                                        }
                                    });
                                });
                            });
                            //Activate the prettyPhoto
                            $("a[class^='prettyPhoto']").prettyPhoto();
                            //Activate the MainMenu
                            $("ul.sf-menu").superfish();
                            //Toggle box
                            $('.toggle-trigger').click(function() {
                                $(this).next().toggle('slow');
                                $(this).toggleClass("active");
                                return false;
                            }).next().hide();

                            $(function() {
                                $("form .send-button").live('click', function(e) {
                                    e.preventDefault();
                                    var nombre = $("input#nombre"),
                                        apellidos = $("input#apellidos"),
                                        email = $("input#email"),
                                        comentario = $("textarea#comentario"),
                                        telefono     = $("input#telefono"),
                                        dni = $("input#dni"),
                                        nameRegex = /^[a-zA-Záéíóú]+$/,
                                        emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/,
                                        phoneRegex   = /[0-9-()+]{3,20}/;

                                    if (nombre.val() == "") {
                                        inlineMsg('nombre','Debe ingresar su nombre.',3);
                                        nombre.focus();
                                        return false;
                                    } else if(!nombre.val().match(nameRegex)) {
                                        inlineMsg('nombre','Ha ingresado un nombre no válido.',3);
                                        nombre.focus();
                                        return false;
                                    } else if (apellidos.val() != '' && !apellidos.val().match(nameRegex)) {
                                        inlineMsg('apellidos','Ha ingresado un apellido no válido.',3);
                                        apellidos.focus();
                                        return false;
                                    } else if (email.val() == "") {
                                        inlineMsg('email','Debe ingresar su correo electrónico.',3);
                                        email.focus();
                                        return false;
                                    } else if (!email.val().match(emailRegex)) {
                                        inlineMsg('email','Ha ingresado un correo no válido.',3);
                                        email.focus();
                                        return false;
                                    } else if (telefono.val() != '' && !telefono.val().match(phoneRegex)) {
                                        inlineMsg('telefono','Ha ingresado un teléfono no válido.',3);
                                        telefono.focus();
                                        return false;
                                    } else if (dni.val() != '' && !dni.val().match(phoneRegex)) {
                                        inlineMsg('dni','Ha ingresado un DNI no válido.',3);
                                        dni.focus();
                                        return false;
                                    } else if (comentario.val() == "") {
                                        inlineMsg('comentario','Debe ingresar un comentario.',3);
                                        comentario.focus();
                                        return false;
                                    }
                                    $form = $('form#contact-form');
                                    $.ajax({
                                        type: "POST",
                                        url: $form.attr("action"),
                                        data: $form.serialize(),
                                        dataType: "json"
                                    }).done(function(data){
                                        var response = data.responseCode == 200 ? 'success' : 'fail';
                                        $("#" + response).append($("<span />").text(data.response)).slideDown(500, function(){
                                            setTimeout(function(){
                                                $("#" + response).slideUp(1000, function() {
                                                    $("#" + response + ' span').remove();
                                                });
                                            }, 1500);
                                        });
                                        if (response == 'success') {
                                            $form.each (function(){
                                                this.reset();
                                            });
                                        }
                                    }).fail(function(data){
                                        $("#fail").append($("<span />").text(data.statusText)).slideDown(500, function(){
                                            setTimeout(function(){
                                                $("#fail").slideUp(1000, function() {
                                                    $("#fail" + ' span').remove();
                                                });
                                            }, 1500);
                                        });
                                    });
                                });
                            });

                            var MSGTIMER = 20,
                                MSGSPEED = 5,
                                MSGOFFSET = 3,
                                MSGHIDE = 3;

                            // face the message box //
                            function fadeMsg(flag) {
                                if(flag == null) {
                                    flag = 1;
                                }
                                var msg = document.getElementById('msg');
                                var value;
                                if(flag == 1) {
                                    value = msg.alpha + MSGSPEED;
                                } else {
                                    value = msg.alpha - MSGSPEED;
                                }
                                msg.alpha = value;
                                msg.style.opacity = (value / 100);
                                msg.style.filter = 'alpha(opacity=' + value + ')';
                                if(value >= 99) {
                                    clearInterval(msg.timer);
                                    msg.timer = null;
                                } else if(value <= 1) {
                                    msg.style.display = "none";
                                    clearInterval(msg.timer);
                                }
                            }
                            // build out the divs, set attributes and call the fade function //
                            function inlineMsg(target,string,autohide) {
                                var msg;
                                var msgcontent;
                                if(!document.getElementById('msg')) {
                                    msg = document.createElement('div');
                                    msg.id = 'msg';
                                    msgcontent = document.createElement('div');
                                    msgcontent.id = 'msgcontent';
                                    document.body.appendChild(msg);
                                    msg.appendChild(msgcontent);
                                    msg.style.filter = 'alpha(opacity=0)';
                                    msg.style.opacity = 0;
                                    msg.alpha = 0;
                                } else {
                                    msg = document.getElementById('msg');
                                    msgcontent = document.getElementById('msgcontent');
                                }
                                msgcontent.innerHTML = string;
                                msg.style.display = 'block';
                                var msgheight = msg.offsetHeight;
                                var targetdiv = document.getElementById(target);
                                targetdiv.focus();
                                var targetheight = targetdiv.offsetHeight;
                                var targetwidth = targetdiv.offsetWidth;
                                var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
                                var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
                                msg.style.top = topposition + 'px';
                                msg.style.left = leftposition + 'px';
                                clearInterval(msg.timer);
                                msg.timer = setInterval(function(){fadeMsg(1)}, MSGTIMER);
                                if(!autohide) {
                                    autohide = MSGHIDE;
                                }
                                window.setTimeout(function(){hideMsg()}, (autohide * 1000));
                            }

                            // hide the form alert //
                            function hideMsg(msg) {
                                var msg = document.getElementById('msg');
                                if(!msg.timer) {
                                    msg.timer = setInterval(function(){fadeMsg(0)}, MSGTIMER);
                                }
                            }

                            // calculate the position of the element in relation to the left of the browser //
                            function leftPosition(target) {
                                var left = 0;
                                if(target.offsetParent) {
                                    while(1) {
                                        left += target.offsetLeft;
                                        if(!target.offsetParent) {
                                              break;
                                        }
                                        target = target.offsetParent;
                                    }
                                } else if(target.x) {
                                    left += target.x;
                                }
                                return left;
                            }

                            // calculate the position of the element in relation to the top of the browser window //
                            function topPosition(target) {
                                var top = 0;
                                if(target.offsetParent) {
                                    while(1) {
                                        top += target.offsetTop;
                                        if(!target.offsetParent) {
                                            break;
                                        }
                                        target = target.offsetParent;
                                    }
                                } else if(target.y) {
                                    top += target.y;
                                }
                                return top;
                            }

                            // preload the arrow //
                            if(document.images) {
                                arrow = new Image(7,80);
                                arrow.src = "../images/msg_arrow.gif";
                            }
                            var time = 4000;
                            var slides = $('.slide');
                            var numberSlides = slides.length;
                            var slideWidth = $('.slide').width();
                            var wrap = $('.info');
                            var padding = 19;
                            var visibleSlides = 3;
                            var sum = parseInt(slideWidth) + parseInt(padding * 2);

                            wrap.width(parseInt(numberSlides * slideWidth) + (padding * 2 * numberSlides));

                            function moveMent() {
                                for (var r = 0; r < 100; r++) {
                                    for (var i = 0; i < numberSlides - visibleSlides; i++) {
                                        wrap
                                            .delay(time)
                                            .animate({
                                            left: '-=' + sum + 'px'
                                            })
                                            .fadeTo(500, 1)
                                    }
                                    wrap.animate({
                                        left: '0'
                                    }, 0);
                                }
                            };
                            moveMent();

                            var timea = 2000;
                            var slidesa = $('.slidea');
                            var numberSlidesa = slidesa.length;
                            var slideWidtha = $('.slidea').width();
                            var wrapa = $('.clients');
                            var padding = 17;
                            var visibleSlides = 4;
                            var suma = parseInt(slideWidtha) + parseInt(padding * 2);

                            wrapa.width(parseInt(numberSlidesa * slideWidtha) + (padding * 2 * numberSlidesa));

                            function moveMentAreas() {
                                for (var r = 0; r < 100; r++) {
                                    for (var i = 0; i < numberSlidesa - visibleSlides; i++) {
                                        wrapa
                                            .delay(timea)
                                            .animate({
                                            left: '-=' + suma + 'px'
                                            })
                                            .fadeTo(500, 1)
                                    }
                                    wrapa.animate({
                                        left: '0'
                                    }, 0);
                                }
                            };
                            moveMentAreas();

                            $(function() {
                                $( "#abogados" ).tabs();
                            });
                            $("#slideToggle").click(function () {
                                $('.slideTogglebox').slideToggle(500);
                                $("html, body").animate({ scrollTop: $(document).height() }, 500);
                            });
                        });<|endoftext|>


<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import configureStore from './store/configureStore';
import routes from './routes';

const store = configureStore({}, browserHistory);

ReactDOM.render(
  <Provider store={store}>
    <Router history={browserHistory} routes={routes}>
    </Router>
  </Provider>,
  document.getElementById('root')
);
<commit_msg>revert history to hashHistory<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, useRouterHistory } from 'react-router';
import { createHashHistory } from 'history';
import configureStore from './store/configureStore';
import routes from './routes';

const history = useRouterHistory(createHashHistory)({ queryKey: false });
const store = configureStore({}, history);

ReactDOM.render(
  <Provider store={store}>
    <Router history={history} routes={routes} />
  </Provider>,
  document.getElementById('root')
);
<|endoftext|>


<commit_before>/* eslint-disable no-var */
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");

var config = {
  devtool:  'hidden-source-map',
  entry: {
    app: path.resolve(__dirname, '..', 'src', 'index.js'),
  },
  output: {
    publicPath: '/build',
    path: path.resolve(__dirname, '../build'),
    filename: '[name].js',
  },
  resolve: {
    alias: {
      app: path.resolve(__dirname, '..', 'app'),
      src: path.resolve(__dirname, '..', 'src'),
      shared: path.resolve(__dirname, '..', 'src', 'shared'),
      style: path.resolve(__dirname, '..', 'src', 'style'),
      utils: path.resolve(__dirname, '..', 'src', 'utils'),
    },
  },
  module: {
    preLoaders: [
      {
        test: /\.js$/,
        exclude: [/node_modules/, /(_s|S)pec\.js$/],
        loader: 'eslint-loader',
      },
    ],
    loaders: [
      {
        test: /\.json$/,
        loader: 'json',
      },
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader'),
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader'),
      },
      {
        test   : /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
        loader : 'file-loader',
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react'],
          cacheDirectory: false, // Using the cache directory on production builds has never been helpful.
        },
      },
    ],
  },
  eslint: {
    failOnWarning: false,
    failOnError: false,
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production'),
      },
    }),
    new ExtractTextPlugin("style.css"),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, '..', 'src', 'index.template.html'),
      inject: 'body',
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    }),
  ],
  postcss: require('./postcss'),
  target: 'web',
};

module.exports = config;
<commit_msg>Fix prod webpack to look to / instead of /build<commit_after>/* eslint-disable no-var */
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");

var config = {
  devtool:  'hidden-source-map',
  entry: {
    app: path.resolve(__dirname, '..', 'src', 'index.js'),
  },
  output: {
    publicPath: '/',
    path: path.resolve(__dirname, '../build'),
    filename: '[name].js',
  },
  resolve: {
    alias: {
      app: path.resolve(__dirname, '..', 'app'),
      src: path.resolve(__dirname, '..', 'src'),
      shared: path.resolve(__dirname, '..', 'src', 'shared'),
      style: path.resolve(__dirname, '..', 'src', 'style'),
      utils: path.resolve(__dirname, '..', 'src', 'utils'),
    },
  },
  module: {
    preLoaders: [
      {
        test: /\.js$/,
        exclude: [/node_modules/, /(_s|S)pec\.js$/],
        loader: 'eslint-loader',
      },
    ],
    loaders: [
      {
        test: /\.json$/,
        loader: 'json',
      },
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader'),
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader'),
      },
      {
        test   : /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
        loader : 'file-loader',
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react'],
          cacheDirectory: false, // Using the cache directory on production builds has never been helpful.
        },
      },
    ],
  },
  eslint: {
    failOnWarning: false,
    failOnError: false,
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production'),
      },
    }),
    new ExtractTextPlugin("style.css"),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, '..', 'src', 'index.template.html'),
      inject: 'body',
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    }),
  ],
  postcss: require('./postcss'),
  target: 'web',
};

module.exports = config;
<|endoftext|>


<commit_before>
// PKUI 核心模块
define( function ( require ) {
    "use strict";

    require( "isLoading" );

    require( "css/font/font-awesome/4.7.0/font-awesome.css" );

    require( "layer" );
    require( "lib/component/layer/3.0.1.x/skin/default/layer.css" );

    require( "moment-local-zh" );

    require( "bootstrap-tooltip" );

    var
        $ = require( "jquery" ),

        AOP = require( "meld" ),

        moment = require( "moment" ),

        ArtTemplate = require( "artTemplate" ),

        DataSource = require( "dataSource" ),

        ns = window[ "www.pkusoft.net" ],

        $doc = $( window.document ),

        PKUI = {
            // 标识组件类型的HTML属性：

            componentHtmlAttr: "pkui-component",

            // 标识组件参数的HTML属性：

            componentOptionsHtmlAttr: "pkui-component-options",

            // CTX路径：${ ctx }（http://localhost:8080/projname）
            ctxPath: ns.ctxPath,

            // pkui的基本路径：${ ctx }/static/pkui
            basePath: ns.pkuiBasePath,

            // 字典路径：${ ctx }/static/dic/
            dicPath: ns.ctxPath + "/static/dic/",

            // 时间戳（版本控制）v=2012-1-1
            timestamp: ns.timestamp,

            // 组件容器
            component: {},

            // 自动渲染标志
            isAutoRender: true,

            // 是否正在渲染
            __isrendering: false,
            // 渲染次数（render()被调用的次数）
            __renderedTimes: 0

        }
        ;

    // 如果是在WebStorm里跑 PKUI项目，则更改 ctxPath 和 dicPath
    if ( location.href.indexOf( "localhost" ) !== -1 && ns.pkuiBasePath.indexOf( "static" ) === -1 ) {
        PKUI.ctxPath = "http://localhost:8080/pkui";
        PKUI.dicPath = "http://localhost:8080/pkui/static/dic/";
    }

    /**
     * 控制台打印
     * @type {{info: info, warn: warn, error: error}}
     */
    PKUI.console = {
        info: function ( message, isShow ) {
            console.info( message );
            if ( isShow ) {
                window.layer.msg( message );
            }
        },
        warn: function ( message, isShow ) {
            console.warn( message );
            if ( isShow ) {
                window.layer.msg( message );
            }
        },
        error: function ( message, isShow ) {
            console.error( message );
            if ( isShow ) {
                window.layer.msg( message );
            }
        }
    };

    /**
     * 初始化
     */
    $.extend( PKUI, {
        _init: function () {

            // 暴露到全局名称空间
            window.PKUI = PKUI;

            // 注册在当前模块中使用的组件
            this._registerComponent();

            // 全局的事件绑定
            this._bindEvent();

            // 配置ajax的默认参数
            this._setAjaxDefaultOptions();

            // 处理 __CTX__
            this._convertCtxPath();

            // 模板helper
            this._setTemplateHelper();

            // 预设 bootgrid 的formatter
            this._setBootgridFormatter();

            // 设置自动渲染
            this.setAutoRender( this.isAutoRender );
        },
        /**
         * 注册在当前模块中使用的组件
         */
        _registerComponent: function () {
            // DataSource
            PKUI.component.DataSource = DataSource;
            DataSource.init();
        },
        /**
         * 绑定事件
         */
        _bindEvent: function () {
            // DOM树构建完毕，执行一次渲染
            $doc.ready( PKUI.render );
        },
        /**
         * 设置Ajax的默认参数
         */
        _setAjaxDefaultOptions: function () {
            // 默认参数设置
            $.ajaxSetup( {
                type: "POST",   // 1.9.0 版本使用 "type"
                method: "POST", // 1.9.0 版本后用 "method"
                dataType: "json"
            } );
        },
        /**
         * 转换 __CTX__ 为 PKUI.ctxPath，转换情景：
         * 1. 使用 $.ajax( { url: "__CTX__/..." } )
         * 2. 使用 $jq.html( "....__CTX__..." )
         */
        _convertCtxPath: function () {
            var
                originHtmlMethod = $.fn.html,
                originAjaxMethod = $.ajax
            ;

            $.ajax = function ( url, options ) {
                // 正则添加".*"是为了解决被当成相对路径时，自动拼接的前缀。
                if ( typeof url === "string" ) {
                    url = url.replace( /.*__CTX__/, PKUI.ctxPath );
                }
                else if ( typeof url === "object" && url.hasOwnProperty( "url" ) ) {
                    url.url = url.url.replace( /.*__CTX__/, PKUI.ctxPath );
                }
                return originAjaxMethod.call( this, url, options );
            };

            $.fn.html = function ( value ) {

                // 没有传值
                if ( value === undefined ) {
                    return originHtmlMethod.call( this );
                }

                // 字符串
                if ( typeof value === "string" ) {
                    value = value.replace( /__CTX__/gm, PKUI.ctxPath );
                }

                return originHtmlMethod.call( this, value );

            }
        },
        /**
         * 模板helper
         * @example
         * {{addTime | dateFormat : "YYYY年MM月DD日 HH时mm分ss秒"}}
         * {{parentDeptId | dicValue: "DIC_DEPT" }}
         */
        _setTemplateHelper: function () {
            // 类比 <pku:dicValue>
            ArtTemplate.helper( "dicValue", function ( code, dicName ) {
                return DataSource.getDicValue( dicName, code );
            } );
            ArtTemplate.helper( "dateFormat", function ( date, format ) {
                return moment( date ).format( format )
            } );
        },
        /**
         * 预设 bootgrid formatter
         * @example
         * 录入时间
         */
        _setBootgridFormatter: function () {
            PKUI.bootgridFormatter = {
                // 日期 转 格式化后的年月日
                dateFormatter: function ( column, row ) {
                    var date = row[ column.id ];
                    return moment( date ).format( "YYYY年MM月DD日" )
                },
                // 日期 转 格式化后的年月日时分秒
                datetimeFormatter: function ( column, row ) {
                    var date = row[ column.id ];
                    return moment( date ).format( "YYYY年MM月DD日 HH时mm分ss秒" )
                },
                // 标志状态（正常/停用）
                statusFormatter: function ( column, row ) {
                    var
                        status = row[ column.id ]
                        ;
                    // 正常
                    if ( status === "1" ) {
                        return ' 正常';
                    }
                    // 停用
                    else {
                        return ' 停用';
                    }
                },
                // 标志状态（是/否）
                yesOrNoFormatter: function ( column, row ) {
                    var
                        status = row[ column.id ]
                        ;
                    // 正常
                    if ( status === "1" ) {
                        return ' 是';
                    }
                    // 停用
                    else {
                        return ' 否';
                    }
                }
            }
        },
        /**
         * 添加 tooltip
         */
        _addTooltip: function () {
            var
                $target
            ;
            // 如果在执行该方法，则退出
            if ( this._isAddingTooltip ) {
                return;
            }
            this._isAddingTooltip = true;

            $target = $( '[title]' ).not( function () {
                return ! $( this ).attr( "title" );
            } );

            $target.bsTooltip( {
                container: "body",
                placement: "auto top"
            } );

            this._isAddingTooltip = false;
        }
    } );

    /**
     * 核心功能
     */
    $.extend( PKUI, {

        // 载入模块（seajs.use方法的别名）
        load: seajs.use,

        /**
         * 渲染。
         *
         * 渲染的目标：
         *      // datagrid
         *

         *
         *      // drawer
         *

         *
         *      // form|validator
         *

         *
         *
         * 已渲染的标志（添加 isrendered="true"）：
         *
         *

         *
         *      渲染标志的添加由组件自身添加
         *
         * 不识别的组件（添加 notrecognized="not reg"）
         *
         *

         */
        render: function () {
            var
                $component = $( "[data-" + PKUI.componentHtmlAttr + "]" )
                    .not('[isrendered]')
                    .not( "[notrecognized='not reg']" )

                ;

            // 添加 tooltip
            PKUI._addTooltip();

            try {

                // 找不到标识为组件的
                if ( $component.size() === 0 ) {
                    return;
                }
                // 正在渲染时
                if ( PKUI.__isrendering ) {
                    console.info( moment().format( "YYYY年MM月DD日 HH:MM:SS" ), "正在渲染..." );
                    return;
                }

                PKUI.__isrendering = true;

                PKUI.__renderedTimes++;
                console.info( moment().format( "YYYY年MM月DD日 HH:MM:SS" ), "渲染次数：" + PKUI.__renderedTimes);

                $component.each( function () {
                    var
                        $this = $( this ),
                        componentName = $this.data( PKUI.componentHtmlAttr ),
                        // jQuery自动转为JSON对象了
                        componentOptions = $this.data( PKUI.componentOptionsHtmlAttr ) || {},
                        componentNameList
                        ;
                    if ( $.trim( componentName ) === "" ) {
                        return ;
                    }

                    if ( componentName.indexOf( "|" ) !== -1 ) {
                        componentNameList = componentName.split( "|" );
                    } else {
                        componentNameList = [ componentName ];
                    }

                    if ( ! $.isArray( componentOptions ) ) {
                        componentOptions = [ componentOptions ];
                    }

                    $.each( componentNameList, function( index, componentName ) {
                        var
                            options = componentOptions[ index ] || {},
                            component = PKUI.component[ $.trim( componentName ) ],
                            moduleId = componentName
                            ;
                        // 如果没有注册该组件，则载入，再初始化
                        if ( !component ) {
                            switch ( componentName ) {
                                case "datagrid":
                                    moduleId = "bootgrid";
                                    break;
                                case "datagrid-delete":
                                    moduleId = "datagrid-delete";
                                    break;
                                case "drawer":
                                    moduleId = "drawer";
                                    break;
                                case "form":
                                    moduleId = "form";
                                    break;
                                case "validator":
                                    moduleId = "validator";
                                    break;
                                case "chosen":
                                    moduleId = "chosen";
                                    break;
                                default:
                                    var errorMessage = "未被注册的组件[" + componentName + "]";
                                    PKUI.console.info( moment().format("YYYY年MM月DD日 HH:MM:SS") + " " + errorMessage );
                                    window.layer.msg( errorMessage );
                                    $this.attr( "notrecognized", "not reg" );
                                    return;
                            }
                            seajs.use( [ moduleId ], function () {
                                PKUI.component[ $.trim( componentName ) ].call( $this, options );
                            } );
                        }
                        // 如果已注册，则初始化
                        else {
                            component.call( $this, options );
                        }
                    } );

                } );

            } catch ( e ) {
                throw e;
            } finally {
                PKUI.__isrendering = false;
            }
        },

        /**
         * 开启/关闭 自动渲染。
         *
         * 自动渲染时机：
         *
         *      1. 调用 jquery.html( value ) 方法之后
         *      2. 调用 jquery.append( value ) 方法之后
         *      3. 调用 jquery.appendTo( value ) 方法之后
         *      4. 调用 jquery.prepend( value ) 方法之后
         *      5. 调用 jquery.prependTo( value ) 方法之后
         *
         * @param isAutoRender {boolean} true-开启，false-关闭。
         *
         */
        setAutoRender: function ( isAutoRender ) {
            if ( arguments.length === 0 ) {
                console.info( "/(ㄒoㄒ)/~~ 请设置参数。" );
                return;
            }

            PKUI.isAutoRender = Boolean( isAutoRender );

            if ( isAutoRender ) {

                PKUI.setAutoRender.pointcutHandlerList = [

                    // 1. 调用 jquery.html( value ) 方法之后
                    AOP.after( $.prototype, "html", PKUI.render )

                    // 2. 调用 jquery.append( value ) 方法之后
                    //AOP.after( $.prototype, "append", render ),

                    // 3. 调用 jquery.appendTo( value ) 方法之后
                    //AOP.after( $.prototype, "appendTo", render ),

                    // 4. 调用 jquery.prepend( value ) 方法之后
                    //AOP.after( $.prototype, "prepend", render ),

                    // 5. 调用 jquery.prependTo( value ) 方法之后
                    //AOP.after( $.prototype, "prependTo", render )

                ];

            } else {

                $.each( PKUI.setAutoRender.pointcutHandlerList, function ( index, pointcutHandler ) {
                    pointcutHandler.remove();
                } );

            }

        }
    } );

    /**
     * 通用功能
     */
    $.extend( PKUI, {
        /**
         * @example
         * public class JsonResult {
         *     private boolean success = false;
         *     private String message = "";
         *     private Object data;
         * }
         */
        handleJsonResult: function ( jsonResult ) {
            if ( typeof jsonResult === "string" ) {
                jsonResult = $.parseJSON( jsonResult );
            }
            // if ( jsonResult.success == false ) {
            //     return false;
            // }
            return jsonResult;
        },
        /**
         * @example
         * public class GridResult {
         *     private boolean success = true;
         *     private int totalRecords = 0;
         *     private List<?> data;
         * }
         */
        handleGridResult: function ( gridResult ) {
            return PKUI.handleJsonResult( gridResult );
        },
        /**
         * 转换树结构
         * @param options {{data: Array, rootId: string, idName: string, parentIdName: string, childrenName: string, filter: Array}}
         * @example
         * PKUI.getTreeList( {
                data: [
                    { menuId: 0, menuName: "系统管理", treeParentId: null },
                    { menuId: 1, menuName: "用户管理", treeParentId: 0 },
                    { menuId: 2, menuName: "单位管理", treeParentId: 0 }
                ],
                rootId: 0,
                idName: "menuId",
                parentIdName: "treeParentId",
                childrenName: "children"
           } );
         返回：
         [
         {
             menuId: 0, menuName: "系统管理", treeParentId: null,
             children: [
                 { menuId: 1, menuName: "用户管理", treeParentId: 0, children: null },
                 { menuId: 2, menuName: "单位管理", treeParentId: 0, children: null }
             ]
         }
         ]
         */
        getTreeList: function getTreeList( options ) {
            var
                data = options.data,
                rootId = options.rootId,
                idName = options.idName || "id",
                parentIdName = options.parentIdName || "parentId",
                childrenName = options.childrenName || "children",
                returnData,
                childrenCollection = {},
                parentId,
                rootList
                ;

            if ( !rootId ) {
                rootId = data[ 0 ][ idName ];
            }

            $.each( data, function ( index, elt ) {
                parentId = elt[ parentIdName ];
                childrenCollection[ parentId ] = childrenCollection[ parentId ] || [];
                childrenCollection[ parentId ].push( elt );
            } );

            rootList = data[ rootId ];

            if ( !$.isArray( rootList ) ) {
                rootList = [ rootList ];
            }

            returnData = fmtData( rootList );

            function fmtData( data ) {
                var list = []
                    ;
                if ( !data || !data.length ) {
                    return null;
                }
                $.each( data, function ( index, elt ) {
                    var record = elt,
                        newRecord
                        ;
                    newRecord = $.extend( {}, record );
                    newRecord[ childrenName ] = fmtData( childrenCollection[ record[ idName ] ] );
                    list.push( newRecord );
                } );
                return list;
            }

            return returnData;

        }
    } );

    PKUI._init();

} );<commit_msg>【PKUI】_pkui.js：当 title没有内容或内容为空白字符串时，不初始化tooltip<commit_after>
// PKUI 核心模块
define( function ( require ) {
    "use strict";

    require( "isLoading" );

    require( "css/font/font-awesome/4.7.0/font-awesome.css" );

    require( "layer" );
    require( "lib/component/layer/3.0.1.x/skin/default/layer.css" );

    require( "moment-local-zh" );

    require( "bootstrap-tooltip" );

    var
        $ = require( "jquery" ),

        AOP = require( "meld" ),

        moment = require( "moment" ),

        ArtTemplate = require( "artTemplate" ),

        DataSource = require( "dataSource" ),

        ns = window[ "www.pkusoft.net" ],

        $doc = $( window.document ),

        PKUI = {
            // 标识组件类型的HTML属性：

            componentHtmlAttr: "pkui-component",

            // 标识组件参数的HTML属性：

            componentOptionsHtmlAttr: "pkui-component-options",

            // CTX路径：${ ctx }（http://localhost:8080/projname）
            ctxPath: ns.ctxPath,

            // pkui的基本路径：${ ctx }/static/pkui
            basePath: ns.pkuiBasePath,

            // 字典路径：${ ctx }/static/dic/
            dicPath: ns.ctxPath + "/static/dic/",

            // 时间戳（版本控制）v=2012-1-1
            timestamp: ns.timestamp,

            // 组件容器
            component: {},

            // 自动渲染标志
            isAutoRender: true,

            // 是否正在渲染
            __isrendering: false,
            // 渲染次数（render()被调用的次数）
            __renderedTimes: 0

        }
        ;

    // 如果是在WebStorm里跑 PKUI项目，则更改 ctxPath 和 dicPath
    if ( location.href.indexOf( "localhost" ) !== -1 && ns.pkuiBasePath.indexOf( "static" ) === -1 ) {
        PKUI.ctxPath = "http://localhost:8080/pkui";
        PKUI.dicPath = "http://localhost:8080/pkui/static/dic/";
    }

    /**
     * 控制台打印
     * @type {{info: info, warn: warn, error: error}}
     */
    PKUI.console = {
        info: function ( message, isShow ) {
            console.info( message );
            if ( isShow ) {
                window.layer.msg( message );
            }
        },
        warn: function ( message, isShow ) {
            console.warn( message );
            if ( isShow ) {
                window.layer.msg( message );
            }
        },
        error: function ( message, isShow ) {
            console.error( message );
            if ( isShow ) {
                window.layer.msg( message );
            }
        }
    };

    /**
     * 初始化
     */
    $.extend( PKUI, {
        _init: function () {

            // 暴露到全局名称空间
            window.PKUI = PKUI;

            // 注册在当前模块中使用的组件
            this._registerComponent();

            // 全局的事件绑定
            this._bindEvent();

            // 配置ajax的默认参数
            this._setAjaxDefaultOptions();

            // 处理 __CTX__
            this._convertCtxPath();

            // 模板helper
            this._setTemplateHelper();

            // 预设 bootgrid 的formatter
            this._setBootgridFormatter();

            // 设置自动渲染
            this.setAutoRender( this.isAutoRender );
        },
        /**
         * 注册在当前模块中使用的组件
         */
        _registerComponent: function () {
            // DataSource
            PKUI.component.DataSource = DataSource;
            DataSource.init();
        },
        /**
         * 绑定事件
         */
        _bindEvent: function () {
            // DOM树构建完毕，执行一次渲染
            $doc.ready( PKUI.render );
        },
        /**
         * 设置Ajax的默认参数
         */
        _setAjaxDefaultOptions: function () {
            // 默认参数设置
            $.ajaxSetup( {
                type: "POST",   // 1.9.0 版本使用 "type"
                method: "POST", // 1.9.0 版本后用 "method"
                dataType: "json"
            } );
        },
        /**
         * 转换 __CTX__ 为 PKUI.ctxPath，转换情景：
         * 1. 使用 $.ajax( { url: "__CTX__/..." } )
         * 2. 使用 $jq.html( "....__CTX__..." )
         */
        _convertCtxPath: function () {
            var
                originHtmlMethod = $.fn.html,
                originAjaxMethod = $.ajax
            ;

            $.ajax = function ( url, options ) {
                // 正则添加".*"是为了解决被当成相对路径时，自动拼接的前缀。
                if ( typeof url === "string" ) {
                    url = url.replace( /.*__CTX__/, PKUI.ctxPath );
                }
                else if ( typeof url === "object" && url.hasOwnProperty( "url" ) ) {
                    url.url = url.url.replace( /.*__CTX__/, PKUI.ctxPath );
                }
                return originAjaxMethod.call( this, url, options );
            };

            $.fn.html = function ( value ) {

                // 没有传值
                if ( value === undefined ) {
                    return originHtmlMethod.call( this );
                }

                // 字符串
                if ( typeof value === "string" ) {
                    value = value.replace( /__CTX__/gm, PKUI.ctxPath );
                }

                return originHtmlMethod.call( this, value );

            }
        },
        /**
         * 模板helper
         * @example
         * {{addTime | dateFormat : "YYYY年MM月DD日 HH时mm分ss秒"}}
         * {{parentDeptId | dicValue: "DIC_DEPT" }}
         */
        _setTemplateHelper: function () {
            // 类比 <pku:dicValue>
            ArtTemplate.helper( "dicValue", function ( code, dicName ) {
                return DataSource.getDicValue( dicName, code );
            } );
            ArtTemplate.helper( "dateFormat", function ( date, format ) {
                return moment( date ).format( format )
            } );
        },
        /**
         * 预设 bootgrid formatter
         * @example
         * 录入时间
         */
        _setBootgridFormatter: function () {
            PKUI.bootgridFormatter = {
                // 日期 转 格式化后的年月日
                dateFormatter: function ( column, row ) {
                    var date = row[ column.id ];
                    return moment( date ).format( "YYYY年MM月DD日" )
                },
                // 日期 转 格式化后的年月日时分秒
                datetimeFormatter: function ( column, row ) {
                    var date = row[ column.id ];
                    return moment( date ).format( "YYYY年MM月DD日 HH时mm分ss秒" )
                },
                // 标志状态（正常/停用）
                statusFormatter: function ( column, row ) {
                    var
                        status = row[ column.id ]
                        ;
                    // 正常
                    if ( status === "1" ) {
                        return ' 正常';
                    }
                    // 停用
                    else {
                        return ' 停用';
                    }
                },
                // 标志状态（是/否）
                yesOrNoFormatter: function ( column, row ) {
                    var
                        status = row[ column.id ]
                        ;
                    // 正常
                    if ( status === "1" ) {
                        return ' 是';
                    }
                    // 停用
                    else {
                        return ' 否';
                    }
                }
            }
        },
        /**
         * 添加 tooltip
         */
        _addTooltip: function () {
            var
                $target
            ;
            // 如果在执行该方法，则退出
            if ( this._isAddingTooltip ) {
                return;
            }
            this._isAddingTooltip = true;

            $target = $( '[title]' ).not( function () {
                return ! $.trim( $( this ).attr( "title" ) );
            } );

            $target.bsTooltip( {
                container: "body",
                placement: "auto top"
            } );

            this._isAddingTooltip = false;
        }
    } );

    /**
     * 核心功能
     */
    $.extend( PKUI, {

        // 载入模块（seajs.use方法的别名）
        load: seajs.use,

        /**
         * 渲染。
         *
         * 渲染的目标：
         *      // datagrid
         *

         *
         *      // drawer
         *

         *
         *      // form|validator
         *

         *
         *
         * 已渲染的标志（添加 isrendered="true"）：
         *
         *

         *
         *      渲染标志的添加由组件自身添加
         *
         * 不识别的组件（添加 notrecognized="not reg"）
         *
         *

         */
        render: function () {
            var
                $component = $( "[data-" + PKUI.componentHtmlAttr + "]" )
                    .not('[isrendered]')
                    .not( "[notrecognized='not reg']" )

                ;

            // 添加 tooltip
            PKUI._addTooltip();

            try {

                // 找不到标识为组件的
                if ( $component.size() === 0 ) {
                    return;
                }
                // 正在渲染时
                if ( PKUI.__isrendering ) {
                    console.info( moment().format( "YYYY年MM月DD日 HH:MM:SS" ), "正在渲染..." );
                    return;
                }

                PKUI.__isrendering = true;

                PKUI.__renderedTimes++;
                console.info( moment().format( "YYYY年MM月DD日 HH:MM:SS" ), "渲染次数：" + PKUI.__renderedTimes);

                $component.each( function () {
                    var
                        $this = $( this ),
                        componentName = $this.data( PKUI.componentHtmlAttr ),
                        // jQuery自动转为JSON对象了
                        componentOptions = $this.data( PKUI.componentOptionsHtmlAttr ) || {},
                        componentNameList
                        ;
                    if ( $.trim( componentName ) === "" ) {
                        return ;
                    }

                    if ( componentName.indexOf( "|" ) !== -1 ) {
                        componentNameList = componentName.split( "|" );
                    } else {
                        componentNameList = [ componentName ];
                    }

                    if ( ! $.isArray( componentOptions ) ) {
                        componentOptions = [ componentOptions ];
                    }

                    $.each( componentNameList, function( index, componentName ) {
                        var
                            options = componentOptions[ index ] || {},
                            component = PKUI.component[ $.trim( componentName ) ],
                            moduleId = componentName
                            ;
                        // 如果没有注册该组件，则载入，再初始化
                        if ( !component ) {
                            switch ( componentName ) {
                                case "datagrid":
                                    moduleId = "bootgrid";
                                    break;
                                case "datagrid-delete":
                                    moduleId = "datagrid-delete";
                                    break;
                                case "drawer":
                                    moduleId = "drawer";
                                    break;
                                case "form":
                                    moduleId = "form";
                                    break;
                                case "validator":
                                    moduleId = "validator";
                                    break;
                                case "chosen":
                                    moduleId = "chosen";
                                    break;
                                default:
                                    var errorMessage = "未被注册的组件[" + componentName + "]";
                                    PKUI.console.info( moment().format("YYYY年MM月DD日 HH:MM:SS") + " " + errorMessage );
                                    window.layer.msg( errorMessage );
                                    $this.attr( "notrecognized", "not reg" );
                                    return;
                            }
                            seajs.use( [ moduleId ], function () {
                                PKUI.component[ $.trim( componentName ) ].call( $this, options );
                            } );
                        }
                        // 如果已注册，则初始化
                        else {
                            component.call( $this, options );
                        }
                    } );

                } );

            } catch ( e ) {
                throw e;
            } finally {
                PKUI.__isrendering = false;
            }
        },

        /**
         * 开启/关闭 自动渲染。
         *
         * 自动渲染时机：
         *
         *      1. 调用 jquery.html( value ) 方法之后
         *      2. 调用 jquery.append( value ) 方法之后
         *      3. 调用 jquery.appendTo( value ) 方法之后
         *      4. 调用 jquery.prepend( value ) 方法之后
         *      5. 调用 jquery.prependTo( value ) 方法之后
         *
         * @param isAutoRender {boolean} true-开启，false-关闭。
         *
         */
        setAutoRender: function ( isAutoRender ) {
            if ( arguments.length === 0 ) {
                console.info( "/(ㄒoㄒ)/~~ 请设置参数。" );
                return;
            }

            PKUI.isAutoRender = Boolean( isAutoRender );

            if ( isAutoRender ) {

                PKUI.setAutoRender.pointcutHandlerList = [

                    // 1. 调用 jquery.html( value ) 方法之后
                    AOP.after( $.prototype, "html", PKUI.render )

                    // 2. 调用 jquery.append( value ) 方法之后
                    //AOP.after( $.prototype, "append", render ),

                    // 3. 调用 jquery.appendTo( value ) 方法之后
                    //AOP.after( $.prototype, "appendTo", render ),

                    // 4. 调用 jquery.prepend( value ) 方法之后
                    //AOP.after( $.prototype, "prepend", render ),

                    // 5. 调用 jquery.prependTo( value ) 方法之后
                    //AOP.after( $.prototype, "prependTo", render )

                ];

            } else {

                $.each( PKUI.setAutoRender.pointcutHandlerList, function ( index, pointcutHandler ) {
                    pointcutHandler.remove();
                } );

            }

        }
    } );

    /**
     * 通用功能
     */
    $.extend( PKUI, {
        /**
         * @example
         * public class JsonResult {
         *     private boolean success = false;
         *     private String message = "";
         *     private Object data;
         * }
         */
        handleJsonResult: function ( jsonResult ) {
            if ( typeof jsonResult === "string" ) {
                jsonResult = $.parseJSON( jsonResult );
            }
            // if ( jsonResult.success == false ) {
            //     return false;
            // }
            return jsonResult;
        },
        /**
         * @example
         * public class GridResult {
         *     private boolean success = true;
         *     private int totalRecords = 0;
         *     private List<?> data;
         * }
         */
        handleGridResult: function ( gridResult ) {
            return PKUI.handleJsonResult( gridResult );
        },
        /**
         * 转换树结构
         * @param options {{data: Array, rootId: string, idName: string, parentIdName: string, childrenName: string, filter: Array}}
         * @example
         * PKUI.getTreeList( {
                data: [
                    { menuId: 0, menuName: "系统管理", treeParentId: null },
                    { menuId: 1, menuName: "用户管理", treeParentId: 0 },
                    { menuId: 2, menuName: "单位管理", treeParentId: 0 }
                ],
                rootId: 0,
                idName: "menuId",
                parentIdName: "treeParentId",
                childrenName: "children"
           } );
         返回：
         [
         {
             menuId: 0, menuName: "系统管理", treeParentId: null,
             children: [
                 { menuId: 1, menuName: "用户管理", treeParentId: 0, children: null },
                 { menuId: 2, menuName: "单位管理", treeParentId: 0, children: null }
             ]
         }
         ]
         */
        getTreeList: function getTreeList( options ) {
            var
                data = options.data,
                rootId = options.rootId,
                idName = options.idName || "id",
                parentIdName = options.parentIdName || "parentId",
                childrenName = options.childrenName || "children",
                returnData,
                childrenCollection = {},
                parentId,
                rootList
                ;

            if ( !rootId ) {
                rootId = data[ 0 ][ idName ];
            }

            $.each( data, function ( index, elt ) {
                parentId = elt[ parentIdName ];
                childrenCollection[ parentId ] = childrenCollection[ parentId ] || [];
                childrenCollection[ parentId ].push( elt );
            } );

            rootList = data[ rootId ];

            if ( !$.isArray( rootList ) ) {
                rootList = [ rootList ];
            }

            returnData = fmtData( rootList );

            function fmtData( data ) {
                var list = []
                    ;
                if ( !data || !data.length ) {
                    return null;
                }
                $.each( data, function ( index, elt ) {
                    var record = elt,
                        newRecord
                        ;
                    newRecord = $.extend( {}, record );
                    newRecord[ childrenName ] = fmtData( childrenCollection[ record[ idName ] ] );
                    list.push( newRecord );
                } );
                return list;
            }

            return returnData;

        }
    } );

    PKUI._init();

} );<|endoftext|>


<commit_before>export { default } from 'src/EasyV';
export { default as EasyVClass } from 'src/EasyVClass';
export { createInitialState } from 'src/helpers';
<commit_msg>Fix the import error<commit_after>export { default } from './EasyV';
export { default as EasyVClass } from './EasyVClass';
export { createInitialState } from './helpers';
<|endoftext|>


<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

const moment = require('moment');

function patchMomentType(pgp) {
	const types = pgp.pg.types;
	// This patches momentjs objects to work with pg-promise.
// See https://github.com/vitaly-t/pg-promise#custom-type-formatting
	moment.fn.formatDBType = function formatDBType() {
		return this.toDate();
	};

// This patches timestamps returned from postgres so that they are moment objects.
	const TIMESTAMPTZ_OID = 1184;
	const TIMESTAMP_OID = 1114;

	types.setTypeParser(TIMESTAMP_OID, moment);
	types.setTypeParser(TIMESTAMPTZ_OID, moment);

	moment.duration.fn._rawDBType = true; // eslint-disable-line no-underscore-dangle
	moment.duration.fn.formatDBType = function formatDBType() {
		return `'${this.toISOString()}'::INTERVAL`;
	};

	const INTERVAL_OID = 1186;
	types.setTypeParser(INTERVAL_OID, moment.duration);
}

module.exports = patchMomentType;
<commit_msg>fix moment test errors<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

const moment = require('moment');

function patchMomentType(pgp) {
	const types = pgp.pg.types;
	// This patches momentjs objects to work with pg-promise.
// See https://github.com/vitaly-t/pg-promise#custom-type-formatting
	moment.fn.formatDBType = function formatDBType() {
		return this.toDate();
	};

// This patches timestamps returned from postgres so that they are moment objects.
	const TIMESTAMPTZ_OID = 1184;
	const TIMESTAMP_OID = 1114;

	types.setTypeParser(TIMESTAMP_OID, moment);
	types.setTypeParser(TIMESTAMPTZ_OID, moment);

	moment.duration.fn.rawType = true; // eslint-disable-line no-underscore-dangle
	moment.duration.fn.toPostgres = function toPostgres() {
		return `'${this.toISOString()}'::INTERVAL`;
	};

	const INTERVAL_OID = 1186;
	types.setTypeParser(INTERVAL_OID, moment.duration);
}

module.exports = patchMomentType;
<|endoftext|>