Example #1
0
$(document).ready(function(){
    var osfHome = {
        view : function(ctrl, args) {
            // Camel-case institutions keys
            var _affiliatedInstitutions = lodashGet(window, 'contextVars.currentUser.institutions') || [];
            var affiliatedInstitutions = _affiliatedInstitutions.map(function(inst) {
                return {logoPath: inst.logo_path, id: inst.id, name: inst.name};
            });
            var _dashboardInstitutions = lodashGet(window, 'contextVars.dashboardInstitutions') || [];
            var dashboardInstitutions = _dashboardInstitutions.map(function(inst) {
                return {logoPath: inst.logo_path, id: inst.id, name: inst.name};
            });
            return [
                m('.quickSearch', m('.container.p-t-lg',
                    [
                        m('.row.m-t-lg', [
                            m(columnSizeClass, m.component(QuickSearchProject, {}))
                        ])
                    ]
                )),
                // TODO: We hide the institution logos on small screens. Better to make the carousel responsive.
                m('.institutions-panel.hidden-xs', m('.container',
                    [
                        m('.row', [
                            m(columnSizeClass,  m.component(InstitutionsPanel, {
                                affiliatedInstitutions: affiliatedInstitutions,
                                allInstitutions: dashboardInstitutions
                            }))
                        ])
                    ]
                )),
                m('.newAndNoteworthy', m('.container',
                    [
                        m('.row', [
                            m(columnSizeClass, m('h3', 'Discover Public Projects'))
                        ]),
                        m('.row', [
                            m(columnSizeClass, m.component(NewAndNoteworthy, {}))
                        ])

                    ]
                )),
                m('.prereg', m('.container',
                    [
                        m('.row', [
                            m(columnSizeClass,  m.component(Prereg, {}))
                        ])

                    ]
                )),
                m('.meetings', m('.container',
                    [
                        m('.row', [
                            m(columnSizeClass,  m.component(MeetingsAndConferences, {}))
                        ])

                    ]
                )),
                m('.preprints', m('.container',
                    [
                        m('.row', [
                            m(columnSizeClass,  m.component(Preprints, {}))
                        ])

                    ]
                ))
            ];
        }
    };
    m.mount(document.getElementById('osfHome'), m.component(osfHome, {}));
    $('#osfNavDashboard').addClass('active');


    // If logged in...
    var user = window.contextVars.currentUser;
    if (user) {
        // Update user's timezone and locale
        ensureUserTimezone(user.timezone, user.locale, user.id);
    }
});
Example #2
0
  content: {
    padding: '2rem',
    margin: '0 0 0.5rem 0'
  }
})

//here's the view
todo.view = function() {
	return m("html", [
		m("body", [
      m("style", todo.styles),
      m("div", {class: todo.styles.title}, "Hello"),
			m("input", {onchange: m.withAttr("value", todo.vm.description), value: todo.vm.description()}),
			m("button", {onclick: todo.vm.add}, "Add"),
			m("table", [
				todo.vm.list.map(function(task, index) {
					return m("tr", [
						m("td", [
							m("input[type=checkbox]", {onclick: m.withAttr("checked", task.done), checked: task.done()})
						]),
						m("td", {style: {textDecoration: task.done() ? "line-through" : "none"}}, task.description()),
					])
				})
			])
		])
	]);
};

//initialize the application
m.mount(document, {controller: todo.controller, view: todo.view});
Example #3
0
var $ = require('jquery');
var m = require('mithril');
var $osf = require('js/osfHelpers');
var FileViewPage = require('js/filepage');
var waterbutler = require('js/waterbutler');
var Raven = require('raven-js');

require('jquery-tagsinput');

m.mount(document.getElementsByClassName('file-view-panels')[0], FileViewPage(window.contextVars));

var tagUrl = '/api/v1/project/' + window.contextVars.node.id + '/osfstorage' + window.contextVars.file.path + '/tags/';

$(function() {
    // Tag input
    $('#fileTags').tagsInput({
        width: '100%',
        interactive: window.contextVars.currentUser.canEdit,
        maxChars: 128,
        onAddTag: function (tag) {
            var url = tagUrl;
            var request = $osf.postJSON(url, {'tag': tag });
            request.fail(function (xhr, textStatus, error) {
                $osf.growl('Error', 'Could not add tag.');
                Raven.captureMessage('Failed to add tag', {
                    extra: { tag: tag, url: url, textStatus: textStatus, error: error }
                });
            });
        },
        onRemoveTag: function (tag) {
            // Don't try to delete a blank tag (would result in a server error)
Example #4
0
import { P } from "patchinko/explicit"
import m from "mithril"
import stream from "mithril/stream"

import { app, App } from "./app"

const update = stream()
const states = stream.scan(P, app.initialState(), update).map(app.service)

// Only for using Meiosis Tracer in development.
const meiosisTracer = require("meiosis-tracer")
meiosisTracer({ selector: "#tracer", streams: [{ label: "states", stream: states }] })
states.map(() => m.redraw())
// End of code for using Meiosis Tracer in development.

const actions = app.actions({ update })
m.mount(document.getElementById("app"), { view: () => m(App, { state: states(), actions }) })
Example #5
0
export function init(config = {}) {
    if (controller !== null) {
        return;
    }
    var countryDefault = config.countryDefault;
    if(!countryDefault && config.countries.length > 0){
        countryDefault = config.countries[0].id;
    }
    store.dispatch(setShopChoices(config.shops || []));
    store.dispatch(setShop(config.shops[0] || []));
    store.dispatch(setCountries(config.countries || []));
    store.dispatch(setAddressProperty("billing", "country", countryDefault));
    store.dispatch(setAddressProperty("shipping", "country", countryDefault));
    store.dispatch(setShippingMethodChoices(config.shippingMethods || []));
    store.dispatch(setPaymentMethodChoices(config.paymentMethods || []));
    const orderId = config.orderId;
    store.dispatch(setOrderId(orderId));
    const customerData = config.customerData;

    const persistor = persistStore(store);
    persistor.purge(["customerDetails", "quickAdd"]);
    const resetOrder = window.localStorage.getItem("resetSavedOrder") || "false";
    var savedOrder = {id: null};
    if (resetOrder === "true") {
        persistor.purgeAll();
        window.localStorage.setItem("resetSavedOrder", "false");
    } else {
        const savedOrderStr = window.localStorage.getItem("reduxPersist:order");
        if (savedOrderStr) {
            savedOrder = JSON.parse(savedOrderStr);
        }
    }

    if (customerData) { // contact -> New Order
        persistor.purgeAll();
        store.dispatch(setCustomer(customerData));
    }

    if (orderId) { // Edit mode
        if (!savedOrder.id || savedOrder.id !== orderId) {
            // Saved order id does not match with current order
            // Purge the wrong saved state and initialize from orderData
            persistor.purgeAll();
            store.dispatch(setShop(config.orderData.shop));
            store.dispatch(setCustomer(config.orderData.customer));
            store.dispatch(setShippingMethod(config.orderData.shippingMethodId));
            store.dispatch(setPaymentMethod(config.orderData.paymentMethodId));
            store.dispatch(setLines(config.orderData.lines));
            store.dispatch(updateTotals(store.getState));
        }
    } else {  // New mode
        if (savedOrder.id) {
            // Purge the old saved state for existing order
            persistor.purgeAll();
        }
    }

    controller = m.mount(document.getElementById("order-tool-container"), {
        view,
        controller: _.noop
    });
    store.subscribe(() => {
        m.redraw();
    });
}
Example #6
0
}())

//コントローラは、モデルの中のどの部分が、現在のページと関連するのかを定義している
//この場合は1つのビュー・モデルですべてを取り仕切っている
todo.controller = function() {
    todo.vm.init()
}

//これがビュー
todo.view = function() {
    return m("html", [
        m("body", [
            m("input", {onchange: m.withAttr("value", todo.vm.description), value: todo.vm.description()}),
            m("button", {onclick: todo.vm.add}, "追加"),
            m("table", [
                todo.vm.list.map(function(task, index) {
                    return m("tr", [
                        m("td", [
                            m("input[type=checkbox]", {onclick: m.withAttr("checked", task.done), checked: task.done()})
                        ]),
                        m("td", {style: {textDecoration: task.done() ?"line-through" : "none"}}, task.description()),
                    ])
                })
            ])
        ])
    ]);
};

//アプリケーションの初期化
m.mount(document.getElementById("container"), {controller: todo.controller, view: todo.view});
Example #7
0
 $modal.on('hidden.bs.modal', () => m.mount(container, null))
Example #8
0
File: app.js Project: Nauj10/APE
import Window from "./components/window";
import m from 'mithril';

m.mount(document.body, Window);
Example #9
0
var component = require("./components/example")

var m = require("mithril")

m.mount(document.body, component)
//kick off live editing
require("./patch")
Example #10
0
define(function(require) {
    'use strict';

    var m = require('mithril'),
        iconBtn = require('polythene/icon-button/icon-button'),
        nav = require('nav'),
        github = require('github'),
        iconBlock,
        content;

    require('polythene/layout/layout');
    require('css!app-css');
    require('css!./main');

    iconBlock = {
        view: function(ctrl, args) {
            var btnArgs = (JSON.parse(JSON.stringify(args))); // copy object
            return m('.p-block.p-large', [
                m('span', args.label),
                m.trust(' '),
                m.component(iconBtn, btnArgs.btn)
            ]);
        }
    };

    content = {
        view: function() {
            return [
                m.component(nav, {
                    baseFileName: 'icon-button',
                    title: 'Icon Button',
                    subtitle: 'Mithril version'
                }),
                m.component(iconBlock, {
                    label: 'Menu',
                    btn: {
                        icon: {
                            svg: {
                                group: 'navigation',
                                name: 'menu'
                            },
                            className: 'md'
                        }
                    }
                }),
                m.component(iconBlock, {
                    label: 'Add',
                    btn: {
                        icon: {
                            svg: {
                                group: 'content',
                                name: 'add'
                            },
                            className: 'md'
                        }
                    }
                }),
                m.component(iconBlock, {
                    label: 'Refresh',
                    btn: {
                        icon: {
                            svg: {
                                group: 'navigation',
                                name: 'refresh'
                            },
                            className: 'md'
                        }
                    }
                }),
                github
            ];
        }
    };

    m.mount(document.body, content);
});
Example #11
0
 function unmount() {
   $("body").off();
   m.mount(root, null);
   m.redraw();
 }
Example #12
0
  function mount(canAdminister = true, showSpinner = Stream(false)) {
    buildCauseJson = {
      "approver":           "",
      "is_forced":          false,
      "trigger_message":    "modified by GoCD Test User <*****@*****.**>",
      "material_revisions": [
        {
          "material_type": "Git",
          "material_name": "test-repo",
          "changed":       true,
          "modifications": [
            {
              "_links":        {
                "vsm": {
                  "href": "http://*****:*****@example.com>",
              "revision":      "9c86679eefc3c5c01703e9f1d0e96b265ad25691",
              "modified_time": "2017-12-19T05:30:32.000Z",
              "comment":       "Initial commit"
            }
          ]
        }
      ]
    };
    dashboardJson  = {
      "filter_name": "Default",
      "_embedded":   {
        "pipeline_groups": [
          {
            "_links":         {
              "self": {
                "href": "http://localhost:8153/go/api/config/pipeline_groups/first"
              },
              "doc":  {
                "href": "https://api.go.cd/current/#pipeline-groups"
              }
            },
            "name":           "first",
            "pipelines":      ["up42", "up43"],
            "can_administer": canAdminister
          }
        ],
        "pipelines":       [
          {
            "_links":                 {
              "self":                 {
                "href": "http://localhost:8153/go/api/pipelines/up42/history"
              },
              "doc":                  {
                "href": "https://api.go.cd/current/#pipelines"
              }
            },
            "name":                   "up42",
            "last_updated_timestamp": 1510299695473,
            "locked":                 false,
            "can_pause":              true,
            "pause_info":             {
              "paused":       false,
              "paused_by":    null,
              "pause_reason": null
            },
            "_embedded":              {
              "instances": [
                {
                  "_links":       {
                    "self":            {
                      "href": "http://localhost:8153/go/api/pipelines/up42/instance/1"
                    },
                    "doc":             {
                      "href": "https://api.go.cd/current/#get-pipeline-instance"
                    }
                  },
                  "label":        "1",
                  "counter":      "1",
                  "scheduled_at": "2017-11-10T07:25:28.539Z",
                  "triggered_by": "changes",
                  "_embedded":    {
                    "stages": [
                      {
                        "_links":       {
                          "self": {
                            "href": "http://localhost:8153/go/api/stages/up42/1/up42_stage/1"
                          },
                          "doc":  {
                            "href": "https://api.go.cd/current/#get-stage-instance"
                          }
                        },
                        "name":         "up42_stage",
                        "counter":      "1",
                        "status":       "Failed",
                        "approved_by":  "changes",
                        "scheduled_at": "2017-11-10T07:25:28.539Z"
                      }
                    ]
                  }
                }
              ]
            }
          },
          {
            "_links":                 {
              "self":                 {
                "href": "http://localhost:8153/go/api/pipelines/up43/history"
              },
              "doc":                  {
                "href": "https://api.go.cd/current/#pipelines"
              }
            },
            "name":                   "up43",
            "last_updated_timestamp": 1510299695473,
            "locked":                 true,
            "can_unlock":             true,
            "can_pause":              true,
            "pause_info":             {
              "paused":       false,
              "paused_by":    null,
              "pause_reason": null
            },
            "_embedded":              {
              "instances": [
                {
                  "_links":       {
                    "self":            {
                      "href": "http://localhost:8153/go/api/pipelines/up43/instance/1"
                    },
                    "doc":             {
                      "href": "https://api.go.cd/current/#get-pipeline-instance"
                    }
                  },
                  "label":        "1",
                  "counter":      "1",
                  "scheduled_at": "2017-11-10T07:25:28.539Z",
                  "triggered_by": "changes",
                  "_embedded":    {
                    "stages": [
                      {
                        "_links":       {
                          "self": {
                            "href": "http://localhost:8153/go/api/stages/up43/1/up43_stage/1"
                          },
                          "doc":  {
                            "href": "https://api.go.cd/current/#get-stage-instance"
                          }
                        },
                        "name":         "up43_stage",
                        "counter":      "1",
                        "status":       "Failed",
                        "approved_by":  "changes",
                        "scheduled_at": "2017-11-10T07:25:28.539Z"
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    };

    dashboard           = new Dashboard();
    const personalizeVM = new PersonalizeVM(Stream("Default"));
    personalizeVM.model(new Personalization([{name: "Default", state: []}], []));
    dashboard.initialize(dashboardJson);

    const dashboardViewModel           = new DashboardVM(dashboard);
    dashboardViewModel._performRouting = _.noop;

    m.mount(root, {
      view() {
        return m(DashboardWidget, {
          personalizeVM,
          showSpinner,
          pluginsSupportingAnalytics: {},
          shouldShowAnalyticsIcon:    false,
          doCancelPolling,
          doRefreshImmediately,
          vm:                         dashboardViewModel
        });
      }
    });
    m.redraw(true);
  }