@converse/skeletor 0.0.4 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -7
- package/dist/skeletor.js +163 -161
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +2 -2
- package/dist/skeletor.min.js.map +1 -1
- package/package.json +7 -6
- package/src/collection.js +1 -1
- package/src/drivers/indexeddb-getitems.js~ +1116 -0
- package/src/drivers/indexeddb.js~ +1115 -0
- package/src/storage.js +11 -8
- package/src/storage.js~ +13 -9
- package/CHANGES.md +0 -31
- package/src/.events.js.swp +0 -0
- package/src/.helpers.js.swp +0 -0
- package/src/.history.js.swp +0 -0
- package/src/.model.js.swp +0 -0
- package/src/.overview.js.swp +0 -0
- package/src/.router.js.swp +0 -0
- package/src/.view.js.swp +0 -0
- package/src/collection.js~ +0 -737
- package/src/drivers/.sessionStorage.js.swp +0 -0
- package/src/drivers/sessionStorage.js~ +0 -316
- package/src/element-overview.js~ +0 -4
- package/src/element.js~ +0 -188
- package/src/events.js~ +0 -334
- package/src/helpers.js~ +0 -151
- package/src/history.js~ +0 -301
- package/src/htmlview.js~ +0 -14
- package/src/model.js~ +0 -439
- package/src/orderedlist.js~ +0 -88
- package/src/overview.js~ +0 -111
- package/src/router.js~ +0 -119
- package/src/vdomview.js~ +0 -15
- package/src/view.js~ +0 -267
package/src/router.js~
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// Backbone.js 1.4.0
|
|
2
|
-
// (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
|
|
3
|
-
// Backbone may be freely distributed under the MIT license.
|
|
4
|
-
|
|
5
|
-
// Router
|
|
6
|
-
// ------
|
|
7
|
-
|
|
8
|
-
import History from './history.js';
|
|
9
|
-
import extend from 'lodash-es/extend.js';
|
|
10
|
-
import isFunction from 'lodash-es/isFunction.js';
|
|
11
|
-
import isRegExp from 'lodash-es/isRegExp.js';
|
|
12
|
-
import result from 'lodash-es/result.js';
|
|
13
|
-
import keys from 'lodash-es/keys.js';
|
|
14
|
-
import { Events } from './events.js';
|
|
15
|
-
import { inherits } from './helpers.js';
|
|
16
|
-
|
|
17
|
-
// Routers map faux-URLs to actions, and fire events when routes are
|
|
18
|
-
// matched. Creating a new one sets its `routes` hash, if not set statically.
|
|
19
|
-
export const Router = function(options={}) {
|
|
20
|
-
this.history = options.history || new History();
|
|
21
|
-
this.preinitialize.apply(this, arguments);
|
|
22
|
-
if (options.routes) this.routes = options.routes;
|
|
23
|
-
this._bindRoutes();
|
|
24
|
-
this.initialize.apply(this, arguments);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
Router.extend = inherits;
|
|
28
|
-
|
|
29
|
-
// Cached regular expressions for matching named param parts and splatted
|
|
30
|
-
// parts of route strings.
|
|
31
|
-
const optionalParam = /\((.*?)\)/g;
|
|
32
|
-
const namedParam = /(\(\?)?:\w+/g;
|
|
33
|
-
const splatParam = /\*\w+/g;
|
|
34
|
-
const escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
|
|
35
|
-
|
|
36
|
-
// Set up all inheritable **Router** properties and methods.
|
|
37
|
-
Object.assign(Router.prototype, Events, {
|
|
38
|
-
|
|
39
|
-
// preinitialize is an empty function by default. You can override it with a function
|
|
40
|
-
// or object. preinitialize will run before any instantiation logic is run in the Router.
|
|
41
|
-
preinitialize: function(){},
|
|
42
|
-
|
|
43
|
-
// Initialize is an empty function by default. Override it with your own
|
|
44
|
-
// initialization logic.
|
|
45
|
-
initialize: function(){},
|
|
46
|
-
|
|
47
|
-
// Manually bind a single named route to a callback. For example:
|
|
48
|
-
//
|
|
49
|
-
// this.route('search/:query/p:num', 'search', function(query, num) {
|
|
50
|
-
// ...
|
|
51
|
-
// });
|
|
52
|
-
//
|
|
53
|
-
route: function(route, name, callback) {
|
|
54
|
-
if (!isRegExp(route)) route = this._routeToRegExp(route);
|
|
55
|
-
if (isFunction(name)) {
|
|
56
|
-
callback = name;
|
|
57
|
-
name = '';
|
|
58
|
-
}
|
|
59
|
-
if (!callback) callback = this[name];
|
|
60
|
-
this.history.route(route, (fragment) => {
|
|
61
|
-
const args = this._extractParameters(route, fragment);
|
|
62
|
-
if (this.execute(callback, args, name) !== false) {
|
|
63
|
-
this.trigger.apply(this, ['route:' + name].concat(args));
|
|
64
|
-
this.trigger('route', name, args);
|
|
65
|
-
this.history.trigger('route', this, name, args);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return this;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
// Execute a route handler with the provided parameters. This is an
|
|
72
|
-
// excellent place to do pre-route setup or post-route cleanup.
|
|
73
|
-
execute: function(callback, args, name) {
|
|
74
|
-
if (callback) callback.apply(this, args);
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
// Simple proxy to `history` to save a fragment into the history.
|
|
78
|
-
navigate: function(fragment, options) {
|
|
79
|
-
this.history.navigate(fragment, options);
|
|
80
|
-
return this;
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
// Bind all defined routes to `history`. We have to reverse the
|
|
84
|
-
// order of the routes here to support behavior where the most general
|
|
85
|
-
// routes can be defined at the bottom of the route map.
|
|
86
|
-
_bindRoutes: function() {
|
|
87
|
-
if (!this.routes) return;
|
|
88
|
-
this.routes = result(this, 'routes');
|
|
89
|
-
let route;
|
|
90
|
-
const routes = keys(this.routes);
|
|
91
|
-
while ((route = routes.pop()) != null) {
|
|
92
|
-
this.route(route, this.routes[route]);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
// Convert a route string into a regular expression, suitable for matching
|
|
97
|
-
// against the current location hash.
|
|
98
|
-
_routeToRegExp: function(route) {
|
|
99
|
-
route = route.replace(escapeRegExp, '\\$&')
|
|
100
|
-
.replace(optionalParam, '(?:$1)?')
|
|
101
|
-
.replace(namedParam, function(match, optional) {
|
|
102
|
-
return optional ? match : '([^/?]+)';
|
|
103
|
-
})
|
|
104
|
-
.replace(splatParam, '([^?]*?)');
|
|
105
|
-
return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
// Given a route, and a URL fragment that it matches, return the array of
|
|
109
|
-
// extracted decoded parameters. Empty or unmatched parameters will be
|
|
110
|
-
// treated as `null` to normalize cross-browser behavior.
|
|
111
|
-
_extractParameters: function(route, fragment) {
|
|
112
|
-
const params = route.exec(fragment).slice(1);
|
|
113
|
-
return params.map(function(param, i) {
|
|
114
|
-
// Don't decode the search params.
|
|
115
|
-
if (i === params.length - 1) return param || null;
|
|
116
|
-
return param ? decodeURIComponent(param) : null;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
});
|
package/src/vdomview.js~
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { isFunction, isNil } from "lodash";
|
|
2
|
-
import { View } from "./view";
|
|
3
|
-
import { render } from 'lit-html';
|
|
4
|
-
import tovnode from "tovnode";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const HTMLView = View.extend({
|
|
8
|
-
|
|
9
|
-
render () {
|
|
10
|
-
isFunction(this.beforeRender) && this.beforeRender();
|
|
11
|
-
render(this.toHTML, this.el);
|
|
12
|
-
isFunction(this.afterRender) && this.afterRender();
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
});
|
package/src/view.js~
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
// Backbone.js 1.4.0
|
|
2
|
-
// (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
|
|
3
|
-
// Backbone may be freely distributed under the MIT license.
|
|
4
|
-
|
|
5
|
-
// View
|
|
6
|
-
// ----
|
|
7
|
-
|
|
8
|
-
// Views are almost more convention than they are actual code. A View
|
|
9
|
-
// is simply a JavaScript object that represents a logical chunk of UI in the
|
|
10
|
-
// DOM. This might be a single item, an entire list, a sidebar or panel, or
|
|
11
|
-
// even the surrounding frame which wraps your whole app. Defining a chunk of
|
|
12
|
-
// UI as a **View** allows you to define your DOM events declaratively, without
|
|
13
|
-
// having to worry about render order ... and makes it easy for the view to
|
|
14
|
-
// react to specific changes in the state of your models.
|
|
15
|
-
|
|
16
|
-
import extend from "lodash-es/extend.js";
|
|
17
|
-
import isElement from "lodash-es/isElement.js";
|
|
18
|
-
import isFunction from "lodash-es/isFunction.js";
|
|
19
|
-
import pick from "lodash-es/pick.js";
|
|
20
|
-
import result from "lodash-es/result.js";
|
|
21
|
-
import uniqueId from "lodash-es/uniqueId.js";
|
|
22
|
-
import { Events } from './events.js';
|
|
23
|
-
import { inherits, sync, urlError, wrapError } from './helpers.js';
|
|
24
|
-
import { render } from 'lit-html';
|
|
25
|
-
|
|
26
|
-
const paddedLt = /^\s*</;
|
|
27
|
-
|
|
28
|
-
// Caches a local reference to `Element.prototype` for faster access.
|
|
29
|
-
const ElementProto = (typeof Element !== 'undefined' && Element.prototype) || {};
|
|
30
|
-
|
|
31
|
-
const indexOf = function(array, item) {
|
|
32
|
-
for (let i = 0, len = array.length; i < len; i++) if (array[i] === item) return i;
|
|
33
|
-
return -1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Creating a View creates its initial element outside of the DOM,
|
|
38
|
-
// if an existing element is not provided...
|
|
39
|
-
export const View = function(options) {
|
|
40
|
-
this.cid = uniqueId('view');
|
|
41
|
-
this._domEvents = [];
|
|
42
|
-
this.preinitialize.apply(this, arguments);
|
|
43
|
-
extend(this, pick(options, viewOptions));
|
|
44
|
-
this._ensureElement();
|
|
45
|
-
this.initialize.apply(this, arguments);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
View.extend = inherits;
|
|
49
|
-
|
|
50
|
-
// Cached regex to split keys for `delegate`.
|
|
51
|
-
const delegateEventSplitter = /^(\S+)\s*(.*)$/;
|
|
52
|
-
|
|
53
|
-
// List of view options to be set as properties.
|
|
54
|
-
const viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
|
|
55
|
-
|
|
56
|
-
// Set up all inheritable **View** properties and methods.
|
|
57
|
-
Object.assign(View.prototype, Events, {
|
|
58
|
-
|
|
59
|
-
// The default `tagName` of a View's element is `"div"`.
|
|
60
|
-
tagName: 'div',
|
|
61
|
-
|
|
62
|
-
$: function(selector) {
|
|
63
|
-
return this.el.querySelectorAll(selector);
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
// preinitialize is an empty function by default. You can override it with a function
|
|
67
|
-
// or object. preinitialize will run before any instantiation logic is run in the View
|
|
68
|
-
preinitialize: function(){},
|
|
69
|
-
|
|
70
|
-
// Initialize is an empty function by default. Override it with your own
|
|
71
|
-
// initialization logic.
|
|
72
|
-
initialize: function(){},
|
|
73
|
-
|
|
74
|
-
// **render** is the core function that your view should override, in order
|
|
75
|
-
// to populate its element (`this.el`), with the appropriate HTML. The
|
|
76
|
-
// convention is for **render** to always return `this`.
|
|
77
|
-
render: function() {
|
|
78
|
-
isFunction(this.beforeRender) && this.beforeRender();
|
|
79
|
-
isFunction(this.toHTML) && render(this.toHTML(), this.el);
|
|
80
|
-
isFunction(this.afterRender) && this.afterRender();
|
|
81
|
-
return this;
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
// Remove this view by taking the element out of the DOM, and removing any
|
|
85
|
-
// applicable Backbone.Events listeners.
|
|
86
|
-
remove: function() {
|
|
87
|
-
this._removeElement();
|
|
88
|
-
this.stopListening();
|
|
89
|
-
return this;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
// Remove this view's element from the document and all event listeners
|
|
93
|
-
// attached to it. Exposed for subclasses using an alternative DOM
|
|
94
|
-
// manipulation API.
|
|
95
|
-
_removeElement: function() {
|
|
96
|
-
this.undelegateEvents();
|
|
97
|
-
if (this.el.parentNode) this.el.parentNode.removeChild(this.el);
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
// Change the view's element (`this.el` property) and re-delegate the
|
|
101
|
-
// view's events on the new element.
|
|
102
|
-
setElement: function(element) {
|
|
103
|
-
this.undelegateEvents();
|
|
104
|
-
this._setElement(element);
|
|
105
|
-
this.delegateEvents();
|
|
106
|
-
return this;
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
// Apply the `element` to the view. `element` can be a CSS selector,
|
|
110
|
-
// a string of HTML, or an Element node. If passed a NodeList or CSS
|
|
111
|
-
// selector, uses just the first match.
|
|
112
|
-
_setElement: function(element) {
|
|
113
|
-
if (typeof element == 'string') {
|
|
114
|
-
if (paddedLt.test(element)) {
|
|
115
|
-
const el = document.createElement('div');
|
|
116
|
-
el.innerHTML = element;
|
|
117
|
-
this.el = el.firstChild;
|
|
118
|
-
} else {
|
|
119
|
-
this.el = document.querySelector(element);
|
|
120
|
-
}
|
|
121
|
-
} else if (element && !isElement(element) && element.length) {
|
|
122
|
-
this.el = element[0];
|
|
123
|
-
} else {
|
|
124
|
-
this.el = element;
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
// Set callbacks, where `this.events` is a hash of
|
|
129
|
-
//
|
|
130
|
-
// *{"event selector": "callback"}*
|
|
131
|
-
//
|
|
132
|
-
// {
|
|
133
|
-
// 'mousedown .title': 'edit',
|
|
134
|
-
// 'click .button': 'save',
|
|
135
|
-
// 'click .open': function(e) { ... }
|
|
136
|
-
// }
|
|
137
|
-
//
|
|
138
|
-
// pairs. Callbacks will be bound to the view, with `this` set properly.
|
|
139
|
-
// Uses event delegation for efficiency.
|
|
140
|
-
// Omitting the selector binds the event to `this.el`.
|
|
141
|
-
delegateEvents: function(events) {
|
|
142
|
-
events || (events = result(this, 'events'));
|
|
143
|
-
if (!events) return this;
|
|
144
|
-
this.undelegateEvents();
|
|
145
|
-
for (const key in events) {
|
|
146
|
-
let method = events[key];
|
|
147
|
-
if (!isFunction(method)) method = this[method];
|
|
148
|
-
if (!method) continue;
|
|
149
|
-
const match = key.match(delegateEventSplitter);
|
|
150
|
-
this.delegate(match[1], match[2], method.bind(this));
|
|
151
|
-
}
|
|
152
|
-
return this;
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
// Make a event delegation handler for the given `eventName` and `selector`
|
|
156
|
-
// and attach it to `this.el`.
|
|
157
|
-
// If selector is empty, the listener will be bound to `this.el`. If not, a
|
|
158
|
-
// new handler that will recursively traverse up the event target's DOM
|
|
159
|
-
// hierarchy looking for a node that matches the selector. If one is found,
|
|
160
|
-
// the event's `delegateTarget` property is set to it and the return the
|
|
161
|
-
// result of calling bound `listener` with the parameters given to the
|
|
162
|
-
// handler.
|
|
163
|
-
delegate: function(eventName, selector, listener) {
|
|
164
|
-
const root = this.el;
|
|
165
|
-
if (!root) {
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
if (typeof selector === 'function') {
|
|
169
|
-
listener = selector;
|
|
170
|
-
selector = null;
|
|
171
|
-
}
|
|
172
|
-
// Given that `focus` and `blur` events do not bubble, do not delegate these events
|
|
173
|
-
if (['focus', 'blur'].indexOf(eventName) !== -1) {
|
|
174
|
-
const els = this.el.querySelectorAll(selector);
|
|
175
|
-
for (let i = 0, len = els.length; i < len; i++) {
|
|
176
|
-
const item = els[i];
|
|
177
|
-
item.addEventListener(eventName, listener, false);
|
|
178
|
-
this._domEvents.push({el: item, eventName: eventName, handler: listener});
|
|
179
|
-
}
|
|
180
|
-
return listener;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const handler = selector ? function (e) {
|
|
184
|
-
let node = e.target || e.srcElement;
|
|
185
|
-
for (; node && node != root; node = node.parentNode) {
|
|
186
|
-
if (node.matches(selector)) {
|
|
187
|
-
e.delegateTarget = node;
|
|
188
|
-
listener(e);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
} : listener;
|
|
192
|
-
|
|
193
|
-
this.el.addEventListener(eventName, handler, false);
|
|
194
|
-
this._domEvents.push({el: this.el, eventName: eventName, handler: handler, listener: listener, selector: selector});
|
|
195
|
-
return this;
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
// Clears all callbacks previously bound to the view by `delegateEvents`.
|
|
199
|
-
// You usually don't need to use this, but may wish to if you have multiple
|
|
200
|
-
// Backbone views attached to the same DOM element.
|
|
201
|
-
undelegateEvents: function() {
|
|
202
|
-
if (this.el) {
|
|
203
|
-
for (let i = 0, len = this._domEvents.length; i < len; i++) {
|
|
204
|
-
const item = this._domEvents[i];
|
|
205
|
-
item.el.removeEventListener(item.eventName, item.handler, false);
|
|
206
|
-
}
|
|
207
|
-
this._domEvents.length = 0;
|
|
208
|
-
}
|
|
209
|
-
return this;
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
// A finer-grained `undelegateEvents` for removing a single delegated event.
|
|
213
|
-
// `selector` and `listener` are both optional.
|
|
214
|
-
undelegate: function(eventName, selector, listener) {
|
|
215
|
-
if (typeof selector === 'function') {
|
|
216
|
-
listener = selector;
|
|
217
|
-
selector = null;
|
|
218
|
-
}
|
|
219
|
-
if (this.el) {
|
|
220
|
-
const handlers = this._domEvents.slice();
|
|
221
|
-
let i = handlers.length;
|
|
222
|
-
while (i--) {
|
|
223
|
-
const item = handlers[i];
|
|
224
|
-
const match = item.eventName === eventName &&
|
|
225
|
-
(listener ? item.listener === listener : true) &&
|
|
226
|
-
(selector ? item.selector === selector : true);
|
|
227
|
-
|
|
228
|
-
if (!match) {
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
item.el.removeEventListener(item.eventName, item.handler, false);
|
|
232
|
-
this._domEvents.splice(i, 1);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return this;
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
// Produces a DOM element to be assigned to your view. Exposed for
|
|
239
|
-
// subclasses using an alternative DOM manipulation API.
|
|
240
|
-
_createElement: function(tagName) {
|
|
241
|
-
return document.createElement(tagName);
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
// Ensure that the View has a DOM element to render into.
|
|
245
|
-
// If `this.el` is a string, pass it through `$()`, take the first
|
|
246
|
-
// matching element, and re-assign it to `el`. Otherwise, create
|
|
247
|
-
// an element from the `id`, `className` and `tagName` properties.
|
|
248
|
-
_ensureElement: function() {
|
|
249
|
-
if (!this.el) {
|
|
250
|
-
const attrs = extend({}, result(this, 'attributes'));
|
|
251
|
-
if (this.id) attrs.id = result(this, 'id');
|
|
252
|
-
if (this.className) attrs['class'] = result(this, 'className');
|
|
253
|
-
this.setElement(this._createElement(result(this, 'tagName')));
|
|
254
|
-
this._setAttributes(attrs);
|
|
255
|
-
} else {
|
|
256
|
-
this.setElement(result(this, 'el'));
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
// Set attributes from a hash on this view's element. Exposed for
|
|
261
|
-
// subclasses using an alternative DOM manipulation API.
|
|
262
|
-
_setAttributes: function(attrs) {
|
|
263
|
-
for (const attr in attrs) {
|
|
264
|
-
attr in this.el ? this.el[attr] = attrs[attr] : this.el.setAttribute(attr, attrs[attr]);
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
});
|