Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
[ci skip] Changes necessary to work standalone similar to ipywidgets …
Browse files Browse the repository at this point in the history
…examples

(c) Copyright IBM Corp. 2015
  • Loading branch information
Gino Bustelo committed Dec 16, 2015
1 parent f7b6b78 commit d227b4a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 5 deletions.
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

// This is the main file that will be loaded when urth-widgets is required in an
// npm environment.
//
//module.exports = function createDefine(targetModule) {
// var amdefine = require('amdefine')(targetModule, require);
//
// return function define() {
// var args = Array.prototype.slice.call(arguments);
// //if (args.length > 1) {
// // args[0] = args[0].map(function(arg) {
// // if (arg === 'jqueryui') arg = 'jquery';
// // arg = arg.replace('nbextensions/widgets/widgets/css/', '../css/');
// // arg = arg.replace('nbextensions/widgets/components/require-css/css!', '');
// // return arg;
// // });
// //}
// amdefine.apply(this, args);
// };
//};

var init = require('./dist/urth_widgets/js/init/init');

exports.init = init;
8 changes: 8 additions & 0 deletions nb-extension/js/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
* Loads the web component polyfill and all web components specified in
* elements.html.
*/
// npm compatibility
function requireLocalFiles() {
require('jquery');
require('../widgets/DeclWidgetModel');
}

if (typeof define !== 'function') { var define = require('amdefine')(module, require); }

define([
'require',
'jquery',
Expand Down
32 changes: 28 additions & 4 deletions nb-extension/js/widgets/DeclWidgetModel.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

// npm compatibility
function requireLocalFiles() {
require('../../../../node_modules/jupyter-js-widgets/static/widgets/js/manager-base');
require('../../../../node_modules/jupyter-js-widgets/static/widgets/js/widget');
}

if (typeof define !== 'function') {
var amdefine = require('amdefine')(module, require);

var mapping = {}
mapping['nbextensions/widgets/widgets/js/manager'] = '../../../../node_modules/jupyter-js-widgets/static/widgets/js/manager-base'
mapping['nbextensions/widgets/widgets/js/widget'] = '../../../../node_modules/jupyter-js-widgets/static/widgets/js/widget'

var define = function(){
var args = Array.prototype.slice.call(arguments);
if (args.length > 1) {
args[0] = args[0].map(function(arg) {
arg = mapping[arg] || arg;
return arg;
});
}
amdefine.apply(this, args);
}
}

define(["nbextensions/widgets/widgets/js/manager",
"nbextensions/widgets/widgets/js/widget",
"base/js/namespace"
], function(widgetmanager, ipywidget, IPython) {
"nbextensions/widgets/widgets/js/widget"
], function(widgetmanager, ipywidget) {
"use strict";

/**
Expand Down Expand Up @@ -33,7 +57,7 @@ define(["nbextensions/widgets/widgets/js/manager",
this.comm.send(data, callbacks);
};

widgetmanager.WidgetManager.register_widget_model('DeclWidgetModel', DeclWidgetModel);
widgetmanager.ManagerBase.register_widget_model('DeclWidgetModel', DeclWidgetModel);

return DeclWidgetModel;

Expand Down
2 changes: 1 addition & 1 deletion notebooks/examples/urth-scala-widgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"outputs": [],
"source": [
"// modify to IP and Port of this notebook server\n",
"%addjar http://192.168.99.100:8888/nbextensions/urth_widgets/urth-widgets.jar"
"%addjar http://192.168.99.100:8888/nbexten tsions/urth_widgets/urth-widgets.jar"
]
},
{
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"selenium-standalone": "latest",
"web-component-tester": "~3.4"
},
"dependencies": {
"amdefine": "^1.0.0",
"jquery": "^2.1.4"
},
"config": {},
"scripts": {
"bower": "bower",
Expand Down

0 comments on commit d227b4a

Please sign in to comment.