Commit 3ce0982f authored by Michael Murtaugh's avatar Michael Murtaugh

changes to generalize, fragment support, more media types accepted for ccframe

parent 78977c9d
This diff is collapsed.
......@@ -133,8 +133,8 @@ class CCEditor {
this.window = window;
this.elt.addEventListener("click", this.clicker.bind(this));
this.elt.addEventListener("touchend", this.clicker.bind(this));
window.addEventListener("hashchange", this.hashchange.bind(this));
this.hashchange();
// window.addEventListener("hashchange", this.hashchange.bind(this));
// this.hashchange();
this.setup_keys();
}
/* Map URL and timecode clicks */
......@@ -288,7 +288,7 @@ class CCEditor {
}
set src (href) {
// console.log("cceditor.set src", href);
if (href !== this.current_href) {
if (href && href !== this.current_href) {
this.current_href = href;
var that = this;
getText(href, function (err, text) {
......
......@@ -29,7 +29,7 @@ var DEFAULT_CONFIG = {
content: [{
type: 'component',
componentName: 'cceditor',
componentState: { href: 'index.md', target: "editor" }
componentState: { href: '', target: "editor" }
}]
}]
}]
......@@ -191,13 +191,51 @@ class CCEditorApp {
},
notie: notie
});
container.setTitle(componentState.href);
var initial_href = componentState.href;
if (!initial_href) {
var initial_hash = window.location.hash;
var m = initial_hash.match(/^#(.+)/);
if (m !== null) {
initial_href = m[1];
}
}
container.setTitle(initial_href);
frames_by_target[componentState.target] = editor;
container.on("resize", function () {
// console.log("lm.resize");
editor.resize();
})
editor.src = componentState.href;
editor.src = initial_href;
/* HASH HANDLING */
window.addEventListener("hashchange", function (e) {
// console.log('hashchange', e);
var hash = window.location.hash,
m = hash.match(/^#(.+)/);
if (m !== null) {
hash = m[1];
// console.log("new fragment", hash);
open_in_editor(hash);
}
}, false);
function open_in_editor (href) {
var component = that.find_editor(href);
if (component) {
// console.log("found matching cceditor component", component);
component.parent.setActiveContentItem(component);
} else {
// var editstack = app.layout.root.getItemsById("editorstack")[0];
var editstack = that.get_editor_stack();
editstack.addChild({
'type': 'component',
componentName: 'cceditor',
componentState: { href: href, target: "editor" }
})
}
}
function handle_link (href, target) {
// HANDLE HREF + TARGET
......@@ -205,19 +243,7 @@ class CCEditorApp {
if (href.match(/\.md$/) && !target) {
// EDITOR LINK
// console.log("editor link");
var component = that.find_editor(href);
if (component) {
// console.log("found matching cceditor component", component);
component.parent.setActiveContentItem(component);
} else {
// var editstack = app.layout.root.getItemsById("editorstack")[0];
var editstack = that.get_editor_stack();
editstack.addChild({
'type': 'component',
componentName: 'cceditor',
componentState: { href: href, target: "editor" }
})
}
open_in_editor(href);
} else {
// OTHER LINKS
target = target || "link";
......
......@@ -72,7 +72,7 @@ class CCFrame {
// console.log("purl", purl, "previous", previous_url)
var viewers = {
'video': {
pattern: /\.(mp4|webm)$/,
pattern: /\.(mp4|webm|ogv|ogg|mp3)$/,
viewer: function (m) {
/* Check if match previous_url */
if (this.video && previous_url && previous_url.base == purl.base) {
......
function classcycler (button, target, modes) {
var ret = {};
var i = 0;
button.addEventListener("click", function () {console.log("cycle"+i, button, target); target.classList.replace(modes[i], modes[i = (i+1) % modes.length]); });
function set_index () {
var l; // nb changes i in classcycler scope
for (i=0, l=modes.length; i<l; i++) {
if (target.classList.contains(modes[i])) { return; }
}
}
button.addEventListener("click", function () {
set_index();
console.log("i", i);
target.classList.replace(modes[i], modes[i = (i+1) % modes.length]);
});
ret.set_mode = function (m) {
set_index();
target.classList.replace(modes[i], m);
}
return ret;
}
// classcycler(gebi("toggle"), gebi("content"), "splitscreen overlay".split(" "));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment