<commit_before>// Dependencies
var Fs = require("fs")
  , ArcAssembler = require("../lib")
  , Argv = require("yargs")
     .alias("s", "source")
     .alias("o", "output")
     .argv
  , Path = require("path")
  ;

// Constants
const INPUT_FILE = Path.resolve(process.cwd() + Argv.source)
    , OUTPUT_FILE = Path.resolve(process.cwd() + Argv.output)
    , HELP = "Usage: arc-asm [options]"
         + "\n"
         + "\nOptions:"
         + "\n  -h, --help                          Displays this help."
         + "\n  -v, --version                       Displays version information."
         + "\n  -s, --source <path/to/source/file>  Sets the source file path."
         + "\n  -o, --output <path/to/output/file>  Sets the output file path"
         + "\n"
         + "\nDocumentation can be found at https://github.com/IonicaBizau/arc-assembler"
    ;

// Invalid data
if (!Argv.source || !Arg.output) {
    console.log(HELP);
    process.exit(1);
}

// Create the write stream
var outputStream = Fs.createWriteStream(OUTPUT_FILE);

// Read the input file content
Fs.readFile(INPUT_FILE, "utf-8", function (err, content) {
    if (err) throw err;

    // Compile the input
    var result = ArcAssembler.compile(content);

    // Show some output
    result.raw.forEach(function (c) {
        console.log(c.code.match(/.{1,4}/g).join(" ") + " << Line " + c.line);
    });

    // Write things in the output stream
    outputStream.write("#!/usr/bin/env arc-int");
    outputStream.write(new Buffer(result.mCode));
    outputStream.end();

    // Make the file executable
    Fs.chmodSync(OUTPUT_FILE, 0755);
});
<commit_msg>Made the index.js executable<commit_after>// Dependencies
var Fs = require("fs")
  , ArcAssembler = require("../lib")
  , Argv = require("yargs")
     .alias("s", "source")
     .alias("o", "output")
     .argv
  , Path = require("path")
  ;

// Constants
const INPUT_FILE = Path.resolve(process.cwd() + Argv.source)
    , OUTPUT_FILE = Path.resolve(process.cwd() + Argv.output)
    , HELP = "Usage: arc-asm [options]"
         + "\n"
         + "\nOptions:"
         + "\n  -h, --help                          Displays this help."
         + "\n  -v, --version                       Displays version information."
         + "\n  -s, --source <path/to/source/file>  Sets the source file path."
         + "\n  -o, --output <path/to/output/file>  Sets the output file path"
         + "\n"
         + "\nDocumentation can be found at https://github.com/IonicaBizau/arc-assembler"
    ;

// Invalid data
if (!Argv.source || !Arg.output) {
    console.log(HELP);
    process.exit(1);
}

// Create the write stream
var outputStream = Fs.createWriteStream(OUTPUT_FILE);

// Read the input file content
Fs.readFile(INPUT_FILE, "utf-8", function (err, content) {
    if (err) throw err;

    // Compile the input
    var result = ArcAssembler.compile(content);

    // Show some output
    result.raw.forEach(function (c) {
        console.log(c.code.match(/.{1,4}/g).join(" ") + " << Line " + c.line);
    });

    // Write things in the output stream
    outputStream.write("#!/usr/bin/env arc-int");
    outputStream.write(new Buffer(result.mCode));
    outputStream.end();

    // Make the file executable
    Fs.chmodSync(OUTPUT_FILE, 0755);
});
<|endoftext|>


<commit_before>

/* globals jQuery, document */
(function($, undefined) {

    "use strict";

    var $document = $(document),
        $body = $("body"),
        version = $("link[rel=\"shortcut icon\"]").attr("href").split("?")[1];

    $.fn.titleLinks = function() {

        return $(this).each(function(k, v) {

            var $this = $(v),
                content = $this.html(),
                icons = {},
                link;

            icons.link = "<svg class=\"simicon-link\" role=\"presentation\">" +
                "<use xmlns:xlink=\"http://www.w3.org/1999/xlink\" " +
                "xlink:href=\"/assets/dist/img/svgdefs.svg" +
                "?" + version +
                "#simicon-link\"> " +
                "</use></svg>";

            icons.arrow = "<svg class=\"simicon-arrow-right\" role=\"presentation\">" +
                "<use xmlns:xlink=\"http://www.w3.org/1999/xlink\" " +
                "xlink:href=\"/assets/dist/img/svgdefs.svg" +
                "?" + version +
                "#simicon-arrow-right\"> " +
                "</use></svg>";

            link = "" + content + "";

            $this.html( icons.link + icons.arrow + link );

        });

    };

    $.fn.horizontalRules = function( settings ) {

        var defaults = {
            position: "after"
        }, opts, html;

        opts = $.extend( defaults, settings );
        html = "

";

        return $(this).each(function() {

            var $this = $(this);

            if ( opts.position === "after" ) {

                $this
                    .hide()
                    .after( html );

            } else if ( opts.position === "before" ) {

                $this
                    .hide()
                    .before( html );

            }

        });

    };

    $.fn.centerImages = function() {

        return $(this).each(function() {

            var $this = $(this);

            if ( $this.is("img") ) {

                $this
                    .parent("p")
                    .addClass("txt-c");

            }

        });

    };

    $document.ready(function() {

        var $post = $(".blog-post__content"),
            $titles = $post.find("h1,h2,h3,h4,h5"),
            $codes = $post.find("pre"),
            $hrs = $post.find("hr"),
            $imgs = $post.find("img"),

            guy,
            toggle = true;

        $post.fitVids();
        $titles.titleLinks();
        $codes.addClass("prettyprint");
        $hrs.horizontalRules();
        $imgs.centerImages();

        // error page fun thing.

        if ( $body.hasClass("error-page") ) {

            guy = setInterval(function() {

                if ( toggle ) {

                    $(".guy").html( "¯\\_( ツ)_/¯" );
                    toggle = false;

                } else {

                    $(".guy").html( "¯\\_(ツ )_/¯" );
                    toggle = true;

                }

            }, 1000 );

            $(".guy").on("click", function() {

                clearTimeout( guy );

            });

        }

    });

    // console easter egg.

    if ( window.console && console.warn && console.info && console.error ) {

        window.doge = function() {

            ga("send", "event", "doge", "wow amaze" );

            console.log(
                "%c░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░%c such secret %c░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░░░░░%c very javascript %c░░\n" +
                "░░░░░░░░░░░░░░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐░░%c many code %c░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░%c do hide %c░░▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▀▀░░░░░░░░░░░░░░░░%c wow! %c░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",

                "background: beige; color: slategray;",
                "color: #E64213;",
                "background: beige; color: slategray;",
                "color: #0BBF0B;",
                "background: beige; color: slategray;",
                "color: #A100FF;",
                "background: beige; color: slategray;",
                "color: #034BF6;",
                "background: beige; color: slategray;",
                "color: #F603D2;",
                "background: beige; color: slategray;"
            );
        };

        console.warn("******************************************");

        console.groupCollapsed(
            "%cBut do you even %cdoge();%c, bro?",
            "color: black;",
            "color: aquamarine; background: slategray; padding: 0.3em 0.5em",
            "color: black;" );

        console.log(" - http://github.com/simeydotme");
        console.log(" - http://twitter.com/simeydotme");

        console.groupEnd();

        console.warn("******************************************");

    }

})(jQuery);
<commit_msg>add tracking for social events<commit_after>

/* globals jQuery, document */
(function($, undefined) {

    "use strict";

    var $document = $(document),
        $body = $("body"),
        version = $("link[rel=\"shortcut icon\"]").attr("href").split("?")[1];

    $.fn.titleLinks = function() {

        return $(this).each(function(k, v) {

            var $this = $(v),
                content = $this.html(),
                icons = {},
                link;

            icons.link = "<svg class=\"simicon-link\" role=\"presentation\">" +
                "<use xmlns:xlink=\"http://www.w3.org/1999/xlink\" " +
                "xlink:href=\"/assets/dist/img/svgdefs.svg" +
                "?" + version +
                "#simicon-link\"> " +
                "</use></svg>";

            icons.arrow = "<svg class=\"simicon-arrow-right\" role=\"presentation\">" +
                "<use xmlns:xlink=\"http://www.w3.org/1999/xlink\" " +
                "xlink:href=\"/assets/dist/img/svgdefs.svg" +
                "?" + version +
                "#simicon-arrow-right\"> " +
                "</use></svg>";

            link = "" + content + "";

            $this.html( icons.link + icons.arrow + link );

        });

    };

    $.fn.horizontalRules = function( settings ) {

        var defaults = {
            position: "after"
        }, opts, html;

        opts = $.extend( defaults, settings );
        html = "

";

        return $(this).each(function() {

            var $this = $(this);

            if ( opts.position === "after" ) {

                $this
                    .hide()
                    .after( html );

            } else if ( opts.position === "before" ) {

                $this
                    .hide()
                    .before( html );

            }

        });

    };

    $.fn.centerImages = function() {

        return $(this).each(function() {

            var $this = $(this);

            if ( $this.is("img") ) {

                $this
                    .parent("p")
                    .addClass("txt-c");

            }

        });

    };

    $document.ready(function() {

        var $post = $(".blog-post__content"),
            $titles = $post.find("h1,h2,h3,h4,h5"),
            $codes = $post.find("pre"),
            $hrs = $post.find("hr"),
            $imgs = $post.find("img"),
            $socials = $(".social__item"),

            guy,
            toggle = true;

        $post.fitVids();
        $titles.titleLinks();
        $codes.addClass("prettyprint");
        $hrs.horizontalRules();
        $imgs.centerImages();

        // track the social links

        $socials.children(".social__link")

            .on("click mouseenter", function(e) {

                var which = $(this).parent().attr("class").replace("social__item / ", "");
                ga("send", "event", "social " + e.type , which );

            });

        // error page fun thing.

        if ( $body.hasClass("error-page") ) {

            guy = setInterval(function() {

                if ( toggle ) {

                    $(".guy").html( "¯\\_( ツ)_/¯" );
                    toggle = false;

                } else {

                    $(".guy").html( "¯\\_(ツ )_/¯" );
                    toggle = true;

                }

            }, 1000 );

            $(".guy").on("click", function() {

                clearTimeout( guy );

            });

        }

    });

    // console easter egg.

    if ( window.console && console.warn && console.info && console.error ) {

        window.doge = function() {

            ga("send", "event", "doge", "wow amaze" );

            console.log(
                "%c░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░%c such secret %c░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░░░░░%c very javascript %c░░\n" +
                "░░░░░░░░░░░░░░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐░░%c many code %c░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░%c do hide %c░░▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▀▀░░░░░░░░░░░░░░░░%c wow! %c░░░░░░░░░\n" +
                "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n",

                "background: beige; color: slategray;",
                "color: #E64213;",
                "background: beige; color: slategray;",
                "color: #0BBF0B;",
                "background: beige; color: slategray;",
                "color: #A100FF;",
                "background: beige; color: slategray;",
                "color: #034BF6;",
                "background: beige; color: slategray;",
                "color: #F603D2;",
                "background: beige; color: slategray;"
            );
        };

        console.warn("******************************************");

        console.groupCollapsed(
            "%cBut do you even %cdoge();%c, bro?",
            "color: black;",
            "color: aquamarine; background: slategray; padding: 0.3em 0.5em",
            "color: black;" );

        console.log(" - http://github.com/simeydotme");
        console.log(" - http://twitter.com/simeydotme");

        console.groupEnd();

        console.warn("******************************************");

    }

})(jQuery);
<|endoftext|>


<commit_before><commit_msg>Change the user's schema<commit_after><|endoftext|>


<commit_before>// example get request: http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=michael%20jackson&song=bad

var RapGenius = function() {

}

var artistsSongs = {
	'kanye west': ['stronger', 'jesus walks', 'through the wire', 'gold digger'],
	'eminem': ['lose yourself', 'not afraid', 'the real slim shady', 'rap god'],
	'rick ross': ['box chevy', '911', 'i\'m not a star', 'hold me back'],
	'schoolboy q': ['studio', 'collard greens', 'man of the year', 'hell of a night'],
	'tupac': ['life goes on', 'thugz mansion', 'hit em up', 'dear mama'],
	'snoop dogg': ['drop it like it\'s hot', 'i wanna rock', 'young, wild & free', 'doggy dogg world']
};

RapGenius.prototype.getRandomSong = function(artist) {
	var songs = artistsSongs[artist];
	var randIndex = Math.floor(Math.random() * songs.length);

	return songs[randIndex];
}

RapGenius.prototype.getLyric = function(artist) {
	var baseURL = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";

	var requestObj = {};
	requestObj.artist = artist;
	requestObj.song = this.getRandomSong(artist);

	var randomLyric = "";

	$.ajax({
		url: baseURL,
		data: requestObj,
		dataType: 'xml',
		success: function(data){
			var lyrics = data.Lyric.split('\n');
			var randIndex = Math.floor(Math.random() * lyrics.length);
			randomLyric = lyrics[randIndex];
			alert(data);
			return randomLyric;
		}
	});
}<commit_msg>trying ajax request again<commit_after>// example get request: http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=michael%20jackson&song=bad

var RapGenius = function() {

}

var artistsSongs = {
	'kanye west': ['stronger', 'jesus walks', 'through the wire', 'gold digger'],
	'eminem': ['lose yourself', 'not afraid', 'the real slim shady', 'rap god'],
	'rick ross': ['box chevy', '911', 'i\'m not a star', 'hold me back'],
	'schoolboy q': ['studio', 'collard greens', 'man of the year', 'hell of a night'],
	'tupac': ['life goes on', 'thugz mansion', 'hit em up', 'dear mama'],
	'snoop dogg': ['drop it like it\'s hot', 'i wanna rock', 'young, wild & free', 'doggy dogg world']
};

RapGenius.prototype.getRandomSong = function(artist) {
	var songs = artistsSongs[artist];
	var randIndex = Math.floor(Math.random() * songs.length);

	return songs[randIndex];
}

RapGenius.prototype.getLyric = function(artist) {
	var baseURL = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";

	var requestObj = {};
	requestObj.artist = artist;
	requestObj.song = this.getRandomSong(artist);

	var randomLyric = "";

	$.ajax({
		url: baseURL,
		data: requestObj,
		dataType: 'xml',
		success: function(data){
			var lyrics = data.Lyric.split('\n');
			var randIndex = Math.floor(Math.random() * lyrics.length);
			randomLyric = lyrics[randIndex];
			alert(data);
			return randomLyric;
		},
		error: function(error) {
			this.getLyric(artist);
		}
	});
}<|endoftext|>


<commit_before>$(document).ready(function(){
	$("#horario1").click(function(event){
		$("#complejos1").toggle();
	});
});<commit_msg>Muestra los complejos donde se muestra una película<commit_after>$(document).ready(function(){
		$( ".date" ).each(function() {
		$(this).click(function(){
			var number = $(this).attr("id").slice(7);

			var item = $("#complejos" + number);
			$(".complejos:visible").toggle();
			item.toggle();
		});
	});

});<|endoftext|>


<commit_before>import { click, findAll, visit, waitUntil } from '@ember/test-helpers';
import { setupTransitionTest } from '../helpers/integration';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { macroCondition, dependencySatisfies } from '@embroider/macros';
import { gte } from 'ember-compatibility-helpers';

module('Acceptance: Scenarios', function (hooks) {
  setupApplicationTest(hooks);
  setupTransitionTest(hooks);

  test('nested liquid-outlets wait for their ancestors to animate', async function (assert) {
    await visit('/scenarios/nested-outlets/middle/inner');

    // deliberately not waiting so we can observe during the transition
    visit('/scenarios/nested-outlets/middle2');

    assert
      .dom('#inner-index')
      .exists({ count: 1 }, 'inner view exists during animation');
  });

  test('inner nested liquid-outlets can animate', async function (assert) {
    await visit('/scenarios/nested-outlets/middle/inner');
    await visit('/scenarios/nested-outlets/middle');
    assert.ranTransition('fade');
  });

  // named outlets are deprecated in ember starting at 3.27.
  if (macroCondition(dependencySatisfies('ember-source', '<=3.26.0'))) {
    test('liquid-outlet animate by outlet name', async function (assert) {
      await visit('/scenarios/in-test-outlet');
      assert.ranTransition('toLeft');
    });
  }

  if (!gte('4.0.0')) {
    test('model-dependent transitions are matching correctly', async function (assert) {
      await visit('/scenarios/model-dependent-rule/1');
      assert.ranTransition('toLeft');
      await click(
        [...document.querySelectorAll('a')].find(
          (elt) => elt.textContent.trim() === 'Previous'
        )
      );
      assert.ranTransition('toRight');
    });
  }

  test('nested transitions with explode properly hide children', async function (assert) {
    await visit('/scenarios/nested-explode-transition');

    click(
      [...document.querySelectorAll('button')].find(
        (elt) => elt.textContent.trim() === 'Toggle One/Two'
      )
    );

    await waitUntil(
      function () {
        let twos = findAll('.child-two');
        return (
          twos.length === 2 &&
          twos.filter((elt) => getComputedStyle(elt).visibility === 'visible')
            .length === 1
        );
      },
      { timeout: 2000 }
    );

    assert
      .dom('.child-one-a')
      .exists({ count: 2 }, 'explode transition clones child-one');

    let [first, second] = [...document.querySelectorAll('.child-one-a')];
    assert
      .dom(first)
      .hasStyle({ visibility: 'hidden' }, 'even nested children are hidden');
    assert
      .dom(second)
      .hasStyle(
        { visibility: 'visible' },
        'nested children of clone are visible'
      );

    let [twoFirst, twoSecond] = [...document.querySelectorAll('.child-two')];
    assert
      .dom('.child-two')
      .exists({ count: 2 }, 'explode transition clones child-two');
    assert
      .dom(twoFirst)
      .hasStyle({ visibility: 'hidden' }, 'original child-two is hidden');
    assert
      .dom(twoSecond)
      .hasStyle({ visibility: 'visible' }, 'cloned child-two is visible');
  });
});
<commit_msg>Skip test<commit_after>import { click, findAll, visit, waitUntil } from '@ember/test-helpers';
import { setupTransitionTest } from '../helpers/integration';
import { module, skip, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { macroCondition, dependencySatisfies } from '@embroider/macros';

module('Acceptance: Scenarios', function (hooks) {
  setupApplicationTest(hooks);
  setupTransitionTest(hooks);

  test('nested liquid-outlets wait for their ancestors to animate', async function (assert) {
    await visit('/scenarios/nested-outlets/middle/inner');

    // deliberately not waiting so we can observe during the transition
    visit('/scenarios/nested-outlets/middle2');

    assert
      .dom('#inner-index')
      .exists({ count: 1 }, 'inner view exists during animation');
  });

  test('inner nested liquid-outlets can animate', async function (assert) {
    await visit('/scenarios/nested-outlets/middle/inner');
    await visit('/scenarios/nested-outlets/middle');
    assert.ranTransition('fade');
  });

  // named outlets are deprecated in ember starting at 3.27.
  if (macroCondition(dependencySatisfies('ember-source', '<=3.26.0'))) {
    test('liquid-outlet animate by outlet name', async function (assert) {
      await visit('/scenarios/in-test-outlet');
      assert.ranTransition('toLeft');
    });
  }

  skip('model-dependent transitions are matching correctly', async function (assert) {
    await visit('/scenarios/model-dependent-rule/1');
    assert.ranTransition('toLeft');
    await click(
      [...document.querySelectorAll('a')].find(
        (elt) => elt.textContent.trim() === 'Previous'
      )
    );
    assert.ranTransition('toRight');
  });

  test('nested transitions with explode properly hide children', async function (assert) {
    await visit('/scenarios/nested-explode-transition');

    click(
      [...document.querySelectorAll('button')].find(
        (elt) => elt.textContent.trim() === 'Toggle One/Two'
      )
    );

    await waitUntil(
      function () {
        let twos = findAll('.child-two');
        return (
          twos.length === 2 &&
          twos.filter((elt) => getComputedStyle(elt).visibility === 'visible')
            .length === 1
        );
      },
      { timeout: 2000 }
    );

    assert
      .dom('.child-one-a')
      .exists({ count: 2 }, 'explode transition clones child-one');

    let [first, second] = [...document.querySelectorAll('.child-one-a')];
    assert
      .dom(first)
      .hasStyle({ visibility: 'hidden' }, 'even nested children are hidden');
    assert
      .dom(second)
      .hasStyle(
        { visibility: 'visible' },
        'nested children of clone are visible'
      );

    let [twoFirst, twoSecond] = [...document.querySelectorAll('.child-two')];
    assert
      .dom('.child-two')
      .exists({ count: 2 }, 'explode transition clones child-two');
    assert
      .dom(twoFirst)
      .hasStyle({ visibility: 'hidden' }, 'original child-two is hidden');
    assert
      .dom(twoSecond)
      .hasStyle({ visibility: 'visible' }, 'cloned child-two is visible');
  });
});
<|endoftext|>


<commit_before><commit_msg>Update Provider.js (#64)<commit_after><|endoftext|>


<commit_before>/*
 * c_cpp.js
 *
 * Copyright (C) 2009-12 by RStudio, Inc.
 *
 * The Original Code is Ajax.org Code Editor (ACE).
 *
 * The Initial Developer of the Original Code is
 * Ajax.org B.V.
 * Portions created by the Initial Developer are Copyright (C) 2010
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *      Fabian Jakobs <fabian AT ajax DOT org>
 *      Gastón Kleiman <gaston.kleiman AT gmail DOT com>
 *
 * Based on Bespin's C/C++ Syntax Plugin by Marc McIntyre.
 *
 * This program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

define("mode/c_cpp", function(require, exports, module) {

var oop = require("ace/lib/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var c_cppHighlightRules = require("mode/c_cpp_highlight_rules").c_cppHighlightRules;

var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Range = require("ace/range").Range;
var CstyleBehaviour = require("ace/mode/behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("ace/mode/folding/cstyle").FoldMode;

var SweaveBackgroundHighlighter = require("mode/sweave_background_highlighter").SweaveBackgroundHighlighter;

var Mode = function(suppressHighlighting, doc, session) {
    this.$session = session;
    this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
    this.$outdent = new MatchingBraceOutdent();
    this.$behaviour = new CstyleBehaviour();
    this.$sweaveBackgroundHighlighter = new SweaveBackgroundHighlighter(
        session,
        /^\s*\/\*{3}\s*R\s*$/,
        /^\*\/$/,
        true);
    this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);

(function() {

    this.toggleCommentLines = function(state, doc, startRow, endRow) {
        var outdent = true;
        var re = /^(\s*)\/\//;

        for (var i=startRow; i<= endRow; i++) {
            if (!re.test(doc.getLine(i))) {
                outdent = false;
                break;
            }
        }

        if (outdent) {
            var deleteRange = new Range(0, 0, 0, 0);
            for (var i=startRow; i<= endRow; i++)
            {
                var line = doc.getLine(i);
                var m = line.match(re);
                deleteRange.start.row = i;
                deleteRange.end.row = i;
                deleteRange.end.column = m[0].length;
                doc.replace(deleteRange, m[1]);
            }
        }
        else {
            doc.indentRows(startRow, endRow, "//");
        }
    };

    this.getLanguageMode = function(position)
    {
      return this.$session.getState(position.row).match(/^r-/) ? 'R' : 'C_CPP';
    };

    this.getNextLineIndent = function(state, line, tab) {
        var indent = this.$getIndent(line);

        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
        var tokens = tokenizedLine.tokens;
        var endState = tokenizedLine.state;

        if (tokens.length && tokens[tokens.length-1].type == "comment") {
            return indent;
        }

        if (state == "start") {
            var match = line.match(/^.*[\{\(\[]\s*$/);
            if (match) {
                indent += tab;
            }
        } else if (state == "doc-start") {
            if (endState == "start") {
                return "";
            }
            var match = line.match(/^\s*(\/?)\*/);
            if (match) {
                if (match[1]) {
                    indent += " ";
                }
                indent += "* ";
            }
        }

        return indent;
    };

    this.checkOutdent = function(state, line, input) {
        return this.$outdent.checkOutdent(line, input);
    };

    this.autoOutdent = function(state, doc, row) {
        this.$outdent.autoOutdent(doc, row);
    };

    this.transformAction = function(state, action, editor, session, text) {
       if (action === 'insertion' && text === "\n") {
          // If newline in a doxygen comment, continue the comment
          var pos = editor.getSelectionRange().start;
          var match = /^((\s*\/\/+')\s*)/.exec(session.doc.getLine(pos.row));
          if (match && editor.getSelectionRange().start.column >= match[2].length) {
             return {text: "\n" + match[1]};
          }
       }
       return false;
    };

}).call(Mode.prototype);

exports.Mode = Mode;
});
<commit_msg>add chunk info for cpp editor mode<commit_after>/*
 * c_cpp.js
 *
 * Copyright (C) 2009-12 by RStudio, Inc.
 *
 * The Original Code is Ajax.org Code Editor (ACE).
 *
 * The Initial Developer of the Original Code is
 * Ajax.org B.V.
 * Portions created by the Initial Developer are Copyright (C) 2010
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *      Fabian Jakobs <fabian AT ajax DOT org>
 *      Gastón Kleiman <gaston.kleiman AT gmail DOT com>
 *
 * Based on Bespin's C/C++ Syntax Plugin by Marc McIntyre.
 *
 * This program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

define("mode/c_cpp", function(require, exports, module) {

var oop = require("ace/lib/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var c_cppHighlightRules = require("mode/c_cpp_highlight_rules").c_cppHighlightRules;

var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Range = require("ace/range").Range;
var CstyleBehaviour = require("ace/mode/behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("ace/mode/folding/cstyle").FoldMode;

var SweaveBackgroundHighlighter = require("mode/sweave_background_highlighter").SweaveBackgroundHighlighter;

var Mode = function(suppressHighlighting, doc, session) {
    this.$session = session;
    this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
    this.$outdent = new MatchingBraceOutdent();
    this.$behaviour = new CstyleBehaviour();
    this.$sweaveBackgroundHighlighter = new SweaveBackgroundHighlighter(
        session,
        /^\s*\/\*{3}\s*R\s*$/,
        /^\*\/$/,
        true);
    this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);

(function() {

    this.toggleCommentLines = function(state, doc, startRow, endRow) {
        var outdent = true;
        var re = /^(\s*)\/\//;

        for (var i=startRow; i<= endRow; i++) {
            if (!re.test(doc.getLine(i))) {
                outdent = false;
                break;
            }
        }

        if (outdent) {
            var deleteRange = new Range(0, 0, 0, 0);
            for (var i=startRow; i<= endRow; i++)
            {
                var line = doc.getLine(i);
                var m = line.match(re);
                deleteRange.start.row = i;
                deleteRange.end.row = i;
                deleteRange.end.column = m[0].length;
                doc.replace(deleteRange, m[1]);
            }
        }
        else {
            doc.indentRows(startRow, endRow, "//");
        }
    };

    this.getLanguageMode = function(position)
    {
      return this.$session.getState(position.row).match(/^r-/) ? 'R' : 'C_CPP';
    };

    this.insertChunkInfo = {
        value: "/*** R\n\n*/\n",
        position: {row: 1, column: 0}
    };

    this.getNextLineIndent = function(state, line, tab) {
        var indent = this.$getIndent(line);

        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
        var tokens = tokenizedLine.tokens;
        var endState = tokenizedLine.state;

        if (tokens.length && tokens[tokens.length-1].type == "comment") {
            return indent;
        }

        if (state == "start") {
            var match = line.match(/^.*[\{\(\[]\s*$/);
            if (match) {
                indent += tab;
            }
        } else if (state == "doc-start") {
            if (endState == "start") {
                return "";
            }
            var match = line.match(/^\s*(\/?)\*/);
            if (match) {
                if (match[1]) {
                    indent += " ";
                }
                indent += "* ";
            }
        }

        return indent;
    };

    this.checkOutdent = function(state, line, input) {
        return this.$outdent.checkOutdent(line, input);
    };

    this.autoOutdent = function(state, doc, row) {
        this.$outdent.autoOutdent(doc, row);
    };

    this.transformAction = function(state, action, editor, session, text) {
       if (action === 'insertion' && text === "\n") {
          // If newline in a doxygen comment, continue the comment
          var pos = editor.getSelectionRange().start;
          var match = /^((\s*\/\/+')\s*)/.exec(session.doc.getLine(pos.row));
          if (match && editor.getSelectionRange().start.column >= match[2].length) {
             return {text: "\n" + match[1]};
          }
       }
       return false;
    };

}).call(Mode.prototype);

exports.Mode = Mode;
});
<|endoftext|>


<commit_before><commit_msg>fix handleValueChange method<commit_after><|endoftext|>


<commit_before>module.exports = create;

create.usage = "\trappidjs create lib <libName> [<dir>] - Creates a rappidjs lib directory structure"
    + "\n\trappidjs create app <AppName> [<dir>] - Creates empty rappidjs application";

var fs = require("fs"),
    path = require("path"),
    flow = require("flow.js").flow,
    ejs = require('ejs'),
    args = process.argv.splice(2),
    rl = require("readline"),
    install = require(path.join(__dirname, "install.js"));

fs.existsSync || (fs.existsSync = path.existsSync);

var Helper = {
    template: function (source, destination, options) {
        var data = fs.readFileSync(source, "utf8");
        fs.writeFileSync(destination, this.render(data, options));

    },
    render: function (string, options) {
        if (options == null) options = {};
        return ejs.render(string, options);
    },
    copy: function (source, destination) {
        var data = fs.readFileSync(source, "utf8");
        fs.writeFileSync(destination, data);
    },
    copyDirectory: function (srcDir, targetDir, callback) {
        var subDirs = [], files = [];
        if (!fs.existsSync(targetDir)) {
            fs.mkdirSync(targetDir);
        }
        var source, dest;
        fs.readdirSync(srcDir).forEach(function (name) {

            source = path.join(srcDir, name);
            dest = path.join(targetDir, name);
            var stat = fs.statSync(source);
            if (name.indexOf(".") !== 0) {
                if (stat.isDirectory()) {
                    subDirs.push(name);
                } else if (stat.isFile() || stat.isSymbolicLink()) {
                    files.push({
                        src: source,
                        dst: dest
                    });

                }
            }
        });

        flow()
            .seqEach(files, function (file, cb) {
                var inStr = fs.createReadStream(file.src);
                var outStr = fs.createWriteStream(file.dst);

                inStr.on('end', function () {
                    outStr.end();
                    cb();
                });

                inStr.pipe(outStr);
            })
            .seq(function (cb) {
                if (subDirs.length) {
                    subDirs.forEach(function (dirName) {
                        source = path.join(srcDir, dirName);
                        dest = path.join(targetDir, dirName);

                        Helper.copyDirectory(source, dest, cb);
                    });
                } else {
                    cb();
                }

            })
            .exec(callback);
    }
};

fs.mkdirIfNotExist = function (dirPath) {
    if (!fs.existsSync(dirPath)) {
        fs.mkdirSync(dirPath);
    }
};

fs.mkdirParent = function (dirPath) {
    if (!fs.existsSync(dirPath)) {
        var parentDir = path.normalize(path.join(dirPath, ".."));
        if (!fs.existsSync(parentDir)) {
            fs.mkdirParent(parentDir);
        }

        fs.mkdirSync(dirPath);
    }
};

function createDirectories(directories, where) {
    for (var i = 0; i < directories.length; i++) {
        fs.mkdirIfNotExist(path.join(where, directories[i]));
    }
}

function create(args, callback) {
    if (args.length === 0) {
        callback("No args defined");
    }

    var cmd = args.shift();

    var dir = process.cwd();
    var name = args.shift();
    if (args.length > 0) {
        dir = args.shift();
    }

    dir = path.resolve(dir.replace(/^~\//, process.env.HOME + '/'));

    if (cmd == "lib" || cmd == "library") {
        createLibrary(name, dir, callback);
    } else if (cmd == "app" || cmd == "application") {
        createApplication(name, dir, callback);
    } else {
        callback(true);
    }
}

function createLibrary(libName, dir, callback) {
    dir = dir || process.cwd();

    fs.mkdirParent(dir);

    // create directories
    var dirs = ["bin", "doc", "test", libName, "xsd"];
    createDirectories(dirs, dir);

    Helper.template(path.join(__dirname, "templates", "package.json"), path.join(dir, libName, "package.json"), {name: libName, type: "lib"});
}

function createApplication(appName, dir, callback) {

    dir = dir || process.cwd();

    fs.mkdirParent(dir);

    if (!fs.existsSync(dir)) {
        callback("Directory " + dir + " could not be created");
    }

    if (appName) {
        // create sub directories
        var subDirs = ["bin", "doc", "test", "public", "xsd", "server", "node_modules"];

        // create sub directories
        createDirectories(subDirs, dir);

        // make first character of appName UPPERCASE
        appName = appName.charAt(0).toUpperCase() + appName.substr(1);

        var publicDir = path.join(dir, "public");
        var serverDir = path.join(dir, "server");

        // create app directory in public
        var appDir = path.join(publicDir, "app");
        var webDir = path.join(serverDir, "web");

        fs.mkdirIfNotExist(appDir);
        fs.mkdirIfNotExist(webDir);

        var serverAppDir = path.join(serverDir, "app");
        if (!fs.existsSync(serverAppDir)) {
            var relativePath = path.join(path.relative(serverDir, publicDir), "app");
            fs.symlinkSync(relativePath, serverAppDir, 'dir');
        }

        createDirectories(["collection", "model", "view", "locale", "module"], appDir);
        // do the templating stuff

        // scaffold index.html
        Helper.template(path.join(__dirname, "templates", "index.html"), path.join(publicDir, "index.html"), {appName: appName});

        // scaffold app/<AppName>.xml
        Helper.template(path.join(__dirname, "templates", "app", "App.xml"), path.join(publicDir, "app", appName + ".xml"), {appName: appName});
        // scaffold app/<AppName>Class.xml
        Helper.template(path.join(__dirname, "templates", "app", "AppClass.js"), path.join(publicDir, "app", appName + "Class.js"), {appName: appName});

        Helper.template(path.join(__dirname, "templates", "package.json"), path.join(dir, "package.json"), {name: appName, type: "app"});

        // add server xml
        Helper.template(path.join(__dirname, "templates", "Server.xml"), path.join(webDir, "Server.xml"), {});

        var rappidPath = path.join(fs.readlinkSync(process.argv[1]), "../..");

        Helper.copyDirectory(path.join(rappidPath, "node_modules"), path.join(dir, "node_modules"), function () {
            install(["rAppid.js", "latest", dir], function (err) {
                if (!err) {
                    // link config json
                    var configPath = path.join(serverDir, "config.json");
                    if (!fs.existsSync(configPath)) {
                        var relativePath = path.join(path.relative(serverDir, publicDir), "config.json");
                        fs.symlinkSync(relativePath, configPath);
                    }

                    // scaffold default app directory structure
                    console.log("");
                    console.log("Application '" + appName + "' in directory '" + publicDir + "' successfully created.");
                    console.log("");
                } else {
                    callback(err)
                }
            })
        });

    }
}<commit_msg>fixed resolving rappidjs path<commit_after>module.exports = create;

create.usage = "\trappidjs create lib <libName> [<dir>] - Creates a rappidjs lib directory structure"
    + "\n\trappidjs create app <AppName> [<dir>] - Creates empty rappidjs application";

var fs = require("fs"),
    path = require("path"),
    flow = require("flow.js").flow,
    ejs = require('ejs'),
    args = process.argv.splice(2),
    rl = require("readline"),
    install = require(path.join(__dirname, "install.js"));

fs.existsSync || (fs.existsSync = path.existsSync);

var Helper = {
    template: function (source, destination, options) {
        var data = fs.readFileSync(source, "utf8");
        fs.writeFileSync(destination, this.render(data, options));

    },
    render: function (string, options) {
        if (options == null) options = {};
        return ejs.render(string, options);
    },
    copy: function (source, destination) {
        var data = fs.readFileSync(source, "utf8");
        fs.writeFileSync(destination, data);
    },
    copyDirectory: function (srcDir, targetDir, callback) {
        var subDirs = [], files = [];
        if (!fs.existsSync(targetDir)) {
            fs.mkdirSync(targetDir);
        }
        var source, dest;
        fs.readdirSync(srcDir).forEach(function (name) {

            source = path.join(srcDir, name);
            dest = path.join(targetDir, name);
            var stat = fs.statSync(source);
            if (name.indexOf(".") !== 0) {
                if (stat.isDirectory()) {
                    subDirs.push(name);
                } else if (stat.isFile() || stat.isSymbolicLink()) {
                    files.push({
                        src: source,
                        dst: dest
                    });

                }
            }
        });

        flow()
            .seqEach(files, function (file, cb) {
                var inStr = fs.createReadStream(file.src);
                var outStr = fs.createWriteStream(file.dst);

                inStr.on('end', function () {
                    outStr.end();
                    cb();
                });

                inStr.pipe(outStr);
            })
            .seq(function (cb) {
                if (subDirs.length) {
                    subDirs.forEach(function (dirName) {
                        source = path.join(srcDir, dirName);
                        dest = path.join(targetDir, dirName);

                        Helper.copyDirectory(source, dest, cb);
                    });
                } else {
                    cb();
                }

            })
            .exec(callback);
    }
};

fs.mkdirIfNotExist = function (dirPath) {
    if (!fs.existsSync(dirPath)) {
        fs.mkdirSync(dirPath);
    }
};

fs.mkdirParent = function (dirPath) {
    if (!fs.existsSync(dirPath)) {
        var parentDir = path.normalize(path.join(dirPath, ".."));
        if (!fs.existsSync(parentDir)) {
            fs.mkdirParent(parentDir);
        }

        fs.mkdirSync(dirPath);
    }
};

function createDirectories(directories, where) {
    for (var i = 0; i < directories.length; i++) {
        fs.mkdirIfNotExist(path.join(where, directories[i]));
    }
}

function create(args, callback) {
    if (args.length === 0) {
        callback("No args defined");
    }

    var cmd = args.shift();

    var dir = process.cwd();
    var name = args.shift();
    if (args.length > 0) {
        dir = args.shift();
    }

    dir = path.resolve(dir.replace(/^~\//, process.env.HOME + '/'));

    if (cmd == "lib" || cmd == "library") {
        createLibrary(name, dir, callback);
    } else if (cmd == "app" || cmd == "application") {
        createApplication(name, dir, callback);
    } else {
        callback(true);
    }
}

function createLibrary(libName, dir, callback) {
    dir = dir || process.cwd();

    fs.mkdirParent(dir);

    // create directories
    var dirs = ["bin", "doc", "test", libName, "xsd"];
    createDirectories(dirs, dir);

    Helper.template(path.join(__dirname, "templates", "package.json"), path.join(dir, libName, "package.json"), {name: libName, type: "lib"});
}

function createApplication(appName, dir, callback) {

    dir = dir || process.cwd();

    fs.mkdirParent(dir);

    if (!fs.existsSync(dir)) {
        callback("Directory " + dir + " could not be created");
    }

    if (appName) {
        // create sub directories
        var subDirs = ["bin", "doc", "test", "public", "xsd", "server", "node_modules"];

        // create sub directories
        createDirectories(subDirs, dir);

        // make first character of appName UPPERCASE
        appName = appName.charAt(0).toUpperCase() + appName.substr(1);

        var publicDir = path.join(dir, "public");
        var serverDir = path.join(dir, "server");

        // create app directory in public
        var appDir = path.join(publicDir, "app");
        var webDir = path.join(serverDir, "web");

        fs.mkdirIfNotExist(appDir);
        fs.mkdirIfNotExist(webDir);

        var serverAppDir = path.join(serverDir, "app");
        if (!fs.existsSync(serverAppDir)) {
            var relativePath = path.join(path.relative(serverDir, publicDir), "app");
            fs.symlinkSync(relativePath, serverAppDir, 'dir');
        }

        createDirectories(["collection", "model", "view", "locale", "module"], appDir);
        // do the templating stuff

        // scaffold index.html
        Helper.template(path.join(__dirname, "templates", "index.html"), path.join(publicDir, "index.html"), {appName: appName});

        // scaffold app/<AppName>.xml
        Helper.template(path.join(__dirname, "templates", "app", "App.xml"), path.join(publicDir, "app", appName + ".xml"), {appName: appName});
        // scaffold app/<AppName>Class.xml
        Helper.template(path.join(__dirname, "templates", "app", "AppClass.js"), path.join(publicDir, "app", appName + "Class.js"), {appName: appName});

        Helper.template(path.join(__dirname, "templates", "package.json"), path.join(dir, "package.json"), {name: appName, type: "app"});

        // add server xml
        Helper.template(path.join(__dirname, "templates", "Server.xml"), path.join(webDir, "Server.xml"), {});

        var rappidPath = path.join(fs.realpathSync(process.argv[1]), "../..");

        Helper.copyDirectory(path.join(rappidPath, "node_modules"), path.join(dir, "node_modules"), function () {
            install(["rAppid.js", "latest", dir], function (err) {
                if (!err) {
                    // link config json
                    var configPath = path.join(serverDir, "config.json");
                    if (!fs.existsSync(configPath)) {
                        var relativePath = path.join(path.relative(serverDir, publicDir), "config.json");
                        fs.symlinkSync(relativePath, configPath);
                    }

                    // scaffold default app directory structure
                    console.log("");
                    console.log("Application '" + appName + "' in directory '" + publicDir + "' successfully created.");
                    console.log("");
                } else {
                    callback(err)
                }
            })
        });

    }
}<|endoftext|>


<commit_before>import $ from 'jquery';

// the taskId to assign to the next task added via addTask()
let nextTaskId = 0;

// array of queued tasks sorted with highest priority task first
const tasks = [];

// array of web workers to dispatch decode tasks to
const webWorkers = [];

const defaultConfig = {
  maxWebWorkers: navigator.hardwareConcurrency || 1,
  startWebWorkersOnDemand: true,
  webWorkerPath: '../../dist/cornerstoneWADOImageLoaderWebWorker.js',
  webWorkerTaskPaths: [],
  taskConfiguration: {
    decodeTask: {
      loadCodecsOnStartup: true,
      initializeCodecsOnStartup: false,
      codecsPath: '../dist/cornerstoneWADOImageLoaderCodecs.js',
      usePDFJS: false
    }
  }
};

let config;

const statistics = {
  maxWebWorkers: 0,
  numWebWorkers: 0,
  numTasksQueued: 0,
  numTasksExecuting: 0,
  numTasksCompleted: 0,
  totalTaskTimeInMS: 0,
  totalTimeDelayedInMS: 0
};

/**
 * Function to start a task on a web worker
 */
function startTaskOnWebWorker () {
  // return immediately if no decode tasks to do
  if (!tasks.length) {
    return;
  }

  // look for a web worker that is ready
  for (let i = 0; i < webWorkers.length; i++) {
    if (webWorkers[i].status === 'ready') {
      // mark it as busy so tasks are not assigned to it
      webWorkers[i].status = 'busy';

      // get the highest priority task
      const task = tasks.shift();

      task.start = new Date().getTime();

      // update stats with how long this task was delayed (waiting in queue)
      const end = new Date().getTime();

      statistics.totalTimeDelayedInMS += end - task.added;

      // assign this task to this web worker and send the web worker
      // a message to execute it
      webWorkers[i].task = task;
      webWorkers[i].worker.postMessage({
        taskType: task.taskType,
        workerIndex: i,
        data: task.data
      }, task.transferList);
      statistics.numTasksExecuting++;

      return;
    }
  }

  // if no available web workers and we haven't started max web workers, start a new one
  if (webWorkers.length < config.maxWebWorkers) {
    spawnWebWorker();
  }
}

/**
 * Function to handle a message from a web worker
 * @param msg
 */
function handleMessageFromWorker (msg) {
  // console.log('handleMessageFromWorker', msg.data);
  if (msg.data.taskType === 'initialize') {
    webWorkers[msg.data.workerIndex].status = 'ready';
    startTaskOnWebWorker();
  } else {
    statistics.numTasksExecuting--;
    webWorkers[msg.data.workerIndex].status = 'ready';
    statistics.numTasksCompleted++;
    const end = new Date().getTime();

    statistics.totalTaskTimeInMS += end - webWorkers[msg.data.workerIndex].task.start;
    webWorkers[msg.data.workerIndex].task.deferred.resolve(msg.data.result);
    webWorkers[msg.data.workerIndex].task = undefined;
    startTaskOnWebWorker();
  }
}

/**
 * Spawns a new web worker
 */
function spawnWebWorker () {
  // prevent exceeding maxWebWorkers
  if (webWorkers.length >= config.maxWebWorkers) {
    return;
  }

  // spawn the webworker
  const worker = new Worker(config.webWorkerPath);

  webWorkers.push({
    worker,
    status: 'initializing'
  });
  worker.addEventListener('message', handleMessageFromWorker);
  worker.postMessage({
    taskType: 'initialize',
    workerIndex: webWorkers.length - 1,
    config
  });
}

/**
 * Initialization function for the web worker manager - spawns web workers
 * @param configObject
 */
function initialize (configObject) {
  configObject = configObject || defaultConfig;

  // prevent being initialized more than once
  if (config) {
    throw new Error('WebWorkerManager already initialized');
  }

  config = configObject;

  config.maxWebWorkers = config.maxWebWorkers || (navigator.hardwareConcurrency || 1);

  // Spawn new web workers
  if (!config.startWebWorkersOnDemand) {
    for (let i = 0; i < config.maxWebWorkers; i++) {
      spawnWebWorker();
    }
  }
}

/**
 * dynamically loads a web worker task
 * @param sourcePath
 * @param taskConfig
 */
function loadWebWorkerTask (sourcePath, taskConfig) {
  // add it to the list of web worker tasks paths so on demand web workers
  // load this properly
  config.webWorkerTaskPaths.push(sourcePath);

  // if a task specific configuration is provided, merge it into the config
  if (taskConfig) {
    config.taskConfiguration = Object.assign(config.taskConfiguration, taskConfig);
  }

  // tell each spawned web worker to load this task
  for (let i = 0; i < webWorkers.length; i++) {
    webWorkers[i].worker.postMessage({
      taskType: 'loadWebWorkerTask',
      workerIndex: webWorkers.length - 1,
      sourcePath,
      config
    });
  }
}

/**
 * Function to add a decode task to be performed
 *
 * @param taskType - the taskType for this task
 * @param data - data specific to the task
 * @param priority - optional priority of the task (defaults to 0), > 0 is higher, < 0 is lower
 * @param transferList - optional array of data to transfer to web worker
 * @returns {*}
 */
function addTask (taskType, data, priority, transferList) {
  if (!config) {
    initialize();
  }

  priority = priority || 0;
  const deferred = $.Deferred();

  // find the right spot to insert this decode task (based on priority)
  let i;

  for (i = 0; i < tasks.length; i++) {
    if (tasks[i].priority <= priority) {
      break;
    }
  }

  const taskId = nextTaskId++;

  // insert the decode task at position i
  tasks.splice(i, 0, {
    taskId,
    taskType,
    status: 'ready',
    added: new Date().getTime(),
    data,
    deferred,
    priority,
    transferList
  });

  // try to start a task on the web worker since we just added a new task and a web worker may be available
  startTaskOnWebWorker();

  return {
    taskId,
    promise: deferred.promise()
  };
}

/**
 * Changes the priority of a queued task
 * @param taskId - the taskId to change the priority of
 * @param priority - priority of the task (defaults to 0), > 0 is higher, < 0 is lower
 * @returns boolean - true on success, false if taskId not found
 */
function setTaskPriority (taskId, priority) {
  // search for this taskId
  for (let i = 0; i < tasks.length; i++) {
    if (tasks[i].taskId === taskId) {
      // taskId found, remove it
      const task = tasks.splice(i, 1)[0];

      // set its prioirty
      task.priority = priority;

      // find the right spot to insert this decode task (based on priority)
      for (i = 0; i < tasks.length; i++) {
        if (tasks[i].priority <= priority) {
          break;
        }
      }

      // insert the decode task at position i
      tasks.splice(i, 0, task);

      return true;
    }
  }

  return false;
}

/**
 * Cancels a queued task and rejects
 * @param taskId - the taskId to cancel
 * @param reason - optional reason the task was rejected
 * @returns boolean - true on success, false if taskId not found
 */
function cancelTask (taskId, reason) {
  // search for this taskId
  for (let i = 0; i < tasks.length; i++) {
    if (tasks[i].taskId === taskId) {
      // taskId found, remove it
      const task = tasks.splice(i, 1);

      task.promise.reject(reason);

      return true;
    }
  }

  return false;
}

/**
 * Function to return the statistics on running web workers
 * @returns object containing statistics
 */
function getStatistics () {
  statistics.maxWebWorkers = config.maxWebWorkers;
  statistics.numWebWorkers = webWorkers.length;
  statistics.numTasksQueued = tasks.length;

  return statistics;
}

export default {
  initialize,
  loadWebWorkerTask,
  addTask,
  getStatistics,
  setTaskPriority,
  cancelTask
};
<commit_msg>Set web worker status ready after reading its task<commit_after>import $ from 'jquery';

// the taskId to assign to the next task added via addTask()
let nextTaskId = 0;

// array of queued tasks sorted with highest priority task first
const tasks = [];

// array of web workers to dispatch decode tasks to
const webWorkers = [];

const defaultConfig = {
  maxWebWorkers: navigator.hardwareConcurrency || 1,
  startWebWorkersOnDemand: true,
  webWorkerPath: '../../dist/cornerstoneWADOImageLoaderWebWorker.js',
  webWorkerTaskPaths: [],
  taskConfiguration: {
    decodeTask: {
      loadCodecsOnStartup: true,
      initializeCodecsOnStartup: false,
      codecsPath: '../dist/cornerstoneWADOImageLoaderCodecs.js',
      usePDFJS: false
    }
  }
};

let config;

const statistics = {
  maxWebWorkers: 0,
  numWebWorkers: 0,
  numTasksQueued: 0,
  numTasksExecuting: 0,
  numTasksCompleted: 0,
  totalTaskTimeInMS: 0,
  totalTimeDelayedInMS: 0
};

/**
 * Function to start a task on a web worker
 */
function startTaskOnWebWorker () {
  // return immediately if no decode tasks to do
  if (!tasks.length) {
    return;
  }

  // look for a web worker that is ready
  for (let i = 0; i < webWorkers.length; i++) {
    if (webWorkers[i].status === 'ready') {
      // mark it as busy so tasks are not assigned to it
      webWorkers[i].status = 'busy';

      // get the highest priority task
      const task = tasks.shift();

      task.start = new Date().getTime();

      // update stats with how long this task was delayed (waiting in queue)
      const end = new Date().getTime();

      statistics.totalTimeDelayedInMS += end - task.added;

      // assign this task to this web worker and send the web worker
      // a message to execute it
      webWorkers[i].task = task;
      webWorkers[i].worker.postMessage({
        taskType: task.taskType,
        workerIndex: i,
        data: task.data
      }, task.transferList);
      statistics.numTasksExecuting++;

      return;
    }
  }

  // if no available web workers and we haven't started max web workers, start a new one
  if (webWorkers.length < config.maxWebWorkers) {
    spawnWebWorker();
  }
}

/**
 * Function to handle a message from a web worker
 * @param msg
 */
function handleMessageFromWorker (msg) {
  // console.log('handleMessageFromWorker', msg.data);
  if (msg.data.taskType === 'initialize') {
    webWorkers[msg.data.workerIndex].status = 'ready';
    startTaskOnWebWorker();
  } else {
    var start = webWorkers[msg.data.workerIndex].task.start;
    webWorkers[msg.data.workerIndex].task.deferred.resolve(msg.data.result);
    webWorkers[msg.data.workerIndex].task = undefined;

    statistics.numTasksExecuting--;
    webWorkers[msg.data.workerIndex].status = 'ready';
    statistics.numTasksCompleted++;

    var end = new Date().getTime();
    statistics.totalTaskTimeInMS += end - start;

    startTaskOnWebWorker();
  }
}

/**
 * Spawns a new web worker
 */
function spawnWebWorker () {
  // prevent exceeding maxWebWorkers
  if (webWorkers.length >= config.maxWebWorkers) {
    return;
  }

  // spawn the webworker
  const worker = new Worker(config.webWorkerPath);

  webWorkers.push({
    worker,
    status: 'initializing'
  });
  worker.addEventListener('message', handleMessageFromWorker);
  worker.postMessage({
    taskType: 'initialize',
    workerIndex: webWorkers.length - 1,
    config
  });
}

/**
 * Initialization function for the web worker manager - spawns web workers
 * @param configObject
 */
function initialize (configObject) {
  configObject = configObject || defaultConfig;

  // prevent being initialized more than once
  if (config) {
    throw new Error('WebWorkerManager already initialized');
  }

  config = configObject;

  config.maxWebWorkers = config.maxWebWorkers || (navigator.hardwareConcurrency || 1);

  // Spawn new web workers
  if (!config.startWebWorkersOnDemand) {
    for (let i = 0; i < config.maxWebWorkers; i++) {
      spawnWebWorker();
    }
  }
}

/**
 * dynamically loads a web worker task
 * @param sourcePath
 * @param taskConfig
 */
function loadWebWorkerTask (sourcePath, taskConfig) {
  // add it to the list of web worker tasks paths so on demand web workers
  // load this properly
  config.webWorkerTaskPaths.push(sourcePath);

  // if a task specific configuration is provided, merge it into the config
  if (taskConfig) {
    config.taskConfiguration = Object.assign(config.taskConfiguration, taskConfig);
  }

  // tell each spawned web worker to load this task
  for (let i = 0; i < webWorkers.length; i++) {
    webWorkers[i].worker.postMessage({
      taskType: 'loadWebWorkerTask',
      workerIndex: webWorkers.length - 1,
      sourcePath,
      config
    });
  }
}

/**
 * Function to add a decode task to be performed
 *
 * @param taskType - the taskType for this task
 * @param data - data specific to the task
 * @param priority - optional priority of the task (defaults to 0), > 0 is higher, < 0 is lower
 * @param transferList - optional array of data to transfer to web worker
 * @returns {*}
 */
function addTask (taskType, data, priority, transferList) {
  if (!config) {
    initialize();
  }

  priority = priority || 0;
  const deferred = $.Deferred();

  // find the right spot to insert this decode task (based on priority)
  let i;

  for (i = 0; i < tasks.length; i++) {
    if (tasks[i].priority <= priority) {
      break;
    }
  }

  const taskId = nextTaskId++;

  // insert the decode task at position i
  tasks.splice(i, 0, {
    taskId,
    taskType,
    status: 'ready',
    added: new Date().getTime(),
    data,
    deferred,
    priority,
    transferList
  });

  // try to start a task on the web worker since we just added a new task and a web worker may be available
  startTaskOnWebWorker();

  return {
    taskId,
    promise: deferred.promise()
  };
}

/**
 * Changes the priority of a queued task
 * @param taskId - the taskId to change the priority of
 * @param priority - priority of the task (defaults to 0), > 0 is higher, < 0 is lower
 * @returns boolean - true on success, false if taskId not found
 */
function setTaskPriority (taskId, priority) {
  // search for this taskId
  for (let i = 0; i < tasks.length; i++) {
    if (tasks[i].taskId === taskId) {
      // taskId found, remove it
      const task = tasks.splice(i, 1)[0];

      // set its prioirty
      task.priority = priority;

      // find the right spot to insert this decode task (based on priority)
      for (i = 0; i < tasks.length; i++) {
        if (tasks[i].priority <= priority) {
          break;
        }
      }

      // insert the decode task at position i
      tasks.splice(i, 0, task);

      return true;
    }
  }

  return false;
}

/**
 * Cancels a queued task and rejects
 * @param taskId - the taskId to cancel
 * @param reason - optional reason the task was rejected
 * @returns boolean - true on success, false if taskId not found
 */
function cancelTask (taskId, reason) {
  // search for this taskId
  for (let i = 0; i < tasks.length; i++) {
    if (tasks[i].taskId === taskId) {
      // taskId found, remove it
      const task = tasks.splice(i, 1);

      task.promise.reject(reason);

      return true;
    }
  }

  return false;
}

/**
 * Function to return the statistics on running web workers
 * @returns object containing statistics
 */
function getStatistics () {
  statistics.maxWebWorkers = config.maxWebWorkers;
  statistics.numWebWorkers = webWorkers.length;
  statistics.numTasksQueued = tasks.length;

  return statistics;
}

export default {
  initialize,
  loadWebWorkerTask,
  addTask,
  getStatistics,
  setTaskPriority,
  cancelTask
};
<|endoftext|>


<commit_before>/* ========================================================================
 * DOM-based Routing
 * Based on http://goo.gl/EUTi53 by Paul Irish
 *
 * Only fires on body classes that match. If a body class contains a dash,
 * replace the dash with an underscore when adding it to the object below.
 *
 * .noConflict()
 * The routing is enclosed within an anonymous function so that you can
 * always reference jQuery with $, even when in .noConflict() mode.
 * ======================================================================== */

(function($) {

  // Use this variable to set up the common and page specific functions. If you
  // rename this variable, you will also need to rename the namespace below.
  var Sage = {
    // All pages
    'common': {
      init: function() {
        // JavaScript to be fired on all pages
      },
      finalize: function() {
        // JavaScript to be fired on all pages, after page specific JS is fired
      }
    },
    // Home page
    'home': {
      init: function() {
        // JavaScript to be fired on the home page
      },
      finalize: function() {
        // JavaScript to be fired on the home page, after the init JS
      }
    },
    // About us page, note the change from about-us to about_us.
    'about_us': {
      init: function() {
        // JavaScript to be fired on the about us page
      }
    }
  };

  // The routing fires all common scripts, followed by the page specific scripts.
  // Add additional events for more control over timing e.g. a finalize event
  var UTIL = {
    fire: function(func, funcname, args) {
      var fire;
      var namespace = Sage;
      funcname = (funcname === undefined) ? 'init' : funcname;
      fire = func !== '';
      fire = fire && namespace[func];
      fire = fire && typeof namespace[func][funcname] === 'function';

      if (fire) {
        namespace[func][funcname](args);
      }
    },
    loadEvents: function() {
      // Fire common init JS
      UTIL.fire('common');

      // Fire page-specific init JS, and then finalize JS
      $.each(document.body.className.replace(/-/g, '_').split(/\s+/), function(i, classnm) {
        UTIL.fire(classnm);
        UTIL.fire(classnm, 'finalize');
      });

      // Fire common finalize JS
      UTIL.fire('common', 'finalize');
    }
  };

  // Load Events
  $(document).ready(UTIL.loadEvents);

})(jQuery); // Fully reference jQuery after this point.

  $(document).foundation();

  var $grid = $('.lookbookgrid').isotope({
    itemSelector: '.grid-item',
    percentPosition: true,
    masonry: {
      columnWidth: '.grid-sizer',
      gutter: 0
    }
  });

  $grid.imagesLoaded().progress( function() {
    $grid.isotope('layout');
  });

(function($) {
  $.slugi = function(input) {
    var output = 'colvariant colvariant--tiny colvariant--' + input.replace(/ /gi, '-').toLowerCase();
    return output;
  };
})(jQuery);

$('document').ready(function($){

  /*** Required data param for inputs ***/
  $('.woocommerce-billing-fields .validate-required').find('input[type=text], input[type=email]').prop('required','true');

  $('#createaccount').on('change',function(e) {
    if ($(this).prop('checked')) {
      $('.create-account .validate-required').find('input').prop('required','true');
    } else {
      $('.create-account .validate-required').find('input').prop('required','false');
    }
  });

  $('#ship-to-different-address-checkbox').on('change',function(e) {
    if ($(this).prop('checked')) {
      $('.woocommerce-shipping-fields .validate-required').find('input').prop('required','true');
    } else {
      $('.woocommerce-shipping-fields .validate-required').find('input').prop('required','false');
    }
  });

  $(document.body).on('change', 'input[name="payment_method"]', function() {
    $('body').trigger('update_checkout');
    $.ajax( $fragment_refresh );
  });

  /*** Thumbnail Carousel on Single product Page ***/
  var prodthumbsOwl = $('.prodthumbs');

  prodthumbsOwl.owlCarousel({
    pagination:false,
    navigation : false,

    items : 4, //10 items above 1000px browser width
    itemsDesktop : [1024,3], //5 items between 1000px and 901px
    itemsDesktopSmall : [768,3], // betweem 900px and 601px
    itemsTablet: [480,3], //2 items between 480 and 0
    itemsMobile : false // itemsMobile disabled - inherit from itemsTablet option
  });

  var prodOwl = $('.prod-carousel');

  prodOwl.owlCarousel({
    pagination:false,
    navigation : false,

    items : 6, //10 items above 1000px browser width
    itemsDesktop : [1280,5], //5 items between 1000px and 901px
    itemsDesktopSmall : [1024,4], // betweem 900px and 601px
    itemsTablet: [768,3], //2 items between 480 and 0
    itemsMobile : [480,2] // itemsMobile disabled - inherit from itemsTablet option
  });

  $('.lookbookgrid').magnificPopup({
    delegate: 'a',
    type: 'image',
    tLoading: 'Loading image #%curr%...',
    mainClass: 'mfp-img-mobile',
    gallery: {
      enabled: true,
      navigateByImgClick: true,
      preload: [0,1] // Will preload 0 - before current, and 1 after the current image
    },
    image: {
      tError: 'The image #%curr% could not be loaded.',
      titleSrc: function(item) {
        return /*item.el.children().attr('alt') + */'&copy DogDays Yoga Wear';
      }
    }
  });

  $('.woocommerce-main-image').magnificPopup({
    type: 'image',
    closeOnContentClick: true,
    closeBtnInside: false,
    fixedContentPos: true,
    mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side
    image: {
      verticalFit: true
    },
    zoom: {
      enabled: true,
      duration: 300 // don't foget to change the duration also in CSS
    }
  });

  $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
    disableOn: 700,
    type: 'iframe',
    mainClass: 'mfp-fade',
    removalDelay: 160,
    preloader: false,

    fixedContentPos: false
  });

  $('.woocommerce-main-image').zoom({
      url: $('.woocommerce-main-image').attr('href'),
      magnify: 0.75,
   });

  $('.prodthumbs .item a').on('click', function(e) {
   e.preventDefault();
   $('.woocommerce-main-image').trigger('zoom.destroy');
   $('.woocommerce-main-image').css('min-height', $('.woocommerce-main-image .attachment-shop_single').height());
   $('.woocommerce-main-image').attr('href', $(this).attr('href') );
   $('.woocommerce-main-image .attachment-shop_single').replaceWith($(this).data('swapimage'));
   $('.woocommerce-main-image').zoom({
      url: $('.woocommerce-main-image').attr('href'),
      magnify: 0.75
   });

   setTimeout(function() { $('.woocommerce-main-image').css('min-height', 'auto'); } , 2000);
  });

  /*** CONTACT FORM ******/
  $("#contact_form").on('submit', function(ev) {
    ev.preventDefault();
    var user_name = $('input[name=message_name]').val();
      var user_email = $('input[name=message_email]').val();
      var user_tel = $('input[name=message_tel]').val();
      var user_msg = $('textarea[name=message_text]').val();

      var proceed = true;
      if (user_name === "") {
          proceed = false;
      }
      if (user_email === "") {
          proceed = false;
      }
      if (user_msg === "") {
          proceed = false;
      }

      //everything looks good! proceed...
      if (proceed) {
          //data to be sent to server
          post_data = {
              'userName': user_name,
              'userEmail': user_email,
              'userTel': user_tel,
              'userMsg': user_msg
          };

          //Ajax post data to server
          $.post($('#contact_form').attr('action'), post_data, function(response){

              //load json data from server and output message
              if (response.type === 'error') {
                  output = '
' + response.text + '
';
              }
              else {

                  output = '
' + response.text + '
';

                  //reset values in all input fields
                  $('#contact_form input').val('');
                  $('#contact_form textarea').val('');
              }

              $("#result").hide().html(output).slideDown();
          }, 'json');

      }

      return false;
  });

    //reset previously set border colors and hide all message on .keyup()
    $("#contact_form input, #contact_form textarea").keyup(function(){
        $("#result").slideUp();
    });

    /*** Mailchipmp ****/

    // Validate the email address in the form
    function isValidEmail($form) {
        // If email is empty, show error message.
        // contains just one @
        var email = $form.find('input[type="email"]').val();
        if (!email || !email.length) {
            return false;
        } else if (email.indexOf('@') === -1) {
            return false;
        }
        return true;
    }

    // Submit the form with an ajax/jsonp request.
    // Based on http://stackoverflow.com/a/15120409/215821
    function submitSubscribeForm($form, $resultElement) {
        $.ajax({
            type: $form.attr('method'),
            url: $form.attr('action'),
            data: $form.serialize(),
            cache: false,
            dataType: 'jsonp',
            jsonp: "c", // trigger MailChimp to return a JSONP response
            contentType: "application/json; charset=utf-8",
            error: function(error){
                // According to jquery docs, this is never called for cross-domain JSONP requests
            },
            success: function(data){
                if (data.result !== 'success') {
                    var message = data.msg || 'Sorry. Unable to subscribe. Please try again later.';
                    if (data.msg && data.msg.indexOf("already subscribed") >= 0) {
                        message = 'Már fel vagy iratkozva. Köszönjük.';
                    }
                    $resultElement.html(message);
                } else {
                    $resultElement.html('Köszönjük! Feliratkozásod jóvá kell hagynod. A megerősítő e-mailt kiküldtük.');
                }
            }
        });
    }

    // Turn the given MailChimp form into an ajax version of it.
    // If resultElement is given, the subscribe result is set as html to
    // that element.
    function ajaxMailChimpForm($form, $resultElement){
        // Hijack the submission. We'll submit the form manually.
        $form.submit(function(e) {
            e.preventDefault();
            if (!isValidEmail($form)) {
                var error =  'Érvényes e-mail címe szükséges';
                $resultElement.html(error);
            } else {
                $resultElement.html('Feliratkozás…');
                submitSubscribeForm($form, $resultElement);
            }
        });
    }

    ajaxMailChimpForm($('#mc-embedded-subscribe-form'), $('#mce-responses'));

    $('#csiki').on('click', function(e) {
      e.preventDefault();
       $('.topacc').foundation('toggle', $('#thetopcart'));
    });

    $('.filterblock--colors li a').each( function( i, val ) {
     $(this).parent().addClass($.slugi($(this).text())) ;
    });

    //Mérettablazat modal
    $('.linktosizetable').on('click', function(e) {
      e.preventDefault();
      var $modal = $('#sizemodal');
      $.ajax($(this).attr('href'))
        .done(function(resp){
          var cleanTitle = $(resp).find('.pagetitle').eq(0);
          var cleanCont = $(resp).find('.pagecontent').eq(0);
          $modal.html('
Mérettáblázat
<button class="close-button" data-close aria-label="Close modal" type="button">×</button>').append(cleanCont).foundation('open');
        });

    });
    // var $modal = $('#sizemodal');
    // $.ajax('/dd/vasarlasi-informaciok/merettablazat/')
    //   .done(function(resp){
    //     $modal.html(resp.html).foundation('open');
    // });

});<commit_msg>script<commit_after>/* ========================================================================
 * DOM-based Routing
 * Based on http://goo.gl/EUTi53 by Paul Irish
 *
 * Only fires on body classes that match. If a body class contains a dash,
 * replace the dash with an underscore when adding it to the object below.
 *
 * .noConflict()
 * The routing is enclosed within an anonymous function so that you can
 * always reference jQuery with $, even when in .noConflict() mode.
 * ======================================================================== */

(function($) {

  // Use this variable to set up the common and page specific functions. If you
  // rename this variable, you will also need to rename the namespace below.
  var Sage = {
    // All pages
    'common': {
      init: function() {
        // JavaScript to be fired on all pages
      },
      finalize: function() {
        // JavaScript to be fired on all pages, after page specific JS is fired
      }
    },
    // Home page
    'home': {
      init: function() {
        // JavaScript to be fired on the home page
      },
      finalize: function() {
        // JavaScript to be fired on the home page, after the init JS
      }
    },
    // About us page, note the change from about-us to about_us.
    'about_us': {
      init: function() {
        // JavaScript to be fired on the about us page
      }
    }
  };

  // The routing fires all common scripts, followed by the page specific scripts.
  // Add additional events for more control over timing e.g. a finalize event
  var UTIL = {
    fire: function(func, funcname, args) {
      var fire;
      var namespace = Sage;
      funcname = (funcname === undefined) ? 'init' : funcname;
      fire = func !== '';
      fire = fire && namespace[func];
      fire = fire && typeof namespace[func][funcname] === 'function';

      if (fire) {
        namespace[func][funcname](args);
      }
    },
    loadEvents: function() {
      // Fire common init JS
      UTIL.fire('common');

      // Fire page-specific init JS, and then finalize JS
      $.each(document.body.className.replace(/-/g, '_').split(/\s+/), function(i, classnm) {
        UTIL.fire(classnm);
        UTIL.fire(classnm, 'finalize');
      });

      // Fire common finalize JS
      UTIL.fire('common', 'finalize');
    }
  };

  // Load Events
  $(document).ready(UTIL.loadEvents);

})(jQuery); // Fully reference jQuery after this point.

  $(document).foundation();

  var $grid = $('.lookbookgrid').isotope({
    itemSelector: '.grid-item',
    percentPosition: true,
    masonry: {
      columnWidth: '.grid-sizer',
      gutter: 0
    }
  });

  $grid.imagesLoaded().progress( function() {
    $grid.isotope('layout');
  });

(function($) {
  $.slugi = function(input) {
    var output = 'colvariant colvariant--tiny colvariant--' + input.replace(/ /gi, '-').toLowerCase();
    return output;
  };
})(jQuery);

$('document').ready(function($){

  /*** Required data param for inputs ***/
  $('.woocommerce-billing-fields .validate-required').find('input[type=text], input[type=email]').prop('required','true');

  $('#createaccount').on('change',function(e) {
    if ($(this).prop('checked')) {
      $('.create-account .validate-required').find('input').prop('required','true');
    } else {
      $('.create-account .validate-required').find('input').prop('required','false');
    }
  });

  $('#ship-to-different-address-checkbox').on('change',function(e) {
    if ($(this).prop('checked')) {
      $('.woocommerce-shipping-fields .validate-required').find('input').prop('required','true');
    } else {
      $('.woocommerce-shipping-fields .validate-required').find('input').prop('required','false');
    }
  });

  // $(document.body).on('change', 'input[name="payment_method"]', function() {
  //   $('body').trigger('update_checkout');
  //   //$.ajax( $fragment_refresh );
  // });

  /*** Thumbnail Carousel on Single product Page ***/
  var prodthumbsOwl = $('.prodthumbs');

  prodthumbsOwl.owlCarousel({
    pagination:false,
    navigation : false,

    items : 4, //10 items above 1000px browser width
    itemsDesktop : [1024,3], //5 items between 1000px and 901px
    itemsDesktopSmall : [768,3], // betweem 900px and 601px
    itemsTablet: [480,3], //2 items between 480 and 0
    itemsMobile : false // itemsMobile disabled - inherit from itemsTablet option
  });

  var prodOwl = $('.prod-carousel');

  prodOwl.owlCarousel({
    pagination:false,
    navigation : false,

    items : 6, //10 items above 1000px browser width
    itemsDesktop : [1280,5], //5 items between 1000px and 901px
    itemsDesktopSmall : [1024,4], // betweem 900px and 601px
    itemsTablet: [768,3], //2 items between 480 and 0
    itemsMobile : [480,2] // itemsMobile disabled - inherit from itemsTablet option
  });

  $('.lookbookgrid').magnificPopup({
    delegate: 'a',
    type: 'image',
    tLoading: 'Loading image #%curr%...',
    mainClass: 'mfp-img-mobile',
    gallery: {
      enabled: true,
      navigateByImgClick: true,
      preload: [0,1] // Will preload 0 - before current, and 1 after the current image
    },
    image: {
      tError: 'The image #%curr% could not be loaded.',
      titleSrc: function(item) {
        return /*item.el.children().attr('alt') + */'&copy DogDays Yoga Wear';
      }
    }
  });

  $('.woocommerce-main-image').magnificPopup({
    type: 'image',
    closeOnContentClick: true,
    closeBtnInside: false,
    fixedContentPos: true,
    mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side
    image: {
      verticalFit: true
    },
    zoom: {
      enabled: true,
      duration: 300 // don't foget to change the duration also in CSS
    }
  });

  $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
    disableOn: 700,
    type: 'iframe',
    mainClass: 'mfp-fade',
    removalDelay: 160,
    preloader: false,

    fixedContentPos: false
  });

  $('.woocommerce-main-image').zoom({
      url: $('.woocommerce-main-image').attr('href'),
      magnify: 0.75,
   });

  $('.prodthumbs .item a').on('click', function(e) {
   e.preventDefault();
   $('.woocommerce-main-image').trigger('zoom.destroy');
   $('.woocommerce-main-image').css('min-height', $('.woocommerce-main-image .attachment-shop_single').height());
   $('.woocommerce-main-image').attr('href', $(this).attr('href') );
   $('.woocommerce-main-image .attachment-shop_single').replaceWith($(this).data('swapimage'));
   $('.woocommerce-main-image').zoom({
      url: $('.woocommerce-main-image').attr('href'),
      magnify: 0.75
   });

   setTimeout(function() { $('.woocommerce-main-image').css('min-height', 'auto'); } , 2000);
  });

  /*** CONTACT FORM ******/
  $("#contact_form").on('submit', function(ev) {
    ev.preventDefault();
    var user_name = $('input[name=message_name]').val();
      var user_email = $('input[name=message_email]').val();
      var user_tel = $('input[name=message_tel]').val();
      var user_msg = $('textarea[name=message_text]').val();

      var proceed = true;
      if (user_name === "") {
          proceed = false;
      }
      if (user_email === "") {
          proceed = false;
      }
      if (user_msg === "") {
          proceed = false;
      }

      //everything looks good! proceed...
      if (proceed) {
          //data to be sent to server
          post_data = {
              'userName': user_name,
              'userEmail': user_email,
              'userTel': user_tel,
              'userMsg': user_msg
          };

          //Ajax post data to server
          $.post($('#contact_form').attr('action'), post_data, function(response){

              //load json data from server and output message
              if (response.type === 'error') {
                  output = '
' + response.text + '
';
              }
              else {

                  output = '
' + response.text + '
';

                  //reset values in all input fields
                  $('#contact_form input').val('');
                  $('#contact_form textarea').val('');
              }

              $("#result").hide().html(output).slideDown();
          }, 'json');

      }

      return false;
  });

    //reset previously set border colors and hide all message on .keyup()
    $("#contact_form input, #contact_form textarea").keyup(function(){
        $("#result").slideUp();
    });

    /*** Mailchipmp ****/

    // Validate the email address in the form
    function isValidEmail($form) {
        // If email is empty, show error message.
        // contains just one @
        var email = $form.find('input[type="email"]').val();
        if (!email || !email.length) {
            return false;
        } else if (email.indexOf('@') === -1) {
            return false;
        }
        return true;
    }

    // Submit the form with an ajax/jsonp request.
    // Based on http://stackoverflow.com/a/15120409/215821
    function submitSubscribeForm($form, $resultElement) {
        $.ajax({
            type: $form.attr('method'),
            url: $form.attr('action'),
            data: $form.serialize(),
            cache: false,
            dataType: 'jsonp',
            jsonp: "c", // trigger MailChimp to return a JSONP response
            contentType: "application/json; charset=utf-8",
            error: function(error){
                // According to jquery docs, this is never called for cross-domain JSONP requests
            },
            success: function(data){
                if (data.result !== 'success') {
                    var message = data.msg || 'Sorry. Unable to subscribe. Please try again later.';
                    if (data.msg && data.msg.indexOf("already subscribed") >= 0) {
                        message = 'Már fel vagy iratkozva. Köszönjük.';
                    }
                    $resultElement.html(message);
                } else {
                    $resultElement.html('Köszönjük! Feliratkozásod jóvá kell hagynod. A megerősítő e-mailt kiküldtük.');
                }
            }
        });
    }

    // Turn the given MailChimp form into an ajax version of it.
    // If resultElement is given, the subscribe result is set as html to
    // that element.
    function ajaxMailChimpForm($form, $resultElement){
        // Hijack the submission. We'll submit the form manually.
        $form.submit(function(e) {
            e.preventDefault();
            if (!isValidEmail($form)) {
                var error =  'Érvényes e-mail címe szükséges';
                $resultElement.html(error);
            } else {
                $resultElement.html('Feliratkozás…');
                submitSubscribeForm($form, $resultElement);
            }
        });
    }

    ajaxMailChimpForm($('#mc-embedded-subscribe-form'), $('#mce-responses'));

    $('#csiki').on('click', function(e) {
      e.preventDefault();
       $('.topacc').foundation('toggle', $('#thetopcart'));
    });

    $('.filterblock--colors li a').each( function( i, val ) {
     $(this).parent().addClass($.slugi($(this).text())) ;
    });

    //Mérettablazat modal
    $('.linktosizetable').on('click', function(e) {
      e.preventDefault();
      var $modal = $('#sizemodal');
      $.ajax($(this).attr('href'))
        .done(function(resp){
          var cleanTitle = $(resp).find('.pagetitle').eq(0);
          var cleanCont = $(resp).find('.pagecontent').eq(0);
          $modal.html('
Mérettáblázat
<button class="close-button" data-close aria-label="Close modal" type="button">×</button>').append(cleanCont).foundation('open');
        });

    });
    // var $modal = $('#sizemodal');
    // $.ajax('/dd/vasarlasi-informaciok/merettablazat/')
    //   .done(function(resp){
    //     $modal.html(resp.html).foundation('open');
    // });

});<|endoftext|>