<commit_before>/**
 * jQuery plugin monogusa.
 *
 * @Auth    Nully
 * @Url
 * @Make    10/04/26(Mon)
 * Version  1.0
 * @License MIT Lincense
 * The MIT License
 *
 * Copyright (c) 2010 <copyright Nully>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
(function(){
    Array.prototype.inArray = function(value) {
        for(var i in this) {
            if(this[i] === value) {
                return true;
            }
        }
        return false;
    }

    String.prototype.replaceAll = function(o, n) {
        return this.split(o).join(n);
    }
})();

(function($){
    var allowedPlugins = [
        "autoover", "tab", "stripe", "highlight", "scroller", "accordion"
    ];
    $.fn.monogusa = function(method, options) {
        if(!allowedPlugins.inArray(method)) {
            throw $.monogusa.riseError("not allowd method '"+ method +"' !");
        }

        try{
            return $.monogusa[method].call(this, options);
        }
        catch(e) {
            throw $.monogusa.riseError(e);
        }
    }

    // monogusa Object
    $.monogusa = {
        /**
         * autoover to link
         *
         * @access public
         * @param  options      Object
         *  mode   :     String        rollover mode. set to 'opacity' or 'toggle'.
         *  opacity:     Float|Int     rollover opacity value
         *  onStep :     Function      rollover animate callback method
         *  onHover:     Function      rollover hover callback
         *  onOut  :     Function      rollover mouseout callback
         */
        autoover: function(options) {
            var settings = $.extend({
                mode: "opacity",
                opacity: .7,
                duration: 400,
                suffix: "_on",
                onStep: function() {},
                onComplete: function() {},
                onHover: function() {},
                onOut: function() {}
            }, options || {});
            var modeHandler = (function(mode) {
                switch(mode) {
                    case "opacity":
                        return function(event) {
                            var $t = $(this);
                            if(event.originalEvent.type == "mouseover") {
                                $t.animate({ opacity: settings.opacity }, {
                                    duration: settings.duration,
                                    queue: false,
                                    complete: settings.onComplete,
                                    step: settings.onStep
                                });
                            }
                            else {
                                $t.animate({ opacity: 1 }, {
                                    duration: settings.duration,
                                    queue: false,
                                    complete: settings.onComplete,
                                    step: settings.onStep
                                });
                            }
                        }
                        break;
                    default:
                        return function(event) {
                            var $t = $(this),
                                $img = $t.children("img:first");

                            // no have a image
                            if($img.size() <= 0) {
                                return;
                            }

                            if(event.originalEvent.type == "mouseover") {
                                var tmp = $img.attr("src").split(".");
                                var ext = "." + tmp.pop(),
                                    _on = tmp.join(".") + settings.suffix;
                                $img.attr("src", _on + ext);
                            }
                            else {
                                $img.attr("src", $img.attr("src").replace(settings.suffix, ""));
                            }
                        }
                        break;
                }
            })(settings.mode);

            // on step is function ?
            if(!$.isFunction(settings.onStep))
                settings.onStep = function() {};

            // on step is function ?
            if(!$.isFunction(settings.onComplete))
                settings.onComplete = function() {};

            // onHover is function ?
            if(!$.isFunction(settings.onStep))
                settings.onHover = function() {};

            // onOut is function ?
            if(!$.isFunction(settings.onStep))
                settings.onOut = function() {};

            // do each anchors
            return this.each(function(i){
                var t = this,
                    $t = $(t),
                    $anchors = (function(el){
                        if(el.tagName == "A") {
                            return el;
                        }
                        return $(el).find("a");
                    })(t);

                $anchors.each(function() {
                    $(this).hover(function(ev){
                        settings.onHover.call(this, ev);
                        modeHandler.call(this, ev);
                    }, function(ev) {
                        settings.onOut.call(this, ev);
                        modeHandler.call(this, ev);
                    });
                });
            });
        },
        /**
         * accordion slider menu
         *
         * @access public
         * @param  options    Object
         *  header_class:   accordion slider header class name
         *  in_speed    :   accordion slide in speed (open)
         *  out_speed   :   accordion slide out speed (close)
         *  in_callback :   accordion open complete callback
         *  out_callback:   accordion close complete callback
         */
        accordion: function(options) {
            var settings = $.extend({
                header_class: "accordion_header",
                in_speed: 200,
                out_speed: 300,
                in_callback: function() {},
                out_callback: function() {}
            }, options || {});

            // calback functions is not a function, set to clouser function.
            if(!$.isFunction(settings.in_callback)) {
                settings.in_callback = function() {};
            }
            if(!$.isFunction(settings.out_callback)) {
                settings.out_callback = function() {};
            }

            // each of accordions
            return this.each(function(i){
                var $headers = $("." + settings.header_class + " a", this),
                    $panels;

                $headers.each(function(j){
                    var _target = $(this).attr("href");

                    // panel selectors
                    if($panels) $panels = $panels.add(_target);
                    else $panels = $(_target);

                    $(this).bind("click", function(ev){
                        var $current_panel = $($(this).attr("href"));

                        // is current panel shown return false.
                        if($current_panel.is(":visible")) {
                            return false;
                        }

                        // toggle accordion.
                        $panels.filter(":visible").slideUp(settings.out_speed, settings.out_callback);
                        $current_panel.slideDown(settings.in_speed, settings.in_callback);
                        ev.preventDefault();
                    });
                });
                $panels.not(":first").hide();
            });
        },
        /**
         * simple tab panel
         * for core UI tab, jQuery UI use it.
         *
         * @access pubic
         * @param  options    Object
         *  onClick:  on click to tab click callback
         *  onChange: on change to tab panel callback
         */
        tab: function(options) {
            var settings = $.extend({
                tab_active_class: "active",
                onClick: function() {},
                onChange: function() {}
            }, options || {});

            return this.each(function(i){
                var $t = $(this),
                    $ul = $("ul:first", $t),
                    $li = $("li", $ul),
                    $anchors = $("a", $li),
                    panelSelectors;

                $ul.addClass("monogusa-tabs monogusa-tabbox-" + i);
                $anchors.each(function(){
                    var selector = $(this).attr("href");
                    if(panelSelectors) {
                        panelSelectors = panelSelectors.add(selector).addClass("monogusa-panels");
                    }
                    else {
                        panelSelectors = $(selector);
                    }

                    $(this).bind("click", function(ev){
                        $anchors.removeClass(settings.tab_active_class);
                        panelSelectors.hide();
                        if($.isFunction(settings.onClick)) {
                            settings.onClick.call(this, this);
                        }
                        $(this).addClass(settings.tab_active_class);
                        $(selector).show();
                        ev.preventDefault();
                    });
                });
                $anchors.first().trigger("click");
            });
        },
        /**
         * stripe a rows.
         *
         * @access public
         * @param  options    Object
         *  odd_class:  odd row class
         *  even_class: even row class
         */
        stripe: function(options) {
            var settings = $.extend({
                odd_class: "odd",
                even_class: "even"
            }, options || {});

            this.each(function(){
                $(this).find("tr, li").each(function(i){
                    var cls = (i%2) ? settings.even_class : settings.odd_class;
                    $(this).addClass(cls);
                });
            });
        },
        /**
         * highlight for IE, not supported :hover class.
         *
         * @access public
         * @param  options    Object
         */
        highlight: function(options) {
            var settings = $.extend({
                hover_class: "monogusa_hover",
                onHover: function() {},
                onOut: function() {}
            }, options || {});

            this.each(function(){
                $(this).hover(function(){
                    if($.isFunction(settings.onHover)) {
                        settings.onHover.call(this);
                    }
                    $(this).addClass(settings.hover_class);
                }, function(){
                    if($.isFunction(settings.onOut)) {
                        settings.onOut.call(this);
                    }
                    $(this).removeClass(settings.hover_class);
                });
            });
        },
        /**
         * scroller
         *
         * @access public
         * @param  options     Object
         *  scroll_speed:    text or int. "ex) 'slow', 'fast', 1500"
         *  easing      :    required jQuery easing plugin. default supported 'linear', 'swing'.
         *  callback    :    scroll to end callback
         */
        scroller: function(options) {
            var _target = $.browser.safari ? "body": "html";
            var settings = $.extend({
                scroll_speed: 1000,
                easing: "swing",
                callback: function() {}
            }, options || {});

            return this.each(function(i){
                var t = this,
                    $t = $(t)
                    anchor = function() {
                        if(t.tagName == "A") {
                            return t;
                        }
                        return $t.find("a").get(0);
                    }(),
                    $anchor = $(anchor);

                // bind to click handler
                $anchor.bind("click", function(ev){
                    var top = $($(this).attr("href")).offset().top;
                    $(_target).animate({scrollTop: top}, settings.scroll_speed, settings.easing, settings.callback);
                    ev.preventDefault();
                });
            });
        },
        /**
         * KONAMI command !!
         *
         * @access public
         * @param  cmd        execute command
         * @param  callback   commnad executable callback, default meltdown !
         */
        konami: function(cmd, callback) {
            var pushed =[],
                command = cmd ? cmd: "38,38,40,40,37,39,37,39,66,65";
                clb = $.isFunction(callback) ? callback : function () {(function(){var s=document.createElement("script");s.charset="UTF-8";var da=new Date();s.src="http://www.rr.iij4u.or.jp/~kazumix/d/javascript/meltdown/meltdown.js?"+da.getTime(); document.body.appendChild(s)})();};

            $(document).keyup(function(ev) {
                if(command.match(ev.keyCode)) {
                    pushed.push(ev.keyCode);
                    var tmp = pushed.join(",");
                    if(tmp == command) {
                        clb.call(this, this, ev);
                    }
                }
            });
        },
        /**
         * RiseError message
         *
         * @access public
         * @param  message    String    error message
         */
        riseError: function(message) {
            if(window.console) {
                console.log(message);
            }
            alert(message);
        }
    };
})(jQuery);

<commit_msg>add method blank<commit_after>/**
 * jQuery plugin monogusa.
 *
 * @Auth    Nully
 * @Url
 * @Make    10/04/26(Mon)
 * Version  1.0
 * @License MIT Lincense
 * The MIT License
 *
 * Copyright (c) 2010 <copyright Nully>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
(function(){
    Array.prototype.inArray = function(value) {
        for(var i in this) {
            if(this[i] === value) {
                return true;
            }
        }
        return false;
    }

    String.prototype.replaceAll = function(o, n) {
        return this.split(o).join(n);
    }
})();

(function($){
    var allowedPlugins = [
        "autoover", "blank", "tab", "stripe", "highlight", "scroller", "accordion"
    ];
    $.fn.monogusa = function(method, options) {
        if(!allowedPlugins.inArray(method)) {
            throw $.monogusa.riseError("not allowd method '"+ method +"' !");
        }

        try{
            return $.monogusa[method].call(this, options);
        }
        catch(e) {
            throw $.monogusa.riseError(e);
        }
    }

    // monogusa Object
    $.monogusa = {
        /**
         * autoover to link
         *
         * @access public
         * @param  options      Object
         *  mode   :     String        rollover mode. set to 'opacity' or 'toggle'.
         *  opacity:     Float|Int     rollover opacity value
         *  onStep :     Function      rollover animate callback method
         *  onHover:     Function      rollover hover callback
         *  onOut  :     Function      rollover mouseout callback
         */
        autoover: function(options) {
            var settings = $.extend({
                mode: "opacity",
                opacity: .7,
                duration: 400,
                suffix: "_on",
                onStep: function() {},
                onComplete: function() {},
                onHover: function() {},
                onOut: function() {}
            }, options || {});
            var modeHandler = (function(mode) {
                switch(mode) {
                    case "opacity":
                        return function(event) {
                            var $t = $(this);
                            if(event.originalEvent.type == "mouseover") {
                                $t.animate({ opacity: settings.opacity }, {
                                    duration: settings.duration,
                                    queue: false,
                                    complete: settings.onComplete,
                                    step: settings.onStep
                                });
                            }
                            else {
                                $t.animate({ opacity: 1 }, {
                                    duration: settings.duration,
                                    queue: false,
                                    complete: settings.onComplete,
                                    step: settings.onStep
                                });
                            }
                        }
                        break;
                    default:
                        return function(event) {
                            var $t = $(this),
                                $img = $t.children("img:first");

                            // no have a image
                            if($img.size() <= 0) {
                                return;
                            }

                            if(event.originalEvent.type == "mouseover") {
                                var tmp = $img.attr("src").split(".");
                                var ext = "." + tmp.pop(),
                                    _on = tmp.join(".") + settings.suffix;
                                $img.attr("src", _on + ext);
                            }
                            else {
                                $img.attr("src", $img.attr("src").replace(settings.suffix, ""));
                            }
                        }
                        break;
                }
            })(settings.mode);

            // on step is function ?
            if(!$.isFunction(settings.onStep))
                settings.onStep = function() {};

            // on step is function ?
            if(!$.isFunction(settings.onComplete))
                settings.onComplete = function() {};

            // onHover is function ?
            if(!$.isFunction(settings.onStep))
                settings.onHover = function() {};

            // onOut is function ?
            if(!$.isFunction(settings.onStep))
                settings.onOut = function() {};

            // do each anchors
            return this.each(function(i){
                var t = this,
                    $t = $(t),
                    $anchors = (function(el){
                        if(el.tagName == "A") {
                            return el;
                        }
                        return $(el).find("a");
                    })(t);

                $anchors.each(function() {
                    $(this).hover(function(ev){
                        settings.onHover.call(this, ev);
                        modeHandler.call(this, ev);
                    }, function(ev) {
                        settings.onOut.call(this, ev);
                        modeHandler.call(this, ev);
                    });
                });
            });
        },
        /**
         * popup window blacnk link
         *
         * @access public
         * @param  options    Object
         */
        blank: function (options) {
        },
        /**
         * accordion slider menu
         *
         * @access public
         * @param  options    Object
         *  header_class:   accordion slider header class name
         *  in_speed    :   accordion slide in speed (open)
         *  out_speed   :   accordion slide out speed (close)
         *  in_callback :   accordion open complete callback
         *  out_callback:   accordion close complete callback
         */
        accordion: function(options) {
            var settings = $.extend({
                header_class: "accordion_header",
                in_speed: 200,
                out_speed: 300,
                in_callback: function() {},
                out_callback: function() {}
            }, options || {});

            // calback functions is not a function, set to clouser function.
            if(!$.isFunction(settings.in_callback)) {
                settings.in_callback = function() {};
            }
            if(!$.isFunction(settings.out_callback)) {
                settings.out_callback = function() {};
            }

            // each of accordions
            return this.each(function(i){
                var $headers = $("." + settings.header_class + " a", this),
                    $panels;

                $headers.each(function(j){
                    var _target = $(this).attr("href");

                    // panel selectors
                    if($panels) $panels = $panels.add(_target);
                    else $panels = $(_target);

                    $(this).bind("click", function(ev){
                        var $current_panel = $($(this).attr("href"));

                        // is current panel shown return false.
                        if($current_panel.is(":visible")) {
                            return false;
                        }

                        // toggle accordion.
                        $panels.filter(":visible").slideUp(settings.out_speed, settings.out_callback);
                        $current_panel.slideDown(settings.in_speed, settings.in_callback);
                        ev.preventDefault();
                    });
                });
                $panels.not(":first").hide();
            });
        },
        /**
         * simple tab panel
         * for core UI tab, jQuery UI use it.
         *
         * @access pubic
         * @param  options    Object
         *  onClick:  on click to tab click callback
         *  onChange: on change to tab panel callback
         */
        tab: function(options) {
            var settings = $.extend({
                tab_active_class: "active",
                onClick: function() {},
                onChange: function() {}
            }, options || {});

            return this.each(function(i){
                var $t = $(this),
                    $ul = $("ul:first", $t),
                    $li = $("li", $ul),
                    $anchors = $("a", $li),
                    panelSelectors;

                $ul.addClass("monogusa-tabs monogusa-tabbox-" + i);
                $anchors.each(function(){
                    var selector = $(this).attr("href");
                    if(panelSelectors) {
                        panelSelectors = panelSelectors.add(selector).addClass("monogusa-panels");
                    }
                    else {
                        panelSelectors = $(selector);
                    }

                    $(this).bind("click", function(ev){
                        $anchors.removeClass(settings.tab_active_class);
                        panelSelectors.hide();
                        if($.isFunction(settings.onClick)) {
                            settings.onClick.call(this, this);
                        }
                        $(this).addClass(settings.tab_active_class);
                        $(selector).show();
                        ev.preventDefault();
                    });
                });
                $anchors.first().trigger("click");
            });
        },
        /**
         * stripe a rows.
         *
         * @access public
         * @param  options    Object
         *  odd_class:  odd row class
         *  even_class: even row class
         */
        stripe: function(options) {
            var settings = $.extend({
                odd_class: "odd",
                even_class: "even"
            }, options || {});

            this.each(function(){
                $(this).find("tr, li").each(function(i){
                    var cls = (i%2) ? settings.even_class : settings.odd_class;
                    $(this).addClass(cls);
                });
            });
        },
        /**
         * highlight for IE, not supported :hover class.
         *
         * @access public
         * @param  options    Object
         */
        highlight: function(options) {
            var settings = $.extend({
                hover_class: "monogusa_hover",
                onHover: function() {},
                onOut: function() {}
            }, options || {});

            this.each(function(){
                $(this).hover(function(){
                    if($.isFunction(settings.onHover)) {
                        settings.onHover.call(this);
                    }
                    $(this).addClass(settings.hover_class);
                }, function(){
                    if($.isFunction(settings.onOut)) {
                        settings.onOut.call(this);
                    }
                    $(this).removeClass(settings.hover_class);
                });
            });
        },
        /**
         * scroller
         *
         * @access public
         * @param  options     Object
         *  scroll_speed:    text or int. "ex) 'slow', 'fast', 1500"
         *  easing      :    required jQuery easing plugin. default supported 'linear', 'swing'.
         *  callback    :    scroll to end callback
         */
        scroller: function(options) {
            var _target = $.browser.safari ? "body": "html";
            var settings = $.extend({
                scroll_speed: 1000,
                easing: "swing",
                callback: function() {}
            }, options || {});

            return this.each(function(i){
                var t = this,
                    $t = $(t)
                    anchor = function() {
                        if(t.tagName == "A") {
                            return t;
                        }
                        return $t.find("a").get(0);
                    }(),
                    $anchor = $(anchor);

                // bind to click handler
                $anchor.bind("click", function(ev){
                    var top = $($(this).attr("href")).offset().top;
                    $(_target).animate({scrollTop: top}, settings.scroll_speed, settings.easing, settings.callback);
                    ev.preventDefault();
                });
            });
        },
        /**
         * KONAMI command !!
         *
         * @access public
         * @param  cmd        execute command
         * @param  callback   commnad executable callback, default meltdown !
         */
        konami: function(cmd, callback) {
            var pushed =[],
                command = cmd ? cmd: "38,38,40,40,37,39,37,39,66,65";
                clb = $.isFunction(callback) ? callback : function () {(function(){var s=document.createElement("script");s.charset="UTF-8";var da=new Date();s.src="http://www.rr.iij4u.or.jp/~kazumix/d/javascript/meltdown/meltdown.js?"+da.getTime(); document.body.appendChild(s)})();};

            $(document).keyup(function(ev) {
                if(command.match(ev.keyCode)) {
                    pushed.push(ev.keyCode);
                    var tmp = pushed.join(",");
                    if(tmp == command) {
                        clb.call(this, this, ev);
                    }
                }
            });
        },
        /**
         * RiseError message
         *
         * @access public
         * @param  message    String    error message
         */
        riseError: function(message) {
            if(window.console) {
                console.log(message);
            }
            alert(message);
        }
    };
})(jQuery);

<|endoftext|>


<commit_before>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const StylelintPlugin = require('stylelint-webpack-plugin');
const TsConfigPlugin = require("./webpack-ext/tsconfig-webpack-plugin");
const SourceMapFixPlugin = require("./webpack-ext/source-map-fix-webpack-plugin");

module.exports = function (env, { mode }) {

	const production = (mode === 'production');

	const cssLoader = [
		MiniCssExtractPlugin.loader,
		{
			loader: 'css-loader',
			options: {
				url: false,
				modules: true,
				importLoaders: 2,
				...(production ? {} : { sourceMap: true })
			}
		},
		{
			loader: 'postcss-loader',
			options: {
				...(production ? {} : { sourceMap: true })
			}
		},
		{
			loader: 'sass-loader',
			options: {
				includePaths: [
					path.resolve(__dirname, "src/styles")
				],
				...(production ? {} : { sourceMap: true })
			}
		}
	];

	return {
		entry: {
			index: ["./src/index.tsx"],
		},
		output: {
			path: path.resolve(__dirname, "docs"),
			filename: "[name].js"
		},
		module: {
			rules: [
				{
					test: /(?<!\.jsx)\.pug$/,
					loader: "pug-loader"
				},
				{
					test: /\.jsx\.pug$/,
					use: require.resolve("./webpack-ext/jsx-pug-loader")
				},
				{
					test: /\.tsx?$/,
					loader: "ts-loader",
					options: {
						compilerOptions: (production ? {} : { sourceMap: true })
					}
				},
				{
					test: /\.scss$/,
					loader: cssLoader
				},
				{
					test: /(?<!\.(?:html|css|js))$/,
					include: [path.resolve(__dirname, "docs")],
					type: 'javascript/auto',
					loader: "file-loader",
					options: {
						name: "[path][name].[ext]",
						outputPath: url => path.relative("docs", url),
						emitFile: false
					}
				},
				{
					test: /LICENSE$/,
					loader: "./webpack-ext/license-loader",
				}
			]
		},
		resolve: {
			extensions: [".tsx", ".ts", ".js", ".json"],
			alias: {
				"project": __dirname,
				"assets": path.resolve(__dirname, "docs")
			},
			plugins: [
				new TsConfigPlugin()
			]
		},
		resolveLoader: {
			plugins: [
				new SourceMapFixPlugin()
			]
		},
		devServer: {
			contentBase: "docs"
		},
		plugins: [
			new MiniCssExtractPlugin({
				filename: "[name].css"
			}),
			new HtmlWebpackPlugin({
				template: "./src/index.pug",
				templateParameters: { process: { env: { NODE_ENV: mode } } },
				inject: 'head'
			}),
			new ScriptExtHtmlWebpackPlugin({
				defaultAttribute: 'async'
			}),
			...(production ? [] : [new StylelintPlugin({ files: "src/**/*.scss" })])
		]
	}
}<commit_msg>パスの区切り文字にバックスラッシュが交じる問題の修正<commit_after>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const StylelintPlugin = require('stylelint-webpack-plugin');
const TsConfigPlugin = require("./webpack-ext/tsconfig-webpack-plugin");
const SourceMapFixPlugin = require("./webpack-ext/source-map-fix-webpack-plugin");

module.exports = function (env, { mode }) {

	const production = (mode === 'production');

	const cssLoader = [
		MiniCssExtractPlugin.loader,
		{
			loader: 'css-loader',
			options: {
				url: false,
				modules: true,
				importLoaders: 2,
				...(production ? {} : { sourceMap: true })
			}
		},
		{
			loader: 'postcss-loader',
			options: {
				...(production ? {} : { sourceMap: true })
			}
		},
		{
			loader: 'sass-loader',
			options: {
				includePaths: [
					path.resolve(__dirname, "src/styles")
				],
				...(production ? {} : { sourceMap: true })
			}
		}
	];

	return {
		entry: {
			index: ["./src/index.tsx"],
		},
		output: {
			path: path.resolve(__dirname, "docs"),
			filename: "[name].js"
		},
		module: {
			rules: [
				{
					test: /(?<!\.jsx)\.pug$/,
					loader: "pug-loader"
				},
				{
					test: /\.jsx\.pug$/,
					use: require.resolve("./webpack-ext/jsx-pug-loader")
				},
				{
					test: /\.tsx?$/,
					loader: "ts-loader",
					options: {
						compilerOptions: (production ? {} : { sourceMap: true })
					}
				},
				{
					test: /\.scss$/,
					loader: cssLoader
				},
				{
					test: /(?<!\.(?:html|css|js))$/,
					include: [path.resolve(__dirname, "docs")],
					type: 'javascript/auto',
					loader: "file-loader",
					options: {
						name: "[path][name].[ext]",
						outputPath: url => path.relative("docs", url).replace(/\\/g, "/"),
						emitFile: false
					}
				},
				{
					test: /LICENSE$/,
					loader: "./webpack-ext/license-loader",
				}
			]
		},
		resolve: {
			extensions: [".tsx", ".ts", ".js", ".json"],
			alias: {
				"project": __dirname,
				"assets": path.resolve(__dirname, "docs")
			},
			plugins: [
				new TsConfigPlugin()
			]
		},
		resolveLoader: {
			plugins: [
				new SourceMapFixPlugin()
			]
		},
		devServer: {
			contentBase: "docs"
		},
		plugins: [
			new MiniCssExtractPlugin({
				filename: "[name].css"
			}),
			new HtmlWebpackPlugin({
				template: "./src/index.pug",
				templateParameters: { process: { env: { NODE_ENV: mode } } },
				inject: 'head'
			}),
			new ScriptExtHtmlWebpackPlugin({
				defaultAttribute: 'async'
			}),
			...(production ? [] : [new StylelintPlugin({ files: "src/**/*.scss" })])
		]
	}
}<|endoftext|>


<commit_before>'use strict';

// Declare app level module which depends on views, and components
angular.module('myApp', [
    'ngRoute',
    'myApp.view1',
    'myApp.view2',
    'myApp.version',
    'ServiceWorkerModule',
    'OfflinkJs'
]).
    config(['$routeProvider', function ($routeProvider) {
        $routeProvider.otherwise({redirectTo: '/view1'});
    }])
    .run(['ServiceWorkerService', function (ServiceWorkerService) {
        ServiceWorkerService.register('/app/sw.js', 1.3);
    }]);<commit_msg>Remove old cache<commit_after>'use strict';

// Declare app level module which depends on views, and components
angular.module('myApp', [
    'ngRoute',
    'myApp.view1',
    'myApp.view2',
    'myApp.version',
    'OfflinkJs'
]).
    config(['$routeProvider', function ($routeProvider) {
        $routeProvider.otherwise({redirectTo: '/view1'});
    }])
    .run(['ServiceWorkerService', function (ServiceWorkerService) {
        ServiceWorkerService.register('/app/sw.js', 1.3);
    }]);<|endoftext|>


<commit_before>(function($) {
    /**
    * jQuery Plugin to set the height of all images on a page to
    * a vertical rhythm.
    */
    $.fn.rhythmic = function() {
        'use strict'

        var defaults = {
            baseLineHeight: "16",
            heightUnits: "px"
        };

        // Make simpler variables from our defaults
        var baseLineHeight = defaults['baseLineHeight'];
        var heightUnits = defaults['heightUnits'];

        /**
         * This will check if a number is between a an b.
         *
         * @var a (int)          Min value
         * @var b (int)          Max value
         * @var inclusive (bool) Allows for specifying if the check a<>b should return true or false
         * @return (bool)
         */
        Number.prototype.between = function(a, b, inclusive) {
            var min = Math.min(a, b),
                max = Math.max(a, b);

            return inclusive ? this >= min && this <= max : this > min && this < max;
        }

        $(this).each(function() {
            var sizes = {
                1: [0, 95, (baseLineHeight * 3) + heightUnits],
                2: [96, 143, (baseLineHeight * 6) + heightUnits],
                3: [144, 191, (baseLineHeight * 9) + heightUnits],
                4: [192, 239, (baseLineHeight * 12) + heightUnits],
                5: [240, 287, (baseLineHeight * 15) + heightUnits],
                6: [288, 335, (baseLineHeight * 18) + heightUnits]
            }, size;

            var $this = $(this);

            // Get the parent element to allow for columns/grids etc.
            var $parentWidth = $this.parent().width();

            // Get the starting image width and height
            // NOTE: This may not be the actual true dimension of the image
            var $originalImgWidth  = $this.width();
            var $originalImgHeight = $this.height();

            // Get aspect ratio
            var $aspectRatio = $originalImgHeight / $originalImgWidth;

            // Force the image to be 100% width so we can determine the parents
            // width minus padding.
            $this.css('width', '100%');
            var $maxImgWidth = $this.width(); // Get the new width

            // Reset the width to it's original to avoid problems later
            $this.css('width', 'auto');

            if ($originalImgWidth > $maxImgWidth) {
                var $newHeight = $maxImgWidth * $aspectRatio;
                var $newWidth  = $maxImgWidth;
                logit("New Height: " + $newHeight);
                $this.css({
                    'width': $newWidth,
                    'height': $newHeight
                });
            }

            for (size in sizes) {
                if ($this.height().between(sizes[size][0], sizes[size][1], true)) {
                    var newHeight = sizes[size][2];
                    var newWidth = newHeight * $aspectRatio;

                    $this.css({
                        "display": "block",
                        "width": "auto",
                        "height": newHeight
                    });
                }
            }
        });
    };
})(jQuery);
<commit_msg>Adding window, document and undefined parameters to function call<commit_after>(function($, window, document, undefined) {
    /**
    * jQuery Plugin to set the height of all images on a page to
    * a vertical rhythm.
    */
    $.fn.rhythmic = function() {
        'use strict'

        var defaults = {
            baseLineHeight: "16",
            heightUnits: "px"
        };

        // Make simpler variables from our defaults
        var baseLineHeight = defaults['baseLineHeight'];
        var heightUnits = defaults['heightUnits'];

        /**
         * This will check if a number is between a an b.
         *
         * @var a (int)          Min value
         * @var b (int)          Max value
         * @var inclusive (bool) Allows for specifying if the check a<>b should return true or false
         * @return (bool)
         */
        Number.prototype.between = function(a, b, inclusive) {
            var min = Math.min(a, b),
                max = Math.max(a, b);

            return inclusive ? this >= min && this <= max : this > min && this < max;
        }

        $(this).each(function() {
            var sizes = {
                1: [0, 95, (baseLineHeight * 3) + heightUnits],
                2: [96, 143, (baseLineHeight * 6) + heightUnits],
                3: [144, 191, (baseLineHeight * 9) + heightUnits],
                4: [192, 239, (baseLineHeight * 12) + heightUnits],
                5: [240, 287, (baseLineHeight * 15) + heightUnits],
                6: [288, 335, (baseLineHeight * 18) + heightUnits]
            }, size;

            var $this = $(this);

            // Get the parent element to allow for columns/grids etc.
            var $parentWidth = $this.parent().width();

            // Get the starting image width and height
            // NOTE: This may not be the actual true dimension of the image
            var $originalImgWidth  = $this.width();
            var $originalImgHeight = $this.height();

            // Get aspect ratio
            var $aspectRatio = $originalImgHeight / $originalImgWidth;

            // Force the image to be 100% width so we can determine the parents
            // width minus padding.
            $this.css('width', '100%');
            var $maxImgWidth = $this.width(); // Get the new width

            // Reset the width to it's original to avoid problems later
            $this.css('width', 'auto');

            if ($originalImgWidth > $maxImgWidth) {
                var $newHeight = $maxImgWidth * $aspectRatio;
                var $newWidth  = $maxImgWidth;
                logit("New Height: " + $newHeight);
                $this.css({
                    'width': $newWidth,
                    'height': $newHeight
                });
            }

            for (size in sizes) {
                if ($this.height().between(sizes[size][0], sizes[size][1], true)) {
                    var newHeight = sizes[size][2];
                    var newWidth = newHeight * $aspectRatio;

                    $this.css({
                        "display": "block",
                        "width": "auto",
                        "height": newHeight
                    });
                }
            }
        });
    };
})(jQuery, window, document);
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var Clean = require('clean-webpack-plugin');

var plugins = [
  new webpack.DefinePlugin({
    VERSION: JSON.stringify(require('./package.json').version)
  })
];
if (process.env.npm_lifecycle_event === 'release') {
  plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {warnings: false},
    output: {comments: false}
  }));
} else {
  plugins.push(new Clean(['dist']));
}

module.exports = {
  entry: path.resolve(__dirname, 'src/main.js'),
  plugins: plugins,
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
      },
      {
        test: /\.scss$/,
        loaders: ['css', 'sass?includePaths[]='
            + path.resolve(__dirname, './node_modules/compass-mixins/lib')
            + '&includePaths[]='
            + path.resolve(__dirname, './src/base/scss')
        ],
        include: path.resolve(__dirname, 'src'),
      },
       {
           test: /\.(png|woff|eot|ttf|swf)/, loader: 'url-loader?limit=1'
       },
       {
           test: /\.svg/, loader: 'file-loader'
       },
       {
           test: /\.html/, loader: 'html?minimize=false'
       }
    ],
  },
  resolve: {
    extensions: ['', '.js'],
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    publicPath: '<%=baseUrl%>/',
    filename: 'clappr.js',
    library: 'Clappr',
    libraryTarget: 'umd',
  },
};
<commit_msg>webpack: change resolve root path configuration<commit_after>var path = require('path');
var webpack = require('webpack');
var Clean = require('clean-webpack-plugin');

var plugins = [
  new webpack.DefinePlugin({
    VERSION: JSON.stringify(require('./package.json').version)
  })
];
if (process.env.npm_lifecycle_event === 'release') {
  plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {warnings: false},
    output: {comments: false}
  }));
} else {
  plugins.push(new Clean(['dist']));
}

module.exports = {
  entry: path.resolve(__dirname, 'src/main.js'),
  plugins: plugins,
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
      },
      {
        test: /\.scss$/,
        loaders: ['css', 'sass?includePaths[]='
            + path.resolve(__dirname, './node_modules/compass-mixins/lib')
            + '&includePaths[]='
            + path.resolve(__dirname, './src/base/scss')
        ],
        include: path.resolve(__dirname, 'src'),
      },
       {
           test: /\.(png|woff|eot|ttf|swf)/, loader: 'url-loader?limit=1'
       },
       {
           test: /\.svg/, loader: 'file-loader'
       },
       {
           test: /\.html/, loader: 'html?minimize=false'
       }
    ],
  },
  resolve: {
    root: path.resolve(__dirname, 'src'),
    extensions: ['', '.js'],
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    publicPath: '<%=baseUrl%>/',
    filename: 'clappr.js',
    library: 'Clappr',
    libraryTarget: 'umd',
  },
};
<|endoftext|>


<commit_before>var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var config = require('./config')();
var Firebase = require("firebase");

var clarifai = require("./clarifai/clarifai-tags.js");

var routes = require('./routes/index');
var users = require('./routes/users');

var myFirebaseRef = new Firebase("https://boiling-inferno-5486.firebaseio.com/");
myFirebaseRef.child("imageLoading").on("child_added", function(snapshot) {
  var userUpload = snapshot.val();

});

function

var app = express();

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('less-middleware')(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/users', users);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

module.exports = app;
<commit_msg>add clarifai call<commit_after>var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var config = require('./config')();
var Firebase = require("firebase");

var clarifai = require("./clarifai/clarifai-tags.js");

var routes = require('./routes/index');
var users = require('./routes/users');

var myFirebaseRef = new Firebase("https://boiling-inferno-5486.firebaseio.com/");
myFirebaseRef.child("imageLoading").on("child_added", function(snapshot) {
  var userUpload = snapshot.val(); //img url
  clarifai.tagUrl(userUpload.toString, null, function(req, res, next) {

  });
});

function

var app = express();

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('less-middleware')(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/users', users);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

module.exports = app;
<|endoftext|>


<commit_before>module.exports = {

  /**
   * ES6 rules
   * @see http://eslint.org/docs/rules/#ecmascript-6
   */
  rules: {

    /**
     * Require braces around arrow function bodies
     * @see http://eslint.org/docs/rules/arrow-body-style
     * @fixable
     */
    'arrow-body-style': [ 'error', 'as-needed', {
      requireReturnForObjectLiteral: false
    }],

    /**
     * Require parentheses around arrow function arguments
     * @see http://eslint.org/docs/rules/arrow-parens
     * @fixable
     */
    'arrow-parens': [ 'error', 'as-needed', {
      requireForBlockBody: true
    }],

    /**
     * Enforce consistent spacing before and after the arrow in arrow functions
     * @see http://eslint.org/docs/rules/arrow-spacing
     * @fixable
     */
    'arrow-spacing': [ 'error', {
      before: true,
      after: true
    }],

    /**
     * Require super() calls in constructors
     * @see http://eslint.org/docs/rules/constructor-super
     */
    'constructor-super': 'error',

    /**
     * Enforce consistent spacing around * operators in generator functions
     * @see http://eslint.org/docs/rules/generator-star-spacing
     * @fixable
     */
    'generator-star-spacing': [ 'error', 'before' ],

    /**
     * Disallow reassigning class members
     * @see http://eslint.org/docs/rules/no-class-assign
     */
    'no-class-assign': 'error',

    /**
     * Disallow arrow functions where they could be confused with comparisons
     * @see http://eslint.org/docs/rules/no-confusing-arrow
     */
    'no-confusing-arrow': [ 'error', {
      allowParens: true
    }],

    /**
     * Disallow reassigning const variables
     * @see http://eslint.org/docs/rules/no-const-assign
     */
    'no-const-assign': 'error',

    /**
     * Disallow duplicate class members
     * @see http://eslint.org/docs/rules/no-dupe-class-members
     */
    'no-dupe-class-members': 'error',

    /**
     * Disallow duplicate module imports
     * @see http://eslint.org/docs/rules/no-duplicate-imports
     */
    'no-duplicate-imports': [ 'error', {
      includeExports: false
    }],

    /**
     * Disallow new operators with the Symbol object
     * @see http://eslint.org/docs/rules/no-new-symbol
     */
    'no-new-symbol': 'error',

    /**
     * Disallow specified modules when loaded by import
     * @see http://eslint.org/docs/rules/no-restricted-imports
     */
    'no-restricted-imports': 'off',

    /**
     * Disallow this/super before calling super() in constructors
     * @see http://eslint.org/docs/rules/no-this-before-super
     */
    'no-this-before-super': 'error',

    /**
     * Disallow unnecessary computed property keys in object literals
     * @see http://eslint.org/docs/rules/no-useless-computed-key
     * @fixable
     */
    'no-useless-computed-key': 'error',

    /**
     * Disallow unnecessary constructors
     * @see http://eslint.org/docs/rules/no-useless-constructor
     */
    'no-useless-constructor': 'error',

    /**
     * Disallow renaming import, export, and destructured assignments to the same name
     * @see http://eslint.org/docs/rules/no-useless-rename
     * @fixable
     */
    'no-useless-rename': 'error',

    /**
     * Require let or const instead of var
     * @see http://eslint.org/docs/rules/no-var
     * @fixable
     */
    'no-var': 'error',

    /**
     * Require or disallow method and property shorthand syntax for object literals
     * @see http://eslint.org/docs/rules/object-shorthand
     * @fixable
     */
    'object-shorthand': [ 'error', 'always' ],

    /**
     * Require arrow functions as callbacks
     * @see http://eslint.org/docs/rules/prefer-arrow-callback
     * @fixable
     */
    'prefer-arrow-callback': 'error',

    /**
     * Require const declarations for variables that are never reassigned after declared
     * @see http://eslint.org/docs/rules/prefer-const
     * @fixable
     */
    'prefer-const': [ 'error', {
      destructuring: 'any',
      ignoreReadBeforeAssign: false
    }],

    /**
     * Require destructuring from arrays and/or objects
     * @see http://eslint.org/docs/rules/prefer-destructuring
     */
    'prefer-destructuring': [ 'error', {
      array: true,
      object: true
    }, {
      enforceForRenamedProperties: true
    }],

    /**
     * Disallow parseInt() in favor of binary, octal, and hexadecimal literals
     * @see http://eslint.org/docs/rules/prefer-numeric-literals
     * @fixable
     */
    'prefer-numeric-literals': 'off',

    /**
     * Require Reflect methods where applicable
     * @see http://eslint.org/docs/rules/prefer-reflect
     */
    'prefer-reflect': 'error',

    /**
     * Require rest parameters instead of arguments
     * @see http://eslint.org/docs/rules/prefer-rest-params
     */
    'prefer-rest-params': 'error',

    /**
     * Require spread operators instead of .apply()
     * @see http://eslint.org/docs/rules/prefer-spread
     * @fixable
     */
    'prefer-spread': 'error',

    /**
     * Require template literals instead of string concatenation
     * @see http://eslint.org/docs/rules/prefer-template
     * @fixable
     */
    'prefer-template': 'error',

    /**
     * Require generator functions to contain yield
     * @see http://eslint.org/docs/rules/require-yield
     */
    'require-yield': 'off',

    /**
     * Enforce spacing between rest and spread operators and their expressions
     * @see http://eslint.org/docs/rules/rest-spread-spacing
     * @fixable
     */
    'rest-spread-spacing': [ 'error', 'never' ],

    /**
     * Enforce sorted import declarations within modules
     * @see http://eslint.org/docs/rules/sort-imports
     */
    'sort-imports': [ 'off', {
      ignoreCase: false,
      ignoreMemberSort: false,
      memberSyntaxSortOrder: [ 'none', 'all', 'multiple', 'single' ]
    }],

    /**
     * Require symbol descriptions
     * @see http://eslint.org/docs/rules/symbol-description
     */
    'symbol-description': 'error',

    /**
     * Require or disallow spacing around embedded expressions of template strings
     * @see http://eslint.org/docs/rules/template-curly-spacing
     * @fixable
     */
    'template-curly-spacing': [ 'error', 'never' ],

    /**
     * Require or disallow spacing around the * in yield* expressions
     * @see http://eslint.org/docs/rules/yield-star-spacing
     * @fixable
     */
    'yield-star-spacing': [ 'error', 'before' ]
  }
}
<commit_msg>Updated generator-star-spacing<commit_after>module.exports = {

  /**
   * ES6 rules
   * @see http://eslint.org/docs/rules/#ecmascript-6
   */
  rules: {

    /**
     * Require braces around arrow function bodies
     * @see http://eslint.org/docs/rules/arrow-body-style
     * @fixable
     */
    'arrow-body-style': [ 'error', 'as-needed', {
      requireReturnForObjectLiteral: false
    }],

    /**
     * Require parentheses around arrow function arguments
     * @see http://eslint.org/docs/rules/arrow-parens
     * @fixable
     */
    'arrow-parens': [ 'error', 'as-needed', {
      requireForBlockBody: true
    }],

    /**
     * Enforce consistent spacing before and after the arrow in arrow functions
     * @see http://eslint.org/docs/rules/arrow-spacing
     * @fixable
     */
    'arrow-spacing': [ 'error', {
      before: true,
      after: true
    }],

    /**
     * Require super() calls in constructors
     * @see http://eslint.org/docs/rules/constructor-super
     */
    'constructor-super': 'error',

    /**
     * Enforce consistent spacing around * operators in generator functions
     * @see http://eslint.org/docs/rules/generator-star-spacing
     * @fixable
     */
    'generator-star-spacing': [ 'error', 'both' ],

    /**
     * Disallow reassigning class members
     * @see http://eslint.org/docs/rules/no-class-assign
     */
    'no-class-assign': 'error',

    /**
     * Disallow arrow functions where they could be confused with comparisons
     * @see http://eslint.org/docs/rules/no-confusing-arrow
     */
    'no-confusing-arrow': [ 'error', {
      allowParens: true
    }],

    /**
     * Disallow reassigning const variables
     * @see http://eslint.org/docs/rules/no-const-assign
     */
    'no-const-assign': 'error',

    /**
     * Disallow duplicate class members
     * @see http://eslint.org/docs/rules/no-dupe-class-members
     */
    'no-dupe-class-members': 'error',

    /**
     * Disallow duplicate module imports
     * @see http://eslint.org/docs/rules/no-duplicate-imports
     */
    'no-duplicate-imports': [ 'error', {
      includeExports: false
    }],

    /**
     * Disallow new operators with the Symbol object
     * @see http://eslint.org/docs/rules/no-new-symbol
     */
    'no-new-symbol': 'error',

    /**
     * Disallow specified modules when loaded by import
     * @see http://eslint.org/docs/rules/no-restricted-imports
     */
    'no-restricted-imports': 'off',

    /**
     * Disallow this/super before calling super() in constructors
     * @see http://eslint.org/docs/rules/no-this-before-super
     */
    'no-this-before-super': 'error',

    /**
     * Disallow unnecessary computed property keys in object literals
     * @see http://eslint.org/docs/rules/no-useless-computed-key
     * @fixable
     */
    'no-useless-computed-key': 'error',

    /**
     * Disallow unnecessary constructors
     * @see http://eslint.org/docs/rules/no-useless-constructor
     */
    'no-useless-constructor': 'error',

    /**
     * Disallow renaming import, export, and destructured assignments to the same name
     * @see http://eslint.org/docs/rules/no-useless-rename
     * @fixable
     */
    'no-useless-rename': 'error',

    /**
     * Require let or const instead of var
     * @see http://eslint.org/docs/rules/no-var
     * @fixable
     */
    'no-var': 'error',

    /**
     * Require or disallow method and property shorthand syntax for object literals
     * @see http://eslint.org/docs/rules/object-shorthand
     * @fixable
     */
    'object-shorthand': [ 'error', 'always' ],

    /**
     * Require arrow functions as callbacks
     * @see http://eslint.org/docs/rules/prefer-arrow-callback
     * @fixable
     */
    'prefer-arrow-callback': 'error',

    /**
     * Require const declarations for variables that are never reassigned after declared
     * @see http://eslint.org/docs/rules/prefer-const
     * @fixable
     */
    'prefer-const': [ 'error', {
      destructuring: 'any',
      ignoreReadBeforeAssign: false
    }],

    /**
     * Require destructuring from arrays and/or objects
     * @see http://eslint.org/docs/rules/prefer-destructuring
     */
    'prefer-destructuring': [ 'error', {
      array: true,
      object: true
    }, {
      enforceForRenamedProperties: true
    }],

    /**
     * Disallow parseInt() in favor of binary, octal, and hexadecimal literals
     * @see http://eslint.org/docs/rules/prefer-numeric-literals
     * @fixable
     */
    'prefer-numeric-literals': 'off',

    /**
     * Require Reflect methods where applicable
     * @see http://eslint.org/docs/rules/prefer-reflect
     */
    'prefer-reflect': 'error',

    /**
     * Require rest parameters instead of arguments
     * @see http://eslint.org/docs/rules/prefer-rest-params
     */
    'prefer-rest-params': 'error',

    /**
     * Require spread operators instead of .apply()
     * @see http://eslint.org/docs/rules/prefer-spread
     * @fixable
     */
    'prefer-spread': 'error',

    /**
     * Require template literals instead of string concatenation
     * @see http://eslint.org/docs/rules/prefer-template
     * @fixable
     */
    'prefer-template': 'error',

    /**
     * Require generator functions to contain yield
     * @see http://eslint.org/docs/rules/require-yield
     */
    'require-yield': 'off',

    /**
     * Enforce spacing between rest and spread operators and their expressions
     * @see http://eslint.org/docs/rules/rest-spread-spacing
     * @fixable
     */
    'rest-spread-spacing': [ 'error', 'never' ],

    /**
     * Enforce sorted import declarations within modules
     * @see http://eslint.org/docs/rules/sort-imports
     */
    'sort-imports': [ 'off', {
      ignoreCase: false,
      ignoreMemberSort: false,
      memberSyntaxSortOrder: [ 'none', 'all', 'multiple', 'single' ]
    }],

    /**
     * Require symbol descriptions
     * @see http://eslint.org/docs/rules/symbol-description
     */
    'symbol-description': 'error',

    /**
     * Require or disallow spacing around embedded expressions of template strings
     * @see http://eslint.org/docs/rules/template-curly-spacing
     * @fixable
     */
    'template-curly-spacing': [ 'error', 'never' ],

    /**
     * Require or disallow spacing around the * in yield* expressions
     * @see http://eslint.org/docs/rules/yield-star-spacing
     * @fixable
     */
    'yield-star-spacing': [ 'error', 'before' ]
  }
}
<|endoftext|>


<commit_before>var app = require('app'),
  BrowserWindow = require('browser-window'),
  dialog = require('dialog'),
  fs = require('fs')
  ipc = require('ipc'),
  Menu = require('menu'),
  path = require('path');

// report crashes to atom-shell
require('crash-reporter').start();

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

//------------------------------------------------------------------------------
// Dialogs
// (These have to be created on the "browser" side, i.e. here, not on the "page")
//------------------------------------------------------------------------------

const existingProjectDialogOptions = {
  title: 'Please select an existing project.clj file',
  properties: ['openFile'],
  filters: [
    {
      name: 'Leiningen project.clj',
      extensions: ['clj']
    }
  ]
};

function showAddExistingProjectDialog() {
  dialog.showOpenDialog(existingProjectDialogOptions, function(filenames) {
    if (filenames) {
      var filename = filenames[0];
      mainWindow.webContents.send('add-existing-project-dialog-success', filename);
    }
  });
}

const newProjectDialogOptions = {
  title: 'Select a folder for your new project',
  properties: ['openDirectory']
};

function newProjectDialogSuccess(folders) {
  if (folders) {
    mainWindow.webContents.send('new-project-folder', folders[0]);
  }
}

function showNewProjectDialog() {
  dialog.showOpenDialog(newProjectDialogOptions, newProjectDialogSuccess);
}

ipc.on('request-add-existing-project-dialog', showAddExistingProjectDialog);
ipc.on('request-new-project-folder-dialog', showNewProjectDialog);

//------------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------------

// load development config (optional)
var devConfig = {};
if (fs.existsSync(__dirname + '/config.json')) {
  devConfig = require(__dirname + '/config.json');
}

// load window information
const windowInformationFile = app.getDataPath() + path.sep + 'window.json';
var windowInformation = {};
if (fs.existsSync(windowInformationFile)) {
  windowInformation = require(windowInformationFile);
}

function onBounceDock() {
  if (app &&
      app.hasOwnProperty('dock') &&
      app.dock.hasOwnProperty('bounce')) {
    app.dock.bounce();
  }
}

ipc.on('bounce-dock', onBounceDock);

var shutdownForRealHasHappened = false;

function shutdownForReal() {
  // save current window information
  windowInformation.maximized = mainWindow.isMaximized();
  windowInformation.position = mainWindow.getPosition();
  windowInformation.size = mainWindow.getSize();
  fs.writeFileSync(windowInformationFile, JSON.stringify(windowInformation));

  // toggle the shutdown for real flag and close the window
  shutdownForRealHasHappened = true;
  mainWindow.close();
}

ipc.on('shutdown-for-real', shutdownForReal);

// NOTE: copied this directly from the atom-shell docs
// is this really necessary?
function onWindowClosed() {
  // dereference the window object
  mainWindow = null;
}

function onWindowClose(evt) {
  // prevent window close if we have not shut down for real
  if (shutdownForRealHasHappened !== true) {
    evt.preventDefault();

    // send shutdown signal to the window
    mainWindow.webContents.send('shutdown-attempt');
  }
}

// send the OS-normalized app data path to the webpage
// NOTE: this event triggers the "global app init" on the webpage side
function onFinishLoad() {
  mainWindow.webContents.send('config-file-location', app.getDataPath());
}

// NOTE: not all of the browserWindow options listed on the docs page work
// on all operating systems
const browserWindowOptions = {
  height: 850,
  icon: __dirname + '/img/clojure-logo.png',
  title: 'ClojureScript Compiler',
  width: 1000
};

function startApp() {
  // create the browser window
  mainWindow = new BrowserWindow(browserWindowOptions);

  // load index.html
  mainWindow.loadUrl('file://' + __dirname + '/index.html');

  // send info to the webpage
  mainWindow.webContents.on('did-finish-load', onFinishLoad);

  // Emitted when the user tries to close the window
  mainWindow.on('close', onWindowClose);

  // Emitted when the window is closed.
  mainWindow.on('closed', onWindowClosed);

  // optionally launch dev tools
  if (devConfig.hasOwnProperty('dev-tools') &&
      devConfig['dev-tools'] === true) {
    mainWindow.openDevTools();
  }

  // position window initially
  if (windowInformation.hasOwnProperty('maximized') &&
      windowInformation.maximized === true) {
    mainWindow.maximize();
  }
  else if (windowInformation.hasOwnProperty('size') &&
           windowInformation.hasOwnProperty('position')) {
    mainWindow.setPosition(windowInformation.position[0], windowInformation.position[1]);
    mainWindow.setSize(windowInformation.size[0], windowInformation.size[1]);
  }
}

// This method will be called when atom-shell has done everything
// initialization and ready for creating browser windows.
app.on('ready', startApp);
<commit_msg>exit the application when all windows are closed<commit_after>var app = require('app'),
  BrowserWindow = require('browser-window'),
  dialog = require('dialog'),
  fs = require('fs')
  ipc = require('ipc'),
  Menu = require('menu'),
  path = require('path');

// report crashes to atom-shell
require('crash-reporter').start();

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

//------------------------------------------------------------------------------
// Dialogs
// (These have to be created on the "browser" side, i.e. here, not on the "page")
//------------------------------------------------------------------------------

const existingProjectDialogOptions = {
  title: 'Please select an existing project.clj file',
  properties: ['openFile'],
  filters: [
    {
      name: 'Leiningen project.clj',
      extensions: ['clj']
    }
  ]
};

function showAddExistingProjectDialog() {
  dialog.showOpenDialog(existingProjectDialogOptions, function(filenames) {
    if (filenames) {
      var filename = filenames[0];
      mainWindow.webContents.send('add-existing-project-dialog-success', filename);
    }
  });
}

const newProjectDialogOptions = {
  title: 'Select a folder for your new project',
  properties: ['openDirectory']
};

function newProjectDialogSuccess(folders) {
  if (folders) {
    mainWindow.webContents.send('new-project-folder', folders[0]);
  }
}

function showNewProjectDialog() {
  dialog.showOpenDialog(newProjectDialogOptions, newProjectDialogSuccess);
}

ipc.on('request-add-existing-project-dialog', showAddExistingProjectDialog);
ipc.on('request-new-project-folder-dialog', showNewProjectDialog);

//------------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------------

// load development config (optional)
var devConfig = {};
if (fs.existsSync(__dirname + '/config.json')) {
  devConfig = require(__dirname + '/config.json');
}

// load window information
const windowInformationFile = app.getDataPath() + path.sep + 'window.json';
var windowInformation = {};
if (fs.existsSync(windowInformationFile)) {
  windowInformation = require(windowInformationFile);
}

function onBounceDock() {
  if (app &&
      app.hasOwnProperty('dock') &&
      app.dock.hasOwnProperty('bounce')) {
    app.dock.bounce();
  }
}

ipc.on('bounce-dock', onBounceDock);

var shutdownForRealHasHappened = false;

function shutdownForReal() {
  // save current window information
  windowInformation.maximized = mainWindow.isMaximized();
  windowInformation.position = mainWindow.getPosition();
  windowInformation.size = mainWindow.getSize();
  fs.writeFileSync(windowInformationFile, JSON.stringify(windowInformation));

  // toggle the shutdown for real flag and close the window
  shutdownForRealHasHappened = true;
  mainWindow.close();
}

ipc.on('shutdown-for-real', shutdownForReal);

// NOTE: copied this directly from the atom-shell docs
// is this really necessary?
function onWindowClosed() {
  // dereference the window object
  mainWindow = null;
}

function onWindowClose(evt) {
  // prevent window close if we have not shut down for real
  if (shutdownForRealHasHappened !== true) {
    evt.preventDefault();

    // send shutdown signal to the window
    mainWindow.webContents.send('shutdown-attempt');
  }
}

// send the OS-normalized app data path to the webpage
// NOTE: this event triggers the "global app init" on the webpage side
function onFinishLoad() {
  mainWindow.webContents.send('config-file-location', app.getDataPath());
}

// NOTE: not all of the browserWindow options listed on the docs page work
// on all operating systems
const browserWindowOptions = {
  height: 850,
  icon: __dirname + '/img/clojure-logo.png',
  title: 'ClojureScript Compiler',
  width: 1000
};

function startApp() {
  // create the browser window
  mainWindow = new BrowserWindow(browserWindowOptions);

  // load index.html
  mainWindow.loadUrl('file://' + __dirname + '/index.html');

  // send info to the webpage
  mainWindow.webContents.on('did-finish-load', onFinishLoad);

  // Emitted when the user tries to close the window
  mainWindow.on('close', onWindowClose);

  // Emitted when the window is closed.
  mainWindow.on('closed', onWindowClosed);

  // optionally launch dev tools
  if (devConfig.hasOwnProperty('dev-tools') &&
      devConfig['dev-tools'] === true) {
    mainWindow.openDevTools();
  }

  // position window initially
  if (windowInformation.hasOwnProperty('maximized') &&
      windowInformation.maximized === true) {
    mainWindow.maximize();
  }
  else if (windowInformation.hasOwnProperty('size') &&
           windowInformation.hasOwnProperty('position')) {
    mainWindow.setPosition(windowInformation.position[0], windowInformation.position[1]);
    mainWindow.setSize(windowInformation.size[0], windowInformation.size[1]);
  }
}

// This method will be called when atom-shell has done everything
// initialization and ready for creating browser windows.
app.on('ready', startApp);

// Quit the application when all windows are closed.
app.on('window-all-closed', function() {
  app.quit();
});
<|endoftext|>


<commit_before>var webpack = require('webpack')
var path = require('path')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')

var isProduction = process.env.NODE_ENV === 'production'

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  entry: {
    'assets/app': './client/main.js',
    'assets/hot': './client/hot-reload.js',
  },
  output: {
    path: resolve('/dist'),
    filename: '[name].js',
    publicPath: '/',
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      vue$: 'vue/dist/vue.esm.js',
      '@': resolve('client'),
    },
  },
  plugins: isProduction
    ? [
        new webpack.DefinePlugin({
          'process.env': {
            NODE_ENV: '"production"',
          },
        }),
        new ExtractTextPlugin('assets/index.css'),
        new webpack.optimize.UglifyJsPlugin({
          compress: { warnings: false },
          sourceMap: true,
        }),
        new OptimizeCSSPlugin({
          cssProcessorOptions: {
            safe: true,
          },
        }),
        new HtmlWebpackPlugin({
          template: 'client/index.html',
          minify: {
            removeComments: true,
            collapseWhitespace: true,
            removeAttributeQuotes: true,
          },
          inject: true,
        }),
        new FriendlyErrorsPlugin(),
      ]
    : [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoEmitOnErrorsPlugin(),
        new HtmlWebpackPlugin({
          filename: 'index.html',
          template: 'client/index.html',
          inject: true,
        }),
        new FriendlyErrorsPlugin(),
      ],
  module: {
    rules: [
      {
        test: /\.(js|vue)$/,
        loader: 'eslint-loader',
        enforce: 'pre',
        include: [resolve('client'), resolve('test')],
        options: {
          formatter: require('eslint-friendly-formatter'),
        },
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: isProduction
            ? ExtractTextPlugin.extract({
                use: ['vue-style-loader', 'css-loader'],
                fallback: 'vue-style-loader',
              })
            : [
                'vue-style-loader',
                {
                  loader: 'css-loader',
                  options: {
                    minimize: isProduction,
                    sourceMap: isProduction,
                  },
                },
              ],
          transformToRequire: {
            video: 'src',
            source: 'src',
            img: 'src',
            image: 'xlink:href',
          },
        },
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('client'), resolve('test')],
      },
      {
        test: /\.css$/,
        loader: isProduction
          ? ExtractTextPlugin.extract({
              fallback: 'vue-style-loader',
              use: ['css-loader'],
            })
          : [
              'style-loader',
              {
                loader: 'css-loader',
                options: {
                  minimize: isProduction,
                  sourceMap: isProduction,
                },
              },
            ],
        include: [resolve('node_modules')],
      },
    ],
  },
}
<commit_msg>Remove hot reloading script from production build<commit_after>var webpack = require('webpack')
var path = require('path')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')

var isProduction = process.env.NODE_ENV === 'production'

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  entry: isProduction
    ? {
      'assets/app': './client/main.js',
    }
  : {
    'assets/app': './client/main.js',
    'assets/hot': './client/hot-reload.js',
  },
  output: {
    path: resolve('/dist'),
    filename: '[name].js',
    publicPath: '/',
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      vue$: 'vue/dist/vue.esm.js',
      '@': resolve('client'),
    },
  },
  plugins: isProduction
    ? [
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: '"production"',
        },
      }),
      new ExtractTextPlugin('assets/index.css'),
      new webpack.optimize.UglifyJsPlugin({
        compress: { warnings: false },
        sourceMap: true,
      }),
      new OptimizeCSSPlugin({
        cssProcessorOptions: {
          safe: true,
        },
      }),
      new HtmlWebpackPlugin({
        template: 'client/index.html',
        minify: {
          removeComments: true,
          collapseWhitespace: true,
          removeAttributeQuotes: true,
        },
        inject: true,
      }),
      new FriendlyErrorsPlugin(),
    ]
  : [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'client/index.html',
      inject: true,
    }),
    new FriendlyErrorsPlugin(),
  ],
  module: {
    rules: [
      {
        test: /\.(js|vue)$/,
        loader: 'eslint-loader',
        enforce: 'pre',
        include: [resolve('client'), resolve('test')],
        options: {
          formatter: require('eslint-friendly-formatter'),
        },
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: isProduction
            ? ExtractTextPlugin.extract({
              use: ['vue-style-loader', 'css-loader'],
              fallback: 'vue-style-loader',
            })
          : [
            'vue-style-loader',
            {
              loader: 'css-loader',
              options: {
                minimize: isProduction,
                sourceMap: isProduction,
              },
            },
          ],
          transformToRequire: {
            video: 'src',
            source: 'src',
            img: 'src',
            image: 'xlink:href',
          },
        },
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('client'), resolve('test')],
      },
      {
        test: /\.css$/,
        loader: isProduction
          ? ExtractTextPlugin.extract({
            fallback: 'vue-style-loader',
            use: ['css-loader'],
          })
        : [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              minimize: isProduction,
              sourceMap: isProduction,
            },
          },
        ],
        include: [resolve('node_modules')],
      },
    ],
  },
}
<|endoftext|>


<commit_before>'use strict';

var $ = require('jquery');
var bootbox = require('bootbox');
var m = require('mithril');
var Treebeard = require('treebeard');
var $osf = require('js/osfHelpers');
var Fangorn = require('js/fangorn');
require('../css/fangorn.css');

// TODO: Refactor out shared utility code between this module, folder picker, and fangorn.js
function resolveToggle(item) {
    var toggleMinus = m('i.fa.fa-minus', ' '),
        togglePlus = m('i.fa.fa-plus', ' ');

    if (item.children.length > 0) {
        if (item.open) {
            return toggleMinus;
        }
        return togglePlus;
    }
    item.open = true;
    return '';
}

function expandOnLoad() {
    var tb = this;  // jshint ignore: line
    for (var i = 0; i < tb.treeData.children.length; i++) {
        var parent = tb.treeData.children[i];
        tb.updateFolder(null, parent);
        expandChildren(tb, parent.children);
    }
}

function expandChildren(tb, children) {
    var openParent = false;
    for (var i = 0; i < children.length; i++) {
        var child = children[i];
        var parent = children[i].parent();
        if (child.children.length > 0) {
            expandChildren(tb, child.children);
        }
    }
    if (openParent) {
        openAncestors(tb, children[0]);
    }
}

function openAncestors (tb, item) {
    var parent = item.parent();
    if(parent && parent.id > 0) {
        tb.updateFolder(null, parent);
        openAncestors(tb, parent);
    }
}

function before_change_permissions(item, permission){
    var title = item.parent().data.node.title;
    if(permission === 'public'){
        bootbox.confirm({
            title: 'Warning',
            message: 'Are you sure you want to make the wiki of '+title+
                ' publicly editable? This will allow any logged in user to edit the content of your wiki. ' +
                + 'Non-contributor users will not be able to add or remove pages. '+
                'Note: ' +title+ ' must be public for public editing to be available.',
            callback: function(confirm) {
            if (confirm) {
                change_permissions(item, permission);
                }
            }
        });
    }
    else {
        change_permissions(item, permission);
    }
}

function change_permissions(item, permission) {
    var id = item.parent().data.node.id;

    $osf.putJSON(
        build_path(item, permission), {}
    ).done(function(){
        item.notify.update('Settings updated', 'notify-success', 1, 2000);
        item.data.event.permission = permission;
    }).fail(function() {
        item.notify.update('Could not update settings.', 'notify-danger', 1, 2000);
    });
}

// Helper to build path
function build_path(item, permission) {
    var id = item.parent().data.node.id;
    var permissions_change_path = '/api/v1/project/'+ id +
        '/wiki/permissions/' + permission + '/';
    return permissions_change_path;
}

function ProjectWiki(data) {

    //  Treebeard version
    var tbOptions = {
        divID: 'wgrid',
        filesData: data,
        rowHeight : 33,         // user can override or get from .tb-row height
        resolveToggle: resolveToggle,
        paginate : false,       // Whether the applet starts with pagination or not.
        paginateToggle : false, // Show the buttons that allow users to switch between scroll and paginate.
        uploads : false,         // Turns dropzone on/off.
        resolveIcon : Fangorn.Utils.resolveIconView,
        hideColumnTitles: true,
        columnTitles : function wikiColumnTitles(item, col) {
            return [
                {
                    title: 'Project',
                    width: '60%',
                    sortType : 'text',
                    sort : false
                },
                {
                    title: 'Editing Toggle',
                    width : '40%',
                    sort : false

                }
            ];
        },
        ontogglefolder : function (item){
            var containerHeight = this.select('#tb-tbody').height();
            this.options.showTotal = Math.floor(containerHeight / this.options.rowHeight) + 1;
            this.redraw();
        },
        resolveRows : function wikiResolveRows(item){
            var columns = [];
            var iconcss = '';
            // check if should not get icon
            if(item.children.length < 1 ){
                iconcss = 'tb-no-icon';
            }
            if (item.data.kind === 'heading') {
                if (item.data.children.length === 0) {
                    columns.push({
                        data : 'project',  // Data field name
                        folderIcons : false,
                        filter : true,
                        sortInclude : false,
                        custom : function() {
                            return m('div[style="padding-left:5px"]',
                                        [m ('p', [
                                                m('b', item.data.node.title + ': '),
                                                m('span[class="text-warning"]', ' No configured projects.')]
                                        )]
                            );
                        }
                    });
                } else {
                    columns.push({
                        data : 'project',  // Data field name
                        folderIcons : false,
                        filter : true,
                        sortInclude : false,
                        custom : function() {
                            return m('div[style="padding-left:5px"]',
                                    [m('p',
                                        [m('b', item.data.node.title + ':')]
                                )]
                            );
                        }
                    });
                }
            }
            else if (item.data.kind === 'folder' || item.data.kind === 'node') {
                columns.push({
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    sortInclude : false,
                    custom : function() {
                        if (item.data.node.url !== '') {
                            return m('a', { href : item.data.node.url, target : '_blank' }, item.data.node.title);
                        } else {
                            return m('span', item.data.node.title);
                        }

                    }
                });
            }

            else {
                columns.push(
                {
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    css : iconcss,
                    sortInclude : false,
                    custom : function() {
                        return 'Editing Settings';

                    }
                },
                {
                    data : 'permission',  // Data field name
                    folderIcons : false,
                    filter : false,
                    custom : function() {
                        return  m('div[style="padding-right:10px"]',
                            [m('select.form-control', {
                                onchange: function(ev) {
                                    before_change_permissions(item, ev.target.value);
                                }},
                                [
                                    m('option', {value: 'private', selected : item.data.event.permission === 'private' ? 'selected': ''}, 'Private'),
                                    m('option', {value: 'public', selected : item.data.event.permission === 'public' ? 'selected': ''}, 'Public')
                            ])
                        ]);
                    }
                });
            }

            return columns;
        },
        sortButtonSelector : {
            up : 'i.fa.fa-chevron-up',
            down : 'i.fa.fa-chevron-down'
        },
        showFilter : false,     // Gives the option to filter by showing the filter box.
        allowMove : false,       // Turn moving on or off.
        hoverClass : 'fangorn-hover',
        resolveRefreshIcon : function() {
          return m('i.fa.fa-refresh.fa-spin');
        }
    };
    var wgrid = new Treebeard(tbOptions);
    expandOnLoad.call(wgrid.tbController);
}

module.exports = ProjectWiki;
<commit_msg>Fix according to new jshint requirements<commit_after>'use strict';

var $ = require('jquery');
var bootbox = require('bootbox');
var m = require('mithril');
var Treebeard = require('treebeard');
var $osf = require('js/osfHelpers');
var Fangorn = require('js/fangorn');
require('../css/fangorn.css');

// TODO: Refactor out shared utility code between this module, folder picker, and fangorn.js
function resolveToggle(item) {
    var toggleMinus = m('i.fa.fa-minus', ' '),
        togglePlus = m('i.fa.fa-plus', ' ');

    if (item.children.length > 0) {
        if (item.open) {
            return toggleMinus;
        }
        return togglePlus;
    }
    item.open = true;
    return '';
}

function expandOnLoad() {
    var tb = this;  // jshint ignore: line
    for (var i = 0; i < tb.treeData.children.length; i++) {
        var parent = tb.treeData.children[i];
        tb.updateFolder(null, parent);
        expandChildren(tb, parent.children);
    }
}

function expandChildren(tb, children) {
    var openParent = false;
    for (var i = 0; i < children.length; i++) {
        var child = children[i];
        var parent = children[i].parent();
        if (child.children.length > 0) {
            expandChildren(tb, child.children);
        }
    }
    if (openParent) {
        openAncestors(tb, children[0]);
    }
}

function openAncestors (tb, item) {
    var parent = item.parent();
    if(parent && parent.id > 0) {
        tb.updateFolder(null, parent);
        openAncestors(tb, parent);
    }
}

function before_change_permissions(item, permission){
    var title = item.parent().data.node.title;
    if(permission === 'public'){
        bootbox.confirm({
            title: 'Warning',
            message: 'Are you sure you want to make the wiki of ' + title +
                ' publicly editable? This will allow any logged in user to edit the content of your wiki. ' +
                'Non-contributor users will not be able to add or remove pages. ' +
                'Note: ' + title + ' must be public for public editing to be available.',
            callback: function(confirm) {
            if (confirm) {
                change_permissions(item, permission);
                }
            }
        });
    }
    else {
        change_permissions(item, permission);
    }
}

function change_permissions(item, permission) {
    var id = item.parent().data.node.id;

    $osf.putJSON(
        build_path(item, permission), {}
    ).done(function(){
        item.notify.update('Settings updated', 'notify-success', 1, 2000);
        item.data.event.permission = permission;
    }).fail(function() {
        item.notify.update('Could not update settings.', 'notify-danger', 1, 2000);
    });
}

// Helper to build path
function build_path(item, permission) {
    var id = item.parent().data.node.id;
    var permissions_change_path = '/api/v1/project/'+ id +
        '/wiki/permissions/' + permission + '/';
    return permissions_change_path;
}

function ProjectWiki(data) {

    //  Treebeard version
    var tbOptions = {
        divID: 'wgrid',
        filesData: data,
        rowHeight : 33,         // user can override or get from .tb-row height
        resolveToggle: resolveToggle,
        paginate : false,       // Whether the applet starts with pagination or not.
        paginateToggle : false, // Show the buttons that allow users to switch between scroll and paginate.
        uploads : false,         // Turns dropzone on/off.
        resolveIcon : Fangorn.Utils.resolveIconView,
        hideColumnTitles: true,
        columnTitles : function wikiColumnTitles(item, col) {
            return [
                {
                    title: 'Project',
                    width: '60%',
                    sortType : 'text',
                    sort : false
                },
                {
                    title: 'Editing Toggle',
                    width : '40%',
                    sort : false

                }
            ];
        },
        ontogglefolder : function (item){
            var containerHeight = this.select('#tb-tbody').height();
            this.options.showTotal = Math.floor(containerHeight / this.options.rowHeight) + 1;
            this.redraw();
        },
        resolveRows : function wikiResolveRows(item){
            var columns = [];
            var iconcss = '';
            // check if should not get icon
            if(item.children.length < 1 ){
                iconcss = 'tb-no-icon';
            }
            if (item.data.kind === 'heading') {
                if (item.data.children.length === 0) {
                    columns.push({
                        data : 'project',  // Data field name
                        folderIcons : false,
                        filter : true,
                        sortInclude : false,
                        custom : function() {
                            return m('div[style="padding-left:5px"]',
                                        [m ('p', [
                                                m('b', item.data.node.title + ': '),
                                                m('span[class="text-warning"]', ' No configured projects.')]
                                        )]
                            );
                        }
                    });
                } else {
                    columns.push({
                        data : 'project',  // Data field name
                        folderIcons : false,
                        filter : true,
                        sortInclude : false,
                        custom : function() {
                            return m('div[style="padding-left:5px"]',
                                    [m('p',
                                        [m('b', item.data.node.title + ':')]
                                )]
                            );
                        }
                    });
                }
            }
            else if (item.data.kind === 'folder' || item.data.kind === 'node') {
                columns.push({
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    sortInclude : false,
                    custom : function() {
                        if (item.data.node.url !== '') {
                            return m('a', { href : item.data.node.url, target : '_blank' }, item.data.node.title);
                        } else {
                            return m('span', item.data.node.title);
                        }

                    }
                });
            }

            else {
                columns.push(
                {
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    css : iconcss,
                    sortInclude : false,
                    custom : function() {
                        return 'Editing Settings';

                    }
                },
                {
                    data : 'permission',  // Data field name
                    folderIcons : false,
                    filter : false,
                    custom : function() {
                        return  m('div[style="padding-right:10px"]',
                            [m('select.form-control', {
                                onchange: function(ev) {
                                    before_change_permissions(item, ev.target.value);
                                }},
                                [
                                    m('option', {value: 'private', selected : item.data.event.permission === 'private' ? 'selected': ''}, 'Private'),
                                    m('option', {value: 'public', selected : item.data.event.permission === 'public' ? 'selected': ''}, 'Public')
                            ])
                        ]);
                    }
                });
            }

            return columns;
        },
        sortButtonSelector : {
            up : 'i.fa.fa-chevron-up',
            down : 'i.fa.fa-chevron-down'
        },
        showFilter : false,     // Gives the option to filter by showing the filter box.
        allowMove : false,       // Turn moving on or off.
        hoverClass : 'fangorn-hover',
        resolveRefreshIcon : function() {
          return m('i.fa.fa-refresh.fa-spin');
        }
    };
    var wgrid = new Treebeard(tbOptions);
    expandOnLoad.call(wgrid.tbController);
}

module.exports = ProjectWiki;
<|endoftext|>


<commit_before>'use strict';

module.exports = {
  plugins: ['prettier'],
  extends: ['eslint-config-prettier'].map(require.resolve),

  rules: {
    'prettier/prettier': 'error',
  },
};
<commit_msg>feat: reenable rules curly and quotes disabled by prettier config<commit_after>'use strict';

module.exports = {
  plugins: ['prettier'],
  extends: ['eslint-config-prettier'].map(require.resolve),

  rules: {
    'prettier/prettier': 'error',

    // https://github.com/prettier/eslint-config-prettier#curly
    // prettier doesn't enforce {} with multiline
    curly: ['error', 'multi-line'],

    // https://github.com/prettier/eslint-config-prettier#quotes
    // prettier doesn't change backtick to single
    quotes: ['error', 'single', { avoidEscape: true }],
  },
};
<|endoftext|>