Skip to content

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
henning-krause committed Jun 6, 2016
1 parent 16f70cc commit 376b4f8
Show file tree
Hide file tree
Showing 13 changed files with 590 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .tfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build\*
dist\*
jspm_packages\*
node_modules\*
21 changes: 21 additions & 0 deletions build/paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var appRoot = 'src/';
var outputRoot = 'dist/';
var exporSrvtRoot = 'export/';
var jspmPackages = 'jspm_packages/';
var typings = 'typings/';

module.exports = {
root: appRoot,
source: appRoot + '**/*.js',
sourceMaps: "../maps",
html: appRoot + '**/*.html',
css: appRoot + '**/*.css',
sass: 'styles/**/*.scss',
cssOutput: outputRoot,
style: 'styles/**/*.css',
output: outputRoot,
exportSrv: exporSrvtRoot,
doc: './doc',
e2eSpecsSrc: 'test/e2e/src/*.js',
e2eSpecsDist: 'test/e2e/dist/',
};
43 changes: 43 additions & 0 deletions build/tasks/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict'

var gulp = require('gulp');
var bump = require('gulp-bump')
var babel = require('gulp-babel');
var sourcemaps = require('gulp-sourcemaps');
var changed = require('gulp-changed');
var runSequence = require('run-sequence');
var paths = require("../paths")

var compilerOptions = {
moduleIds: false,
comments: false,
compact: false,
presets: ["es2015", "stage-0"],
plugins: ["transform-es2015-modules-systemjs", "transform-decorators-legacy", "transform-decorators", ]
};

gulp.task('build-html', function() {
return gulp.src(paths.html)
.pipe(gulp.dest(paths.output));
});

gulp.task('build-js', function() {
return gulp.src(paths.source)
.pipe(changed(paths.output), {extension: '.js'})
// .pipe(sourcemaps.init({loadMaps: true}))
.pipe(babel(compilerOptions))
// .pipe(sourcemaps.write({includeContent: true}))
.pipe(gulp.dest(paths.output));
});

gulp.task('bump-version', function() {
return gulp.src('./package.json')
.pipe(bump({type: 'patch'}))
.pipe(gulp.dest('./'));

})
gulp.task('build', function(callback) {
return runSequence(
['build-html', 'build-js'],
callback
)});
16 changes: 16 additions & 0 deletions build/tasks/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var gulp = require('gulp');
var paths = require('../paths');

// outputs changes to files to the console
function reportChange(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}

// this task wil watch for changes
// to js, html, and css files and call the
// reportChange method. Also, by depending on the
// serve task, it will instantiate a browserSync session
gulp.task('watch', ['build'], function() {
gulp.watch(paths.source, ['build-js']).on('change', reportChange);
gulp.watch(paths.html, ['build-html']).on('change', reportChange);
});
3 changes: 3 additions & 0 deletions dist/aurelia-froala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div></div>
</template>
194 changes: 194 additions & 0 deletions dist/aurelia-froala.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
'use strict';

System.register(['aurelia-framework', 'aurelia-binding', 'aurelia-i18n', 'jquery', 'aurelia-event-aggregator'], function (_export, _context) {
"use strict";

var customElement, bindable, inject, ObserverLocator, I18N, $, EventAggregator, _createClass, _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, AureliaFroala;

function _initDefineProp(target, property, descriptor, context) {
if (!descriptor) return;
Object.defineProperty(target, property, {
enumerable: descriptor.enumerable,
configurable: descriptor.configurable,
writable: descriptor.writable,
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
});
}

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
var desc = {};
Object['ke' + 'ys'](descriptor).forEach(function (key) {
desc[key] = descriptor[key];
});
desc.enumerable = !!desc.enumerable;
desc.configurable = !!desc.configurable;

if ('value' in desc || desc.initializer) {
desc.writable = true;
}

desc = decorators.slice().reverse().reduce(function (desc, decorator) {
return decorator(target, property, desc) || desc;
}, desc);

if (context && desc.initializer !== void 0) {
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
desc.initializer = undefined;
}

if (desc.initializer === void 0) {
Object['define' + 'Property'](target, property, desc);
desc = null;
}

return desc;
}

function _initializerWarningHelper(descriptor, context) {
throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
}

return {
setters: [function (_aureliaFramework) {
customElement = _aureliaFramework.customElement;
bindable = _aureliaFramework.bindable;
inject = _aureliaFramework.inject;
}, function (_aureliaBinding) {
ObserverLocator = _aureliaBinding.ObserverLocator;
}, function (_aureliaI18n) {
I18N = _aureliaI18n.I18N;
}, function (_jquery) {
$ = _jquery.default;
}, function (_aureliaEventAggregator) {
EventAggregator = _aureliaEventAggregator.EventAggregator;
}],
execute: function () {
_createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}

return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();

_export('AureliaFroala', AureliaFroala = (_dec = customElement('aurelia-froala'), _dec2 = inject(Element, ObserverLocator, I18N, EventAggregator), _dec(_class = _dec2(_class = (_class2 = function () {
function AureliaFroala(element, observerLocator, i18n, eventAggregator) {
var _this = this;

_classCallCheck(this, AureliaFroala);

_initDefineProp(this, 'value', _descriptor, this);

_initDefineProp(this, 'config', _descriptor2, this);

_initDefineProp(this, 'eventHandlers', _descriptor3, this);

this.i18nInitialized = false;

this.element = element;
this.subscriptions = [observerLocator.getObserver(this, 'value').subscribe(function (newValue, oldValue) {
if (_this.instance && _this.instance.froalaEditor('html.get') != newValue) {
_this.instance.froalaEditor('html.set', newValue);
_this.updateEmptyStatus();
}
})];
this.i18n = i18n;
eventAggregator.subscribe('i18n:locale:changed', function (payload) {
_this.processLanguageChanged();
});
}

_createClass(AureliaFroala, [{
key: 'processLanguageChanged',
value: function processLanguageChanged() {
this.tearDownFroala();
this.setupFroala();
}
}, {
key: 'setupFroala',
value: function setupFroala() {
var _this2 = this;

this.instance = $(this.element.getElementsByTagName("div")[0]);

if (this.instance.data('froala.editor')) {
return;
}
var c = {};
c.language = this.i18n.getLocale();
Object.assign(c, this.config);
this.instance.froalaEditor(c);
this.instance.froalaEditor('html.set', this.value);
if (this.eventHandlers && this.eventHandlers.length != 0) {
var _loop = function _loop(eventHandlerName) {
var handler = _this2.eventHandlers[eventHandlerName];
_this2.instance.on('froalaEditor.' + eventHandlerName, function () {
var p = arguments;
return handler.apply(this, p);
});
};

for (var eventHandlerName in this.eventHandlers) {
_loop(eventHandlerName);
}
}
}
}, {
key: 'updateEmptyStatus',
value: function updateEmptyStatus() {}
}, {
key: 'tearDownFroala',
value: function tearDownFroala() {
if (this.instance && this.instance.data('froala.editor')) {
this.instance.froalaEditor('destroy');
}
this.instance = null;
}
}, {
key: 'attached',
value: function attached() {
this.setupFroala();
}
}, {
key: 'detached',
value: function detached() {
this.tearDownFroala();
}
}]);

return AureliaFroala;
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'value', [bindable], {
enumerable: true,
initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'config', [bindable], {
enumerable: true,
initializer: function initializer() {
return {};
}
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'eventHandlers', [bindable], {
enumerable: true,
initializer: function initializer() {
return {};
}
})), _class2)) || _class) || _class));

_export('AureliaFroala', AureliaFroala);
}
};
});
41 changes: 41 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";

System.register(["font-awesome/./css/font-awesome.min.css!", "jquery", "froala-editor/./js/froala_editor.min", "froala-editor/css/froala_editor.min.css!", "froala-editor/css/froala_style.min.css!"], function (_export, _context) {
"use strict";

var $, froala;
return {
setters: [function (_fontAwesomeCssFontAwesomeMinCss) {}, function (_jquery) {
$ = _jquery.default;
}, function (_froalaEditorJsFroala_editorMin) {
froala = _froalaEditorJsFroala_editorMin;
}, function (_froalaEditorCssFroala_editorMinCss) {}, function (_froalaEditorCssFroala_styleMinCss) {}],
execute: function () {
function configure(aurelia, config) {
aurelia.globalResources('./aurelia-froala');
var c = {
addPlugin: function addPlugin(name) {
return Promise.all([System.import("froala-editor/js/plugins/" + name + ".min", _context.id).then(function (m) {
return m();
}), System.import("froala-editor/css/plugins/" + name + ".css!", _context.id).catch(function (e) {})]);
},
global: function global(callback) {
callback($.FroalaEditor);
},
addDefaltOptions: function addDefaltOptions(options) {
$.FroalaEditor.DEFAULTS = $.extend($.FroalaEditor.DEFAULTS, options);
},
addLanguage: function addLanguage(language, additionalTranslations) {
return System.import("froala-editor/js/languages/" + language, _context.id).then(function () {
return additionalTranslations && Object.assign($.FE.LANGUAGE[language].translation, additionalTranslations);
});
}
};
froala.default();
config(c);
}

_export("configure", configure);
}
};
});
6 changes: 6 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <binding AfterBuild='build' />
// all gulp tasks are located in the ./build/tasks directory
// gulp configuration is in files in ./build directory
//require('require-dir')('build/tasks');

require('require-dir')('build/tasks');
47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "aurelia-froala",
"version": "1.0.3",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"directories": {
"lib": "dist",
"src": "src"
},
"author": "Net at Work GmbH",
"license": "MIT",
"devDependencies": {
"babel": "^6.3.26",
"babel-plugin-transform-decorators": "^6.8.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-systemjs": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.3.13",
"babel-runtime": "^6.9.0",
"core-js": "^2.4.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.1",
"gulp-bump": "^2.1.0",
"gulp-changed": "^1.3.0",
"gulp-sourcemaps": "^1.6.0",
"require-dir": "^0.3.0",
"run-sequence": "^1.2.1"
},
"dependencies": {
"aurelia-binding": "^1.0.0-beta.1.0.1",
"aurelia-framework": "^1.0.0-beta.1.1.1",
"font-awesome": "^4.6.3",
"froala-editor": "^2.3.0",
"jquery": "^2.2.4"
},
"jspm": {
"dependencies": {
"css": "jspm:css",
"froala-editor": "npm:froala-editor",
"jquery": "npm:jquery",
"font-awesome": "npm:font-awesome"
}
}
}
Loading

0 comments on commit 376b4f8

Please sign in to comment.