Skip to content

Instantly share code, notes, and snippets.

@zo0m
Created April 2, 2020 12:44
Show Gist options
  • Select an option

  • Save zo0m/0f3eb18f811e56dab277a5a7d69e8f8d to your computer and use it in GitHub Desktop.

Select an option

Save zo0m/0f3eb18f811e56dab277a5a7d69e8f8d to your computer and use it in GitHub Desktop.

Revisions

  1. zo0m created this gist Apr 2, 2020.
    5 changes: 5 additions & 0 deletions EventImage
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Alloy
    Require(src='components/common/base-window/BaseWindow')
    Require#loader(src="components/common/horizontal-scroller/LoadingContainer")
    Require#eventMap(src="components/event/map/EventMap", bind_onLoad="(()=> $.loader.onload())")

    47 changes: 47 additions & 0 deletions alloy.jmk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    var sourceMapper = require('./sourceMapper');
    var paths = require('global-paths');
    var projectDirectory;
    var logger;

    function resolver(moduleName) {
    return require(require('resolve').sync(moduleName, {
    basedir: projectDirectory,
    paths: paths(),
    }));
    }

    task('pre:load', (event, alloyLogger) => {
    logger = alloyLogger;
    projectDirectory = event.dir.project;

    sourceMapper.OPTIONS_OUTPUT.presets = sourceMapper.OPTIONS_OUTPUT.presets || [];
    sourceMapper.OPTIONS_OUTPUT.presets.push(resolver('babel-preset-env'));
    sourceMapper.OPTIONS_OUTPUT.presets.push({
    plugins: [
    [resolver('babel-plugin-titanium-controller-args')],
    [bind_AttributeTransformer],
    [resolver('babel-plugin-transform-async-generator-functions')]
    ],
    });
    });

    function bind_AttributeTransformer(_ref) {
    var types = _ref.types;

    return {
    pre: function (state) {
    },
    visitor: {
    Property: function (path, state) {
    if (types.isStringLiteral(path.node.value)) {
    // if (path.node.value.value.startsWith('@:')) {
    var namePrefix = 'bind_';
    if (path.node.key.name && path.node.key.name.startsWith(namePrefix)) {
    path.replaceWith(types.ObjectProperty(types.identifier(path.node.key.name), types.Identifier(path.node.value.value)));
    path.node.key.name = path.node.key.name.slice(namePrefix.length);
    }
    }
    },
    }
    };
    };
    10 changes: 10 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    Alloy
    Require(src='components/common/base-window/BaseWindow')
    Require#scroller(
    src="components/common/horizontal-scroller/HorizontalScroller",
    module="app/ui/components",
    bind_startIndex="getCurrentListIndex($.args.event)",
    bind_createNextView="createNextView",
    bind_createPrevView="createPrevView",
    bind_handleScrollend="handleScrollend"
    )