Rewriting with Riot.js and Babel

feature/core
Sven Slootweg 9 years ago
parent ce10940e06
commit a108735c4b

@ -0,0 +1,3 @@
{
presets: ["es2015-riot"]
}

1
.gitignore vendored

@ -9,3 +9,4 @@ src/scss/*.css.map
src/elements/*.css
src/elements/*.css.map
/bower_components/
/old/

@ -1,42 +0,0 @@
express = require('express');
path = require('path');
favicon = require('static-favicon');
logger = require('morgan');
cookieParser = require('cookie-parser');
bodyParser = require('body-parser');
app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use("/bower_components", express.static(path.join(__dirname, 'bower_components')));
app.use "/", require("./routes/index")
app.use "/nodes", require("./routes/nodes")
app.use (req, res, next) ->
err = new Error("Not Found")
err.status = 404
next(err)
if app.get("env") == "development"
app.use (err, req, res, next) ->
res.status(err.status || 500)
res.render "error",
message: err.message
error: err
app.use (err, req, res, next) ->
res.status(err.status || 500)
res.render "error",
message: err.message
error: {}
module.exports = app;

@ -0,0 +1,20 @@
'use strict';
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
let app = express();
app.set("view engine", "jade");
app.set("views", path.join(__dirname, "views"));
app.use(express.static(path.join(__dirname, "public")));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use("/", require("./lib/routes/index"));
app.listen(3000);

@ -1,8 +0,0 @@
#!/usr/bin/env coffee
debug = require('debug')('openNG')
app = require('../app')
app.set('port', process.env.PORT ? 3000)
server = app.listen app.get('port'), ->
debug('Express server listening on port ' + server.address().port)

@ -1,8 +0,0 @@
{
"name": "openNG",
"dependencies": {
"platform": "Polymer/platform#~0.4.2",
"polymer": "Polymer/polymer#~0.5.5"
},
"devDependencies": {}
}

@ -1 +0,0 @@
module.exports = "hi"

@ -1,143 +1,81 @@
var gulp = require('gulp');
/* CoffeeScript compile deps */
var path = require('path');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var coffee = require('gulp-coffee');
var sass = require("gulp-sass");
var cache = require('gulp-cached');
var remember = require('gulp-remember');
var plumber = require('gulp-plumber');
var livereload = require('gulp-livereload');
var nodemon = require("gulp-nodemon");
var jade = require("gulp-jade");
var net = require("net");
var spy = require("through2-spy");
var webpack = require("gulp-webpack");
var named = require("vinyl-named");
var webpack = require("webpack-stream");
var webpackLib = require("webpack")
function namedLog(name) {
return function gutilLog(log) {
gc = gutil.colors;
var presetES2015 = require("@joepie91/gulp-preset-es2015");4
items = ["[- " + gc.magenta(name) + " -]"];
var nodemonRestarting = false;
for(i in arguments) {
items.push(arguments[i]);
function tryReload() {
if (nodemonRestarting === false) {
livereload.changed.apply(null, arguments);
}
gutil.log.apply(null, items);
}
}
tasks = {
coffee: [
{
name: "util",
source: ["templateUtil.coffee"],
base: ".",
destination: "."
}
],
jade: [
{
name: "views",
source: ["./views/client/**/*.jade"],
base: "./views/client",
destination: "./public/views"
}, {
name: "elements",
source: ["./src/elements/**/*.jade"],
base: "./src/elements",
destination: "./public/elements"
}
],
sass: [
{
name: "elements",
source: ["./src/elements/**/*.scss"],
base: "./src/elements",
destination: "./public/elements"
}
]
}
function concatName(type, name) {
return type + "-" + name;
}
for (var type in tasks) {
var subTasks = tasks[type];
for (var i in subTasks) {
var subTask = subTasks[i];
(function(type, subTask) {
var taskName = concatName(type, subTask.name);
gulp.task(taskName, function() {
var processor;
switch(type) {
case "coffee":
processor = coffee({bare: true});
break;
case "jade":
processor = jade({locals: require("./templateUtil")});
break;
case "sass":
processor = sass();
break;
}
return gulp.src(subTask.source, {base: subTask.base})
.pipe(plumber())
.pipe(cache(taskName))
.pipe(processor.on('error', gutil.log))
.pipe(spy.obj(namedLog(taskName)))
.pipe(remember(taskName))
.pipe(gulp.dest(subTask.destination));
/* The following resolves JacksonGariety/gulp-nodemon#33 */
process.once("SIGINT", function() {
process.exit(0);
});
})(type, subTask);
}
}
gulp.task("babel", function() {
return gulp.src("./src/**/*.js")
.pipe(presetES2015({
basePath: __dirname
}))
.pipe(gulp.dest("./lib"));
})
gulp.task('webpack', function(){
return gulp.src("./src/coffee/index.coffee")
return gulp.src("./src/frontend/index.js")
.pipe(webpack({
watch: true,
module: {
loaders: [{ test: /\.coffee$/, loader: "coffee-loader" }]
preLoaders: [{
test: /\.tag$/,
loader: "riotjs-loader",
exclude: /node_modules/,
query: {
type: "babel",
template: "jade"
}
}],
loaders: [
{ test: /\.js$/, loader: "babel-loader" },
{ test: /\.json$/, loader: "json-loader" },
//{ loader: "logging-loader" }
]
},
resolve: { extensions: ["", ".web.coffee", ".web.js", ".coffee", ".js"] }
plugins: [ new webpackLib.ProvidePlugin({riot: "riot"}) ],
resolveLoader: { root: path.join(__dirname, "node_modules") },
resolve: {
extensions: [
"",
".tag",
".web.js", ".js",
".web.json", ".json"
]
},
debug: false
}))
.pipe(rename("bundle.js"))
.pipe(gulp.dest("./public/js"));
});
gulp.task("webpack-elements", function() {
return gulp.src(["./src/elements/**/*.coffee"], {base: "./src/elements"})
.pipe(plumber())
.pipe(named())
.pipe(webpack({
watch: true,
module: {
loaders: [{ test: /\.coffee$/, loader: "coffee-loader" }]
},
resolve: { extensions: ["", ".web.coffee", ".web.js", ".coffee", ".js"] }
}))
.pipe(gulp.dest("./public/elements"));
});
function checkServerUp(){
setTimeout(function(){
var sock = new net.Socket();
sock.setTimeout(50);
sock.on("connect", function(){
nodemonRestarting = false;
console.log("Triggering page reload...");
livereload.changed();
tryReload("*");
sock.destroy();
})
.on("timeout", checkServerUp)
@ -146,34 +84,20 @@ function checkServerUp(){
}, 70);
}
var startupTasks = [];
var watchTasks = [];
for (var type in tasks) {
var subTasks = tasks[type];
for (var i in subTasks) {
var subTask = subTasks[i];
var taskName = concatName(type, subTask.name);
startupTasks.push(taskName);
watchTasks.push([subTask, taskName]);
}
}
gulp.task("nodemon", ["babel"], function() {
nodemon({
script: "./app.js",
delay: 500,
ignore: ["public"]
}).on("restart", function() {
nodemonRestarting = true;
}).on("start", checkServerUp);
})
gulp.task('watch', function () {
global.isWatching = true;
gulp.task('watch', ["nodemon"], function () {
livereload.listen();
gulp.watch(['./**/*.css', 'views/**/*.jade', '!views/client/**/*.jade', 'package.json']).on('change', livereload.changed);
gulp.watch(['public/views/**/*.html', 'public/elements/**/*']).on('change', function() { livereload.changed("*"); }); // We need to explicitly reload everything here; Polymer doesn't do partial reloading
for (i in watchTasks) {
task = watchTasks[i];
gulp.watch(task[0].source, [task[1]]);
}
nodemon({script: "./bin/www.coffee", ext: "coffee", delay: 500}).on("start", checkServerUp);
gulp.watch(['./**/*.css', 'views/**/*.jade', '!views/client/**/*.jade', 'package.json', "./public/js/**/*.js"]).on('change', tryReload);
gulp.watch(['public/views/**/*.html', 'public/elements/**/*']).on('change', function() { tryReload("*"); }); // We need to explicitly reload everything here; Polymer doesn't do partial reloading
});
startupTasks.push("webpack", "webpack-elements", "watch");
gulp.task('default', startupTasks);
gulp.task("default", ["watch", "webpack"]);

@ -0,0 +1,9 @@
'use strict';
require("../window");
require("../../views/sample-view");
require("../../views/node/create");
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,5 @@
'use strict';
require("../view-manager");
require("./component");

@ -0,0 +1,12 @@
'use strict';
var $ = require("jquery");
var riot = require("riot");
require("debug").enable("*");
require("../components/app");
$(function () {
riot.mount("*");
});

@ -0,0 +1,8 @@
'use strict';
module.exports = {
change: function change(data) {
Object.assign(this, data);
this.update();
}
};

@ -0,0 +1,68 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var riotQuery = require("riot-query");
var arrayDiff = require("arraydiff");
module.exports = {
init: function init() {
var _this = this;
var knownTags = [];
var listeners = {};
function triggerEvent(action, query, item) {
if (listeners[query] != null && listeners[query][action] != null) {
listeners[query][action].forEach(function (handler) {
handler(item);
});
}
}
this.on("updated", function () {
Object.keys(listeners).forEach(function (query) {
var currentTags = riotQuery(_this, query);
var diff = arrayDiff(knownTags, currentTags);
diff.forEach(function (item) {
if (item.type === "remove") {
for (var i = item.index; i < item.index + item.howMany; i++) {
triggerEvent("remove", query, knownTags[i]);
}
} else if (item.type === "move") {
for (var _i = item.index; _i < item.from + item.howMany; _i++) {
triggerEvent("move", query, knownTags[_i]);
}
} else if (item.type === "insert") {
item.values.forEach(function (value) {
triggerEvent("create", query, value);
});
}
});
knownTags = currentTags;
});
});
this.onChild = function (eventName, handler) {
var _eventName$split = eventName.split(":", 2);
var _eventName$split2 = _slicedToArray(_eventName$split, 2);
var action = _eventName$split2[0];
var query = _eventName$split2[1];
if (listeners[query] == null) {
listeners[query] = {};
}
if (listeners[query][action] == null) {
listeners[query][action] = [];
}
listeners[query][action].push(handler);
};
}
};

@ -0,0 +1,43 @@
'use strict';
var debounce = require("debounce");
var defaultValue = require("default-value");
var selectable = require("./selectable");
module.exports = function ($) {
selectable($);
$.fn.draggable = function () {
var _this = this;
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var debounceInterval = defaultValue(options.debounce, 10);
this.on("mousedown", function (event) {
var startX = event.pageX;
var startY = event.pageY;
var moveHandler = debounce(function (event) {
_this.trigger("draggable:move", [{
offsetX: event.pageX - startX,
offsetY: event.pageY - startY
}]);
}, debounceInterval);
$(document).on("mousemove", moveHandler);
$(document).one("mouseup", function (event) {
$(document).off("mousemove", moveHandler);
$(document).enableSelection();
_this.trigger("draggable:end");
});
$(document).disableSelection();
_this.trigger("draggable:start");
});
};
};

@ -0,0 +1,11 @@
'use strict';
module.exports = function ($) {
$.fn.disableSelection = function () {
return this.attr("unselectable", "on").css("user-select", "none").on("selectstart", false);
};
$.fn.enableSelection = function () {
return this.removeAttr("unselectable").css("user-select", "auto").off("selectstart", false);
};
};

@ -0,0 +1,140 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var elementSize = require("element-size");
var sortDockable = require("./util/sort-dockables");
function px(pixels) {
return pixels + "px";
}
module.exports = {
init: function init() {
var _this = this;
console.log("foo", this);
var dockableAPI = {
isActive: function isActive() {
return _this.opts.dockableContainer != null;
},
stack: [],
fillElement: null,
recalculateLayout: function recalculateLayout() {
dockableAPI.stack.forEach(function (item, i) {
item.stackIndex = i;
});
var orderedStack = dockableAPI.stack.slice().sort(sortDockable);
var reservedLeft = 0;
var reservedRight = 0;
var reservedTop = 0;
var reservedBottom = 0;
orderedStack.forEach(function (item) {
var element = item.tag.root;
/* We set the positioning to absolute *before* attempting
* to obtain the element size - this way, we can be sure
* that the element won't try to stretch to its container.
* Instead, it'll be auto-sized, which is exactly what we
* want. */
element.style.position = "absolute";
var _elementSize = elementSize(element);
var _elementSize2 = _slicedToArray(_elementSize, 2);
var width = _elementSize2[0];
var height = _elementSize2[1];
if (item.heightHint != null) {
height = item.heightHint;
}
if (item.widthHint != null) {
width = item.widthHint;
}
// FIXME: Should the following really be errors?
if ((item.side === "left" || item.side === "right") && width === 0) {
throw new Error("Cannot horizontally dock an element without a width; you may need to specify a dock-width");
} else if ((item.side === "top" || item.side === "bottom") && height === 0) {
throw new Error("Cannot vertically dock an element without a height; you may need to specify a dock-height");
}
if (item.side === "left") {
Object.assign(element.style, {
left: px(reservedLeft),
top: px(reservedTop),
bottom: px(reservedBottom)
});
delete element.style.right;
reservedLeft += width;
} else if (item.side === "right") {
Object.assign(element.style, {
right: px(reservedRight),
top: px(reservedTop),
bottom: px(reservedBottom)
});
delete element.style.left;
reservedRight += width;
} else if (item.side === "top") {
Object.assign(element.style, {
left: px(reservedLeft),
right: px(reservedRight),
top: px(reservedTop)
});
delete element.style.bottom;
reservedTop += height;
} else if (item.side === "bottom") {
Object.assign(element.style, {
left: px(reservedLeft),
right: px(reservedRight),
bottom: px(reservedBottom)
});
delete element.style.top;
reservedBottom += height;
}
console.log("reserved", reservedLeft, reservedRight, reservedTop, reservedBottom);
});
var item = dockableAPI.fillElement;
if (item != null) {
var element = item.root;
Object.assign(element.style, {
position: "absolute",
left: px(reservedLeft),
right: px(reservedRight),
top: px(reservedTop),
bottom: px(reservedBottom)
});
}
console.log("ordered stack", orderedStack);
}
};
this._uikitDockableContainer = dockableAPI;
this.on("mount", function () {
console.log("dockable-container mounted");
if (dockableAPI.isActive()) {
dockableAPI.recalculateLayout();
}
});
}
};

@ -0,0 +1,52 @@
'use strict';
var inArray = require("in-array");
function findContainer(tag) {
var lastTag = tag;
var dockableContainer = void 0;
while (dockableContainer == null && lastTag != null) {
var candidate = lastTag.parent;
if (candidate != null && candidate._uikitDockableContainer != null && candidate._uikitDockableContainer.isActive()) {
dockableContainer = candidate;
} else {
lastTag = candidate;
}
}
if (dockableContainer != null) {
return dockableContainer;
} else {
// FIXME: Better error reporting?
throw new Error("Could not find a dockable container for tag");
}
}
module.exports = {
init: function init() {
if (this.opts.dock != null) {
var dockableContainer = findContainer(this);
var containerData = dockableContainer._uikitDockableContainer;
if (inArray(["bottom", "top", "left", "right"], this.opts.dock)) {
containerData.stack.push({
tag: this,
side: this.opts.dock,
order: this.opts.dockOrder,
widthHint: this.opts.dockWidth,
heightHint: this.opts.dockHeight
});
} else if (this.opts.dock === "fill") {
if (containerData.fillElement != null) {
throw new Error("There can be only one tag with a `dock` setting of `fill` within a dockable container");
} else {
containerData.fillElement = this;
}
} else {
throw new Error("Invalid `dock` property; must be one of bottom, top, left, right, fill");
}
}
}
};

@ -0,0 +1,36 @@
'use strict';
module.exports = function (a, b) {
var aOrder = void 0,
bOrder = void 0;
if (a.order != null) {
aOrder = parseInt(a.order);
}
if (b.order != null) {
bOrder = parseInt(b.order);
}
if (aOrder != null && bOrder == null) {
return -1;
} else if (aOrder == null && bOrder != null) {
return 1;
} else if (aOrder != null && bOrder != null) {
if (aOrder < bOrder) {
return -1;
} else if (aOrder > bOrder) {
return 1;
} else {
return 0;
}
} else {
if (a.stackIndex < b.stackIndex) {
return -1;
} else if (a.stackIndex > b.stackIndex) {
return 1;
} else {
return 0;
}
}
};

@ -0,0 +1,21 @@
"use strict";
var router = require("express-promise-router")();
router.get("/", function (req, res) {
res.render("layout");
});
router.get("/node/:uuid", function (req, res) {
res.json({ uuid: req.params.uuid });
});
router.get("/test1", function (req, res) {
res.send("test ONE <a href='/test2'>go to 2 instead</a> <a href='/test2' target='_blank'>or in a new window</a>");
});
router.get("/test2", function (req, res) {
res.send("test TWO <a href='/test1'>go to 1 instead</a> <a href='/test1' target='_blank'>or in a new window</a>");
});
module.exports = router;

@ -0,0 +1,14 @@
'use strict';
require("../../../components/uikit/frame");
require("../../../components/uikit/toolbar");
require("../../../components/uikit/button");
require("../../../components/uikit/form-section");
require("../../../components/uikit/input-spawner");
require("../../../components/uikit/input");
require("../../../components/uikit/textarea");
require("../../../components/uikit/autocomplete");
require("../../../components/window-meta");
require("./component");

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "Attribute",
tableName: "attributes"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "AttributeSource",
tableName: "attribute_sources"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "AttributeType",
tableName: "attribute_types"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "Bin",
tableName: "bins"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "BinAuthorization",
tableName: "bin_authorizations"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "BinItem",
tableName: "bin_items"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "BinProjectAssociation",
tableName: "bin_project_associations"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "Clearance",
tableName: "clearances"
idAttribute: "id"

@ -1,8 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "Node",
tableName: "nodes"
idAttribute: "id"
relationIdAttribute: "perma_id"
type: -> this.belongsTo "NodeType", "type_id"
tags: -> this.belongsToMany("NodeTag").through "NodeTagAssociation"
attributes: -> this.hasMany "Attribute", "node_id"

@ -1,8 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "NodeTag",
tableName: "node_tags"
idAttribute: "id"
nodes: ->
wrappedModel = Object.create(bookshelf.model("NodeTag"))
wrappedModel.idAttribute =
this.belongsToMany("NodeTag").through "NodeTagAssociation"

@ -1,6 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "NodeTagAssociation",
tableName: "node_tag_associations"
idAttribute: "id"
node: this.belongsTo "Node", "node_id"
tag: this.belongsTo "NodeTag", "tag_id"

@ -1,5 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "NodeType",
tableName: "node_types"
idAttribute: "id"
nodes: this.hasMany "Node", "type_id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "Project",
tableName: "projects"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "ProjectAuthorization",
tableName: "project_autorizations"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "Reference",
tableName: "references"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "Relationship",
tableName: "relationships"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "RelationshipReference",
tableName: "relationship_references"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "RelationshipSource",
tableName: "relationship_sources"
idAttribute: "id"

@ -1,4 +0,0 @@
module.exports = (bookshelf) ->
bookshelf.model "RelationshipType",
tableName: "relationship_types"
idAttribute: "id"

@ -6,40 +6,58 @@
"start": "node ./bin/www"
},
"dependencies": {
"angular-ui-router": "^0.2.10",
"bluebird": "^2.3.2",
"body-parser": "~1.0.0",
"cookie-parser": "~1.0.1",
"debug": "~0.7.4",
"express": "~4.2.0",
"express-promise-router": "0.0.6",
"gulp-remember": "^0.3.0",
"arraydiff": "^0.1.3",
"bhttp": "^1.2.1",
"bluebird": "^3.0.6",
"body-parser": "^1.14.1",
"cookie-parser": "^1.4.0",
"debug": "^2.2.0",
"default-value": "0.0.3",
"express": "^4.13.3",
"express-promise-router": "0.0.9",
"extend": "^3.0.0",
"highland": "^2.4.0",
"jade": "~1.3.0",
"in-array": "^0.1.2",
"jade": "^1.11.0",
"jquery": "^2.1.1",
"lodash": "^2.4.1",
"morgan": "~1.0.0",
"static-favicon": "~1.0.0",
"vinyl-named": "^1.1.0"
"lodash": "^3.10.1",
"morgan": "^1.6.1",
"node-sass": "^3.2.0",
"null-loader": "^0.1.1",
"riot": "^2.4.0",
"riot-query": "0.0.2",
"serve-favicon": "^2.3.0",
"uuid": "^2.0.1",
"vinyl-named": "^1.1.0",
"xtend": "^4.0.1"
},
"devDependencies": {
"@joepie91/gulp-preset-es2015": "^1.0.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015-riot": "^1.1.0",
"brfs": "^1.4.1",
"coffee-loader": "^0.7.2",
"coffee-script": "^1.9.1",
"gulp": "~3.8.0",
"gulp-cached": "~0.0.3",
"gulp-coffee": "~2.0.1",
"gulp-concat": "~2.2.0",
"gulp-jade": "^0.7.0",
"gulp-livereload": "~2.1.0",
"gulp-nodemon": "~1.0.4",
"gulp-notify": "^1.6.0",
"gulp-plumber": "~0.6.3",
"gulp-remember": "~0.3.0",
"gulp-rename": "~1.2.0",
"gulp-sass": "^1.3.3",
"gulp-util": "~2.2.17",
"gulp-webpack": "^1.2.0",
"pretty-hrtime": "^0.2.1",
"through2-spy": "^1.2.0"
"debounce": "^1.0.0",
"element-size": "^1.1.1",
"gulp": "^3.9.0",
"gulp-cached": "^1.1.0",
"gulp-coffee": "^2.3.1",
"gulp-concat": "^2.6.0",
"gulp-jade": "^1.1.0",
"gulp-livereload": "^3.8.1",
"gulp-named-log": "0.0.7",
"gulp-nodemon": "^2.0.4",
"gulp-plumber": "^1.0.1",
"gulp-remember": "^0.3.0",
"gulp-rename": "^1.2.0",
"gulp-sass": "^2.1.0",
"gulp-util": "^3.0.7",
"json-loader": "^0.5.4",
"path-to-regexp": "^1.2.1",
"riotjs-loader": "^1.2.0",
"through2-spy": "^2.0.0",
"transform-loader": "^0.2.3",
"webpack-stream": "^2.3.0"
}
}

@ -1,6 +0,0 @@
i {
margin-right: 5px; }
button[type="submit"] {
background-color: #148C29;
color: white; }

@ -1 +0,0 @@
<link rel="import" href="/bower_components/polymer/polymer.html"/><polymer-element name="pn-button" constructor="pnButton" attributes="type icon label" noscript="noscript"><template><link rel="stylesheet" href="button.css"/><link rel="stylesheet" href="/stylesheets/pure-min.css"/><link rel="stylesheet" href="/stylesheets/font-awesome.min.css"/><button type="{{type}}" class="pure-button"><i class="fa fa-{{icon}}"></i>{{label}}</button></template></polymer-element>

@ -1,2 +0,0 @@
contents.main {
overflow: auto; }

@ -1 +0,0 @@
<link rel="import" href="/bower_components/polymer/polymer.html"/><polymer-element name="pn-frame" constructor="pnFrame"><template><link rel="stylesheet" href="frame.css"/><div id="polymerWrapper"><content select="pn-toolbar" class="docks"></content><content class="main"></content></div></template><script src="frame.js"></script></polymer-element>

@ -1,58 +0,0 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
Polymer("pn-frame", {});
/***/ }
/******/ ])

@ -1 +0,0 @@
<link rel="import" href="/bower_components/polymer/polymer.html"/><polymer-element name="openng-router" constructor="ngRouter"><script src="router.js"></script></polymer-element>

File diff suppressed because it is too large Load Diff

@ -1 +0,0 @@
<link rel="import" href="/bower_components/polymer/polymer.html"/><polymer-element name="pn-toolbar" constructor="pnToolbar" attributes="dock align width height" noscript="noscript"><template><link rel="stylesheet" href="toolbar.css"/><content class="dock-{{dock}} align-{{align}}"></content></template></polymer-element>

@ -1 +0,0 @@
<link rel="import" href="/bower_components/polymer/polymer.html"/><polymer-element name="openng-window-manager" constructor="ngWindowManager"><script src="window-manager.js"></script></polymer-element>

File diff suppressed because it is too large Load Diff

@ -1,115 +0,0 @@
.noscroll {
overflow-x: hidden !important;
overflow-y: hidden !important; }
/* Common styling */
.wrapper {
position: absolute; }
.title {
-webkit-box-shadow: 5px 5px 10px #1a1a1a;
-moz-box-shadow: 5px 5px 10px #1a1a1a;
box-shadow: 5px 5px 10px #1a1a1a;
position: absolute;
z-index: 2;
left: 0px;
right: 0px;
top: 0px;
cursor: default;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
height: 16px;
color: white;
font-size: 14px;
font-weight: bold;
padding: 4px;
padding-left: 7px;
border-top: 1px solid #959595;
border-right: 1px solid #959595;
border-left: 1px solid #959595;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #525252), color-stop(1, #91acbe));
background-image: -moz-linear-gradient(center bottom, #525252 0%, #91acbe 100%);
filter: alpha(opacity=95);
opacity: 0.95; }
.outer {
-webkit-box-shadow: 5px 5px 10px #1a1a1a;
-moz-box-shadow: 5px 5px 10px #1a1a1a;
box-shadow: 5px 5px 10px #1a1a1a;
position: absolute;
z-index: 3;
left: 0px;
right: 0px;
bottom: 0px;
font-size: 13px;
top: 25px;
border-bottom: 1px solid gray;
border-right: 1px solid gray;
border-left: 1px solid gray;
background-color: #F7F7F0;
filter: alpha(opacity=95);
opacity: 0.95; }
.inner-wrapper {
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
overflow-y: auto;
overflow-x: auto; }
.inner {
padding: 7px; }
.close {
float: right; }
.close a {
position: absolute;
right: 3px;
top: 2px;
display: block;
padding: 1px 4px;
text-decoration: none;
font-size: 12px;
border-radius: 5px;
color: white;
border: 1px solid #014D8C; }
.close a:hover {
background-color: #014D8C;
border: 1px solid white; }
.resizer {
position: absolute;
width: 12px;
height: 12px;
bottom: -6px;
right: -6px;
cursor: se-resize; }
/* Special states */
.focused .title {
border-top: 1px solid #6262FF;
border-right: 1px solid #6262FF;
border-left: 1px solid #6262FF;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #0057b3), color-stop(1, #0099ff));
background-image: -moz-linear-gradient(center bottom, #0057b3 0%, #0099ff 100%);
filter: alpha(opacity=85);
opacity: 0.85; }
.dragged .title {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background-color: #0070D5;
background-image: none; }
.dragged .outer {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background: none; }
.dragged .inner {
visibility: hidden; }

@ -1 +0,0 @@
<link rel="import" href="/bower_components/polymer/polymer.html"/><link rel="import" href="/elements/router.html"/><polymer-element name="openng-window" constructor="ngWindow"><template><link rel="stylesheet" href="window.css"/><div id="polymerWrapper"><template if="{{visible}}"><div style="width: {{width}}px; height: {{height}}px; left: {{x}}px; top: {{y}}px; z-index: {{z}};" class="wrapper {{ {focused: focused, dragged: dragged} | tokenList }}"><div class="title"><div class="title-inner">{{ windowTitle }}</div><div class="close"><a href="#">X</a></div></div><div class="outer"><div class="inner-wrapper"><div class="inner"><!-- View goes here--><openng-router url="{{url}}" external-handler="{{_externalHandler}}"></openng-router></div></div><template if="{{resizable}}"><div class="resizer"></div></template></div></div></template></div></template><script src="window.js"></script></polymer-element>

@ -1,284 +0,0 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(4);
/***/ },
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/***/ function(module, exports, __webpack_require__) {
var RateLimitedCall, polymerDefer;
RateLimitedCall = __webpack_require__(5);
polymerDefer = __webpack_require__(6);
Polymer("openng-window", {
publish: {
windowTitle: "",
url: "",
x: 200,
y: 200,
z: 0,
width: 400,
height: 300,
resizable: true,
visible: true,
focused: false,
dragged: false,
focus: function() {
return polymerDefer((function(_this) {
return function() {
return _this._manager.focus(_this);
};
})(this));
}
},
_externalHandler: function(url, method, options) {
var blankWindow;
blankWindow = new ngWindow();
blankWindow.url = url;
return $(blankWindow).insertAfter($(this));
},
_findWindowManager: function() {
var result;
result = $(this).closest("openng-window-manager");
if (result.length > 0) {
return result[0];
} else {
return void 0;
}
},
_register: function() {
this._manager = this._findWindowManager();
if (this._manager != null) {
return polymerDefer((function(_this) {
return function() {
return _this._manager.add(_this);
};
})(this));
}
},
_unregister: function() {
if (this._manager != null) {
return this._manager.remove(this);
}
},
_hookMoveEvents: function() {
var moveCall, self;
self = this;
moveCall = new RateLimitedCall(60, function() {
self.x = this.x - self.dragOffsetX;
return self.y = this.y - self.dragOffsetY;
});
return this._shadowDOM.find(".title").on("mousedown", (function(_this) {
return function(event) {
var moveHandler;
$("body").attr("unselectable", "on").css("user-select", "none").on("selectstart.disableSelect", false);
_this.dragOffsetX = event.pageX - _this.x;
_this.dragOffsetY = event.pageY - _this.y;
moveHandler = function(event) {
return moveCall.call(function() {
this.x = event.pageX;
return this.y = event.pageY;
});
};
_this.dragged = true;
$(document).on("mousemove", moveHandler);
return $(document).one("mouseup", function(event) {
_this.dragged = false;
$(document).off("mousemove", moveHandler);
return $("body").attr("unselectable", "off").css("user-select", "text").off("selectstart.disableSelect");
});
};
})(this));
},
_hookResizeEvents: function() {
var resizeCall, self;
self = this;
resizeCall = new RateLimitedCall(60, function() {
self.width = this.x - self.resizeOffsetX - self.x;
return self.height = this.y - self.resizeOffsetY - self.y;
});
return this._shadowDOM.find(".resizer").on("mousedown", (function(_this) {
return function(event) {
var resizeHandler;
$("body").attr("unselectable", "on").css("user-select", "none").on("selectstart.disableSelect", false);
_this.resizeOffsetX = (event.pageX - _this.x) - _this.width;
_this.resizeOffsetY = (event.pageY - _this.y) - _this.height;
resizeHandler = function(event) {
return resizeCall.call(function() {
this.x = event.pageX;
return this.y = event.pageY;
});
};
_this.dragged = true;
$(document).on("mousemove", resizeHandler);
return $(document).one("mouseup", function(event) {
_this.dragged = false;
$(document).off("mousemove", resizeHandler);
return $("body").attr("unselectable", "off").css("user-select", "text").off("selectstart.disableSelect");
});
};
})(this));
},
_hookCloseButton: function() {
return this._shadowDOM.find(".close a").on("mousedown", function(event) {
return event.stopPropagation();
}).on("click", (function(_this) {
return function(event) {
return $(_this).remove();
};
})(this));
},
_hookFocus: function() {
return this._shadowDOM.find(".wrapper").on("mousedown", (function(_this) {
return function(event) {
return _this.focus();
};
})(this));
},
ready: function() {
this._externalHandler = this._externalHandler.bind(this);
return this._shadowDOM = $(this.$.polymerWrapper);
},
domReady: function() {
this._hookMoveEvents();
this._hookResizeEvents();
this._hookCloseButton();
this._hookFocus();
this._register();
return this.focus();
},
detached: function() {
return this._unregister();
},
urlChanged: function(oldValue, newValue) {
if (newValue !== "") {
return this._shadowDOM.find("openng-router")[0].navigate(newValue);
}
}
});
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
var RateLimitedCall;
module.exports = RateLimitedCall = (function() {
RateLimitedCall.prototype.loopRunning = false;
RateLimitedCall.prototype._lastFrame = Date.now();
function RateLimitedCall(fps, frameHandler) {
this.fps = fps;
this.frameHandler = frameHandler;
this._interval = 1000 / this.fps;
}
RateLimitedCall.prototype._loop = function() {
this.loopRunning = true;
return this._frame();
};
RateLimitedCall.prototype._frame = function() {
var delta, now;
now = Date.now();
delta = now - this._lastFrame;
if (delta > this._interval) {
if (this.callActivated) {
this.frameHandler.apply(this);
this.callActivated = false;
this._lastFrame = now - (delta % this._interval);
} else {
this.loopRunning = false;
}
}
if (this.loopRunning) {
return requestAnimationFrame(this._frame.bind(this));
}
};
RateLimitedCall.prototype._activateRateLimitedCall = function() {
this.callActivated = true;
if (!this.loopRunning) {
return this._loop();
}
};
RateLimitedCall.prototype.call = function(func) {
func.apply(this);
return this._activateRateLimitedCall();
};
return RateLimitedCall;
})();
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
module.exports = function(func) {
if (window.polymerReady) {
return func();
} else {
return $(window).on("polymer-ready", function(event) {
return func();
});
}
};
/***/ }
/******/ ])

File diff suppressed because one or more lines are too long

@ -1,15 +0,0 @@
router = require("express-promise-router")()
router.get "/", (req, res) ->
res.render "layout"
router.get "/node/:uuid", (req, res) ->
res.json {"uuid": req.params.uuid}
router.get "/test1", (req, res) ->
res.send "test ONE <a href='/test2'>go to 2 instead</a> <a href='/test2' target='_blank'>or in a new window</a>"
router.get "/test2", (req, res) ->
res.send "test TWO <a href='/test1'>go to 1 instead</a> <a href='/test1' target='_blank'>or in a new window</a>"
module.exports = router

@ -1,6 +0,0 @@
router = require("express-promise-router")()
router.get "/create", (req, res) ->
res.render "nodes/create"
module.exports = router

@ -1,10 +0,0 @@
global.$ = $ = require "jquery"
OverlayDrawer = require "./lib/OverlayDrawer"
RateLimitedCall = require "./lib/RateLimitedCall"
$ ->
overlayDrawer = new OverlayDrawer($ "canvas.overlay")
$(window).on "polymer-ready", (event) ->
# This is for polymer-defer calls.
window.polymerReady = true

@ -1,97 +0,0 @@
$ = require "jquery"
class OverlayDrawer
_objects: []
_targetCanvas: null
_pendingWindowResize: null
_lastDraw: Date.now()
_interval: 1000 / 30
_processCommonStyles: (context, style) ->
context.fillStyle = style.fillColor ? "transparent"
context.strokeStyle = style.lineColor ? "black"
context.globalAlpha = style.lineColor ? 1
context.lineWidth = style.lineWidth ? 1
context.lineCap = style.lineCap ? "butt"
context.lineJoin = style.lineJoin ? "miter"
context.miterLimit = style.miterLimit ? 10
return context
_drawFrame: =>
now = Date.now()
delta = now - @_lastDraw
if delta > @_interval
# Process any canvas resizes as a consequence of the parent window being resized by the user
if @_pendingWindowResize
[@_targetCanvas[0].width, @_targetCanvas[0].height] = @_pendingWindowResize
@_targetCanvas.css
width: @_pendingWindowResize[0]
height: @_pendingWindowResize[1]
@_pendingWindowResize = null
# Clear the canvas
context = @_targetCanvas[0].getContext("2d");
context.clearRect 0, 0, @_targetCanvas[0].width, @_targetCanvas[0].height
# Draw all the currently active objecs
for object in @_objects
object._draw context
# The following assumes that frame draw duration < frame draw interval!
# TODO: Investigate other approaches for doing this...
@_lastDraw = now - (delta % @_interval)
# If we still have objects left, request a new animation frame
if @_objects.length > 0
window.requestAnimationFrame @_drawFrame
_triggerDraw: =>
window.requestAnimationFrame @_drawFrame
constructor: (canvas) ->
@_targetCanvas = canvas
canvas.css
position: "absolute"
top: "0px"
left: "0px"
"z-index": "999999999"
"pointer-events": "none"
resizeHandler = =>
@_pendingWindowResize = [$(window).width(), $(window).height()]
@_triggerDraw()
$ window
.on "resize", resizeHandler
# Do an initial resize to make our canvas stretch across the screen
resizeHandler()
removeObject: (object) =>
@_objects = (obj for obj in @_objects when obj != object)
createLine: =>
newObj = new OverlayLine(this)
@_objects.push newObj
@_triggerDraw()
return newObj
class OverlayLine
constructor: (drawer) ->
@_drawer = drawer
_startPosition: null
_endPosition: null
_style: {}
_draw: (context) =>
context.beginPath()
context.moveTo @_startPosition[0], @_startPosition[1]
context.lineTo @_endPosition[0], @_endPosition[1]
@_drawer._processCommonStyles context, @_style
context.stroke()
setStyle: (style) =>
@_style = style
return this
updateStart: (position) =>
@_startPosition = position
return this
updateEnd: (position) =>
@_endPosition = position
return this
module.exports = OverlayDrawer

@ -1,34 +0,0 @@
module.exports = class RateLimitedCall
loopRunning: false
_lastFrame: Date.now()
constructor: (@fps, @frameHandler) ->
@_interval = 1000 / @fps
_loop: ->
@loopRunning = true
@_frame()
_frame: ->
now = Date.now()
delta = now - @_lastFrame
if delta > @_interval
if @callActivated
@frameHandler.apply(this)
@callActivated = false
@_lastFrame = now - (delta % @_interval)
else
@loopRunning = false
if @loopRunning
requestAnimationFrame @_frame.bind(this)
_activateRateLimitedCall: ->
@callActivated = true
if not @loopRunning
@_loop()
call: (func) ->
func.apply(this)
@_activateRateLimitedCall()

@ -1,6 +0,0 @@
module.exports = (func) ->
if window.polymerReady
func()
else
$(window).on "polymer-ready", (event) ->
func()

@ -0,0 +1,50 @@
app
window(each="{windows}", router="{router}", window-title="{title}", width=640, height=480, x="{x}", y="{y}", z=0, resizable="true", url="{url}")
script.
const stateRouter = require("../../frontend/riot-state-router");
this.mixin(require("../../frontend/riot-on-child"));
this.mixin(require("riot-query").mixin);
this.windows = [
{ title: "test one", x: 10, y: 10, url: "/" },
{ title: "test two", x: 200, y: 200, url: "/" },
{ title: "", x: 390, y: 390, url: "/nodes/create" }
]
let currentZIndex = 0;
let router = stateRouter();
router.get("/", (req, res) => {
res.render("sample", {
text: "Hello World!"
});
});
router.get("/nodes/create", (req, res) => {
res.render("node-create");
});
this.router = router;
this.onChild("create:window", (window) => {
window.on("focused", () => {
this.query("window").filter((otherWindow) => {
return otherWindow !== window;
}).forEach((otherWindow) => {
otherWindow.defocus();
});
window.setZIndex(currentZIndex++);
});
window.on("requestClose", () => {
window.reportClose();
this.windows = this.windows.filter((windowItem) => windowItem !== window._item);
this.update();
});
window.focus();
});

@ -0,0 +1,9 @@
'use strict';
require("../window");
require("../../views/sample-view");
require("../../views/node/create");
require("./component");

@ -0,0 +1,8 @@
uikit-autocomplete
div
!= "<yield/>"
style.
script.

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,24 @@
uikit-button
button.pure-button(type="{opts.type}", class="{confirm: opts.type === 'submit', cancel: opts.type === 'cancel', normal: opts.type == null}")
i(if="{opts.icon != null}", class="fa fa-{opts.icon}")
!= "<yield/>"
style(scoped, type="scss").
button {
font-weight: bold;
&.confirm {
background-color: #006B00;
color: white;
}
&.cancel {
background-color: #AF0000;
color: white;
}
&.normal {
background-color: #1B4AB5;
color: white;
}
}

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,8 @@
uikit-form-section
div
!= "<yield/>"
style.
script.

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,16 @@
uikit-frame
.frame-wrapper
!= "<yield/>"
script.
this.mixin(require("../../../riot/mixins/dockable-container"));
this.mixin(require("../../../riot/mixins/dockable"));
style(type="scss").
uikit-frame {
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
}

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,8 @@
uikit-input-spawner
div
!= "<yield/>"
style.
script.

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,8 @@
uikit-input
label {opts.label}
input(type="{opts.type}", name="{opts.name}")
style.
script.

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,8 @@
uikit-textarea
div
!= "<yield/>"
style.
script.

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,8 @@
uikit-toolbar
div
!= "<yield/>"
style.
script.
this.mixin(require("../../../riot/mixins/dockable"));

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,41 @@
view-manager
script.
const Promise = require("bluebird");
const $ = require("jquery");
const defaultValue = require("default-value");
Object.assign(this, {
currentView: null,
viewPrefix: defaultValue(opts.viewPrefix, "uikit-view"),
switchView: function(viewName, locals) {
if (this.currentView != null) {
this.currentView.unmount(); // FIXME: Do we need more cleanup here?
}
let viewElementName = `${this.viewPrefix}-${viewName}`;
let newViewElement = $(`<${viewElementName}>`).appendTo(this.root);
this.currentView = riot.mount(newViewElement[0], viewElementName, locals)[0];
this.trigger("switched");
},
navigate: function(method, uri, data = {}) {
return Promise.try(() => {
this.trigger("navigating");
return opts.router.handle(method, uri, data);
}).then((response) => {
response.actions.forEach((action) => {
if (action.type === "render") {
this.switchView(action.viewName, action.locals);
}
});
this.trigger("navigated");
})
}
});
["get", "post", "put", "delete", "patch", "head"].forEach((method) => {
this[method] = this.navigate.bind(this, method);
});

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,9 @@
window-meta
span
script.
Object.assign(this, {
windowTitle: opts.windowTitle,
requestedWidth: opts.requestWidth,
requestedHeight: opts.requestHeight
})

@ -0,0 +1,3 @@
'use strict';
require("./component");

@ -0,0 +1,377 @@
window
div(class="wrapper {focused: focused, dragged: dragged}")
.title
.title-inner { windowTitle }
.close
a(href="#") X
.outer
.inner-wrapper
.inner
view-manager(router="{router}", view-prefix="openng-view")
.resizer(show="{opts.resizable}")
script.
const $ = require("jquery");
const debounce = require("debounce");
const query = require("riot-query");
require("../../jquery/draggable")($);
this.mixin(query.mixin);
this.mixin(require("../../frontend/riot-change"));
Object.assign(this, {
dragged: false,
focused: false,
resized: false,
width: parseInt(opts.width),
height: parseInt(opts.height),
windowTitle: opts.windowTitle,
//x: parseInt(opts.x),
//y: parseInt(opts.y),
z: parseInt(opts.z),
focus: () => {
this.trigger("focused");
this.change({
focused: true
});
},
defocus: () => {
this.trigger("defocused");
this.change({
focused: false
});
},
setZIndex: (index) => {
this.change({
z: index
});
},
setSize: (width, height) => {
this.change({
width: width,
height: height
});
},
setWidth: (width) => {
this.change({
width: width
});
},
setHeight: (height) => {
this.change({
height: height
});
},
setTitle: (title) => {
this.change({
windowTitle: title
});
},
reportClose: () => {
this.trigger("closing");
},
_handleMouseDown: (event) => {
this.focus();
}
});
this.on("updated", () => {
//console.log("UPDATED", this, opts);
$(this.queryOne("//.wrapper")).css({
left: `${this.x}px`,
top: `${this.y}px`,
width: `${this.width}px`,
height: `${this.height}px`,
zIndex: this.z
});
});
this.on("mount", () => {
let viewManager = this.queryOne("view-manager");
let resizeHandle = $(this.queryOne("//.resizer"));
let titleBar = $(this.queryOne("//.title"));
let closeButton = $(this.queryOne("//.close"));
if (opts.url != null) {
viewManager.get(opts.url);
}
viewManager.on("switched", () => {
query(viewManager.currentView, "window-meta").forEach((windowMeta) => {
if (windowMeta.windowTitle != null) {
this.setTitle(windowMeta.windowTitle);
}
if (windowMeta.requestedWidth != null) {
this.setWidth(windowMeta.requestedWidth);
}
if (windowMeta.requestedHeight != null) {
this.setHeight(windowMeta.requestedHeight);
}
})
});
closeButton.on("click", (event) => {
event.stopPropagation();
event.preventDefault;
this.trigger("requestClose");
})
let startWidth, startHeight;
resizeHandle.draggable();
resizeHandle.on("draggable:start", (event) => {
startWidth = this.width;
startHeight = this.height;
this.change({
resized: true
});
});
resizeHandle.on("draggable:end", (event) => {
this.change({
resized: false
});
});
resizeHandle.on("draggable:move", (event, data) => {
this.change({
width: startWidth + data.offsetX,
height: startHeight + data.offsetY
});
});
let startX, startY;
titleBar.draggable();
titleBar.on("draggable:start", (event) => {
startX = this.x;
startY = this.y;
this.change({
dragged: true
});
});
titleBar.on("draggable:end", (event) => {
this.change({
dragged: false
});
});
titleBar.on("draggable:move", (event, data) => {
this.change({
x: startX + data.offsetX,
y: startY + data.offsetY
});
});
$(this.queryOne("//.wrapper")).on("mousedown", () => {
this._handleMouseDown();
});
});
style(scoped, type="scss").
.noscroll
{
overflow-x: hidden !important;
overflow-y: hidden !important;
}
/* Common styling */
.wrapper
{
position: absolute;
}
@mixin shadow
{
-webkit-box-shadow: 5px 5px 10px #1a1a1a;
-moz-box-shadow: 5px 5px 10px #1a1a1a;
box-shadow: 5px 5px 10px #1a1a1a;
}
.title
{
@include shadow;
position: absolute;
z-index: 2;
left: 0px;
right: 0px;
top: 0px;
cursor: default;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
height: 16px;
color: white;
font-size: 14px;
font-weight: bold;
padding: 4px;
padding-left: 7px;
border-top: 1px solid #959595;
border-right: 1px solid #959595;
border-left: 1px solid #959595;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(82,82,82)),
color-stop(1, rgb(145,172,190))
);
background-image: -moz-linear-gradient(
center bottom,
rgb(82,82,82) 0%,
rgb(145,172,190) 100%
);
filter:alpha(opacity=95);
opacity:0.95;
}
.outer
{
@include shadow;
position: absolute;
z-index: 3;
left: 0px;
right: 0px;
bottom: 0px;
font-size: 13px;
top: 25px;
border-bottom: 1px solid gray;
border-right: 1px solid gray;
border-left: 1px solid gray;
background-color: #F7F7F0;
filter:alpha(opacity=95);
opacity:0.95;
}
.inner-wrapper
{
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
overflow-y: auto;
overflow-x: auto;
}
.inner
{
padding: 7px;
}
.close
{
float: right;
a
{
position: absolute;
right: 3px;
top: 2px;
display: block;
padding: 1px 4px;
text-decoration: none;
font-size: 12px;
border-radius: 5px;
color: white;
border: 1px solid #014D8C;
&:hover
{
background-color: #014D8C;
border: 1px solid white;
}
}
}
.resizer
{
position: absolute;
width: 12px;
height: 12px;
bottom: -6px;
right: -6px;
cursor: se-resize;
}
/* Special states */
.focused
{
.title
{
border-top: 1px solid #6262FF;
border-right: 1px solid #6262FF;
border-left: 1px solid #6262FF;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(0,87,179)),
color-stop(1, rgb(0,153,255))
);
background-image: -moz-linear-gradient(
center bottom,
rgb(0,87,179) 0%,
rgb(0,153,255) 100%
);
filter:alpha(opacity=85);
opacity:0.85;
}
}
@mixin noShadow
{
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
@mixin unselectable {
cursor: default;
user-select: none;
-webkit-user-select: none; /* Chrome/Safari/Opera */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE/Edge */
-webkit-touch-callout: none; /* iOS Safari */
}
.dragged
{
.title
{
@include noShadow;
background-color: #0070D5;
background-image: none;
}
.outer
{
@include noShadow;
background: none;
}
.inner
{
visibility: hidden;
}
}
.resized {
@include unselectable;
}

@ -0,0 +1,5 @@
'use strict';
require("../view-manager");
require("./component");

@ -1,25 +0,0 @@
mixin pmImport(name)
link(rel="import", href="/bower_components/#{name}/#{name}.html")
mixin pmImportPath(path)
link(rel="import", href="#{path}.html")
mixin pmStylesheet(name)
link(rel="stylesheet", href="#{name}.css")
mixin pmPureCSS
link(rel="stylesheet", href="/stylesheets/pure-min.css")
mixin pmFontAwesome
link(rel="stylesheet", href="/stylesheets/font-awesome.min.css")
mixin pmScript(name)
script(src="#{name}.js")
mixin pmIf(conditional)
template(if="{{#{conditional}}}")
block
mixin pmRepeat(collection)
template(repeat="{{#{collection}}}")
block

@ -1,12 +0,0 @@
include _polymer
+pmImport("polymer")
polymer-element(name="pn-button", constructor="pnButton", attributes="type icon label", noscript)
template
+pmStylesheet("button")
+pmPureCSS
+pmFontAwesome
button.pure-button(type="{{type}}")
i(class="fa fa-{{icon}}")
| {{label}}

@ -1,10 +0,0 @@
i
{
margin-right: 5px;
}
button[type="submit"]
{
background-color: #148C29;
color: white;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save