written 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/written/app/assets/javascripts/written/core/content.coffee +10 -10
  3. data/lib/written/app/assets/javascripts/written/core/cursor.coffee +6 -6
  4. data/lib/written/app/assets/javascripts/written/core/document.coffee +39 -6
  5. data/lib/written/app/assets/javascripts/written/parsers/block/code.coffee +34 -30
  6. data/lib/written/app/assets/javascripts/written/parsers/block/heading.coffee +28 -30
  7. data/lib/written/app/assets/javascripts/written/parsers/block/image.coffee +30 -49
  8. data/lib/written/app/assets/javascripts/written/parsers/block/olist.coffee +46 -49
  9. data/lib/written/app/assets/javascripts/written/parsers/block/paragraph.coffee +28 -32
  10. data/lib/written/app/assets/javascripts/written/parsers/block/quote.coffee +30 -32
  11. data/lib/written/app/assets/javascripts/written/parsers/block/ulist.coffee +43 -45
  12. data/lib/written/app/assets/javascripts/written/parsers/inline/code.coffee +28 -30
  13. data/lib/written/app/assets/javascripts/written/parsers/inline/italic.coffee +21 -25
  14. data/lib/written/app/assets/javascripts/written/parsers/inline/link.coffee +21 -25
  15. data/lib/written/app/assets/javascripts/written/parsers/inline/strong.coffee +21 -25
  16. data/lib/written/app/assets/javascripts/written/parsers/parsers.coffee +87 -19
  17. data/lib/written/app/assets/javascripts/written.coffee +0 -1
  18. data/lib/written/version.rb +1 -1
  19. data/test/server/app/assets/javascripts/application.coffee +5 -15
  20. metadata +2 -18
  21. data/lib/written/app/assets/javascripts/written/core/extensions/text.coffee +0 -2
  22. data/lib/written/app/assets/javascripts/written/core/stringify.coffee +0 -15
  23. data/lib/written/app/assets/javascripts/written/parsers/block.coffee +0 -69
  24. data/lib/written/app/assets/javascripts/written/parsers/inline/list.coffee +0 -27
  25. data/lib/written/app/assets/javascripts/written/parsers/inline.coffee +0 -81
  26. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/CustomElements.js +0 -32
  27. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/base.js +0 -40
  28. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/boot.js +0 -124
  29. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/observe.js +0 -318
  30. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/register.js +0 -369
  31. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/traverse.js +0 -86
  32. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/upgrade.js +0 -130
  33. data/lib/written/app/assets/javascripts/written/polyfills/MutationObserver/MutationObserver.js +0 -575
  34. data/lib/written/app/assets/javascripts/written/polyfills/WeakMap/WeakMap.js +0 -49
  35. data/lib/written/app/assets/javascripts/written/polyfills/base.coffee +0 -10
  36. data/lib/written/app/assets/javascripts/written/polyfills/dom.js +0 -104
@@ -1,86 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- * Code distributed by Google as part of the polymer project is also
8
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
-
11
- // helper methods for traversing through element trees
12
- window.CustomElements.addModule(function(scope){
13
-
14
- // imports
15
- var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : 'none';
16
-
17
- // walk the subtree rooted at node, including descent into shadow-roots,
18
- // applying 'cb' to each element
19
- function forSubtree(node, cb) {
20
- //flags.dom && node.childNodes && node.childNodes.length && console.group('subTree: ', node);
21
- findAllElements(node, function(e) {
22
- if (cb(e)) {
23
- return true;
24
- }
25
- forRoots(e, cb);
26
- });
27
- forRoots(node, cb);
28
- //flags.dom && node.childNodes && node.childNodes.length && console.groupEnd();
29
- }
30
-
31
-
32
- // walk the subtree rooted at node, applying 'find(element, data)' function
33
- // to each element
34
- // if 'find' returns true for 'element', do not search element's subtree
35
- function findAllElements(node, find, data) {
36
- var e = node.firstElementChild;
37
- if (!e) {
38
- e = node.firstChild;
39
- while (e && e.nodeType !== Node.ELEMENT_NODE) {
40
- e = e.nextSibling;
41
- }
42
- }
43
- while (e) {
44
- if (find(e, data) !== true) {
45
- findAllElements(e, find, data);
46
- }
47
- e = e.nextElementSibling;
48
- }
49
- return null;
50
- }
51
-
52
- // walk all shadowRoots on a given node.
53
- function forRoots(node, cb) {
54
- var root = node.shadowRoot;
55
- while(root) {
56
- forSubtree(root, cb);
57
- root = root.olderShadowRoot;
58
- }
59
- }
60
-
61
- function forDocumentTree(doc, cb) {
62
- _forDocumentTree(doc, cb, []);
63
- }
64
-
65
-
66
- function _forDocumentTree(doc, cb, processingDocuments) {
67
- doc = window.wrap(doc);
68
- if (processingDocuments.indexOf(doc) >= 0) {
69
- return;
70
- }
71
- processingDocuments.push(doc);
72
- var imports = doc.querySelectorAll('link[rel=' + IMPORT_LINK_TYPE + ']');
73
- for (var i=0, l=imports.length, n; (i<l) && (n=imports[i]); i++) {
74
- if (n.import) {
75
- _forDocumentTree(n.import, cb, processingDocuments);
76
- }
77
- }
78
- cb(doc);
79
- }
80
-
81
- // exports
82
- scope.forDocumentTree = forDocumentTree;
83
- scope.forSubtree = forSubtree;
84
-
85
-
86
- });
@@ -1,130 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- * Code distributed by Google as part of the polymer project is also
8
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
-
11
- /**
12
- * Implements custom element upgrading
13
- * @module upgrade
14
- */
15
-
16
- window.CustomElements.addModule(function(scope) {
17
-
18
- // imports
19
- var flags = scope.flags;
20
-
21
- /**
22
- * Upgrade an element to a custom element. Upgrading an element
23
- * causes the custom prototype to be applied, an `is` attribute
24
- * to be attached (as needed), and invocation of the `readyCallback`.
25
- * If the element is in the main document, the `attachedkCallback` method
26
- * will be invoked.
27
- * `upgrade` does nothing if the element is already upgraded, or
28
- * if it matches no registered custom tag name.
29
- *
30
- * @method ugprade
31
- * @param {Element} element The element to upgrade.
32
- * @return {Element} The upgraded element.
33
- */
34
- // Upgrade a node if it can be upgraded and is not already.
35
- function upgrade(node, isAttached) {
36
- // upgrade template elements before custom elements
37
- if (node.localName === 'template') {
38
- if (window.HTMLTemplateElement && HTMLTemplateElement.decorate) {
39
- HTMLTemplateElement.decorate(node);
40
- }
41
- }
42
- if (!node.__upgraded__ && (node.nodeType === Node.ELEMENT_NODE)) {
43
- var is = node.getAttribute('is');
44
- // find definition first by localName and secondarily by is attribute
45
- var definition = scope.getRegisteredDefinition(node.localName) ||
46
- scope.getRegisteredDefinition(is);
47
- if (definition) {
48
- // upgrade with is iff the definition tag matches the element tag
49
- // and don't upgrade if there's an is and the definition does not extend
50
- // a native element
51
- if ((is && definition.tag == node.localName) ||
52
- (!is && !definition.extends)) {
53
- return upgradeWithDefinition(node, definition, isAttached);
54
- }
55
- }
56
- }
57
- }
58
-
59
- function upgradeWithDefinition(element, definition, isAttached) {
60
- flags.upgrade && console.group('upgrade:', element.localName);
61
- // some definitions specify an 'is' attribute
62
- if (definition.is) {
63
- element.setAttribute('is', definition.is);
64
- }
65
- // make 'element' implement definition.prototype
66
- implementPrototype(element, definition);
67
- // flag as upgraded
68
- element.__upgraded__ = true;
69
- // lifecycle management
70
- created(element);
71
- // attachedCallback fires in tree order, call before recursing
72
- if (isAttached) {
73
- scope.attached(element);
74
- }
75
- // there should never be a shadow root on element at this point
76
- scope.upgradeSubtree(element, isAttached);
77
- flags.upgrade && console.groupEnd();
78
- // OUTPUT
79
- return element;
80
- }
81
-
82
- // Set __proto__ on supported platforms and use a mixin strategy when
83
- // this is not supported; e.g. on IE10.
84
- function implementPrototype(element, definition) {
85
- // prototype swizzling is best
86
- if (Object.__proto__) {
87
- element.__proto__ = definition.prototype;
88
- } else {
89
- // where above we can re-acquire inPrototype via
90
- // getPrototypeOf(Element), we cannot do so when
91
- // we use mixin, so we install a magic reference
92
- customMixin(element, definition.prototype, definition.native);
93
- element.__proto__ = definition.prototype;
94
- }
95
- }
96
-
97
- function customMixin(inTarget, inSrc, inNative) {
98
- // TODO(sjmiles): 'used' allows us to only copy the 'youngest' version of
99
- // any property. This set should be precalculated. We also need to
100
- // consider this for supporting 'super'.
101
- var used = {};
102
- // start with inSrc
103
- var p = inSrc;
104
- // The default is HTMLElement.prototype, so we add a test to avoid mixing in
105
- // native prototypes
106
- while (p !== inNative && p !== HTMLElement.prototype) {
107
- var keys = Object.getOwnPropertyNames(p);
108
- for (var i=0, k; k=keys[i]; i++) {
109
- if (!used[k]) {
110
- Object.defineProperty(inTarget, k,
111
- Object.getOwnPropertyDescriptor(p, k));
112
- used[k] = 1;
113
- }
114
- }
115
- p = Object.getPrototypeOf(p);
116
- }
117
- }
118
-
119
- function created(element) {
120
- // invoke createdCallback
121
- if (element.createdCallback) {
122
- element.createdCallback();
123
- }
124
- }
125
-
126
- scope.upgrade = upgrade;
127
- scope.upgradeWithDefinition = upgradeWithDefinition;
128
- scope.implementPrototype = implementPrototype;
129
-
130
- });