Files
@ 2465f2645e2e
Branch filter:
Location: symposion_app/static/src/js/app.js
2465f2645e2e
5.3 KiB
application/javascript
urlize abstracts
I've looked through the database and I can't find any accepted
proposals that actually contain anything to linkify - but I've had
several requests from people that I think are reasonable, things like
being able to link to their project (we ask them to provide a project
url but we don't use that link)
This seems like a reasonably fast way to let those people add a
link. We still have to manually accept changes to their proposal so we
have a chance to look at the content of the url if we want.
The urlize filter adds rel=nofollow to the link automatically.
I've looked through the database and I can't find any accepted
proposals that actually contain anything to linkify - but I've had
several requests from people that I think are reasonable, things like
being able to link to their project (we ask them to provide a project
url but we don't use that link)
This seems like a reasonably fast way to let those people add a
link. We still have to manually accept changes to their proposal so we
have a chance to look at the content of the url if we want.
The urlize filter adds rel=nofollow to the link automatically.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
var u = require('./includes/utils');
var debug = function debug(msg) {
return console.log(msg);
};
var setupTabs = require('./components/tabbed-panel');
u.documentReady(function () {
if (document.querySelector('[data-tab-control]')) {
setupTabs();
}
var menuOpener = document.querySelector('[data-menu-opener]');
if (menuOpener) {
u.addEventListener(menuOpener, 'click', function (e) {
e.preventDefault();
u.toggleClass(this, 'is-active');
u.toggleClass(document.querySelector('[data-menu]'), 'is-active');
});
}
});
},{"./components/tabbed-panel":2,"./includes/utils":3}],2:[function(require,module,exports){
'use strict';
var u = require('../includes/utils');
function setupTabs() {
var elements = document.querySelectorAll('[data-tab-control]');
for (var x = 0; x < elements.length; x++) {
u.addEventListener(elements[x], 'click', tabClickhandler);
}
// Activate the first element with 'is-active' found
var event = document.createEvent('Events');
event.initEvent('click', true, false);
elements = document.querySelectorAll('[data-tab-control].is-active');
elements[0].dispatchEvent(event);
}
function tabClickhandler(e) {
e.preventDefault();
var active = document.querySelectorAll('[data-tab-control].is-active, [data-tab-content].is-active');
if (active) {
for (var y = 0; y < active.length; y++) {
u.removeClass(active[y], 'is-active');
}
}
u.addClass(this, 'is-active');
var targetData = this.dataset.tabControl;
var targetContent = document.querySelectorAll('[data-tab-content="' + targetData + '"]');
for (var z = 0; z < targetContent.length; z++) {
u.addClass(targetContent[z], 'is-active');
}
}
module.exports = setupTabs;
},{"../includes/utils":3}],3:[function(require,module,exports){
"use strict";
module.exports = {
getRandomInRange: getRandomInRange,
getAnchorTarget: getAnchorTarget,
documentReady: documentReady,
addClass: addClass,
hasClass: hasClass,
removeClass: removeClass,
toggleClass: toggleClass,
addEventListener: addEventListener,
getUrl: getUrl
};
function getRandomInRange(from, to) {
return (Math.random() * (to - from) + from).toFixed(0) * 1;
}
function getAnchorTarget(link) {
var id = link.hash.replace("#", "");
return document.getElementById(id) || null;
}
function addClass(element, className) {
if (element instanceof SVGElement) {
element.setAttribute('class', element.getAttribute('class') + ' ' + className);
} else {
if (element.classList) {
element.classList.add(className);
} else {
element.className += ' ' + className;
}
}
}
function removeClass(element, className) {
if (element instanceof SVGElement) {
var updatedClassListString = element.getAttribute('class').replace(new RegExp('(\\s|^)' + className + '(\\s|$)', 'g'), '$2');
element.setAttribute('class', updatedClassListString);
} else {
if (element.classList) {
element.classList.remove(className);
} else {
var classes = element.className.split(' ');
var existingIndex = classes.indexOf(className);
if (existingIndex >= 0) {
classes.splice(existingIndex, 1);
}
element.className = classes.join(' ');
}
}
}
function hasClass(element, className) {
if (element instanceof SVGElement) {
return new RegExp('(\\s|^)' + className + '(\\s|$)').test(element.getAttribute('class'));
} else {
if (element.classList) {
return element.classList.contains(className);
} else {
return element.className.indexOf(className) !== -1;
}
}
}
function toggleClass(element, className) {
if (element.classList) {
element.classList.toggle(className);
} else {
var classes = element.className.split(' ');
var existingIndex = classes.indexOf(className);
if (existingIndex >= 0) {
classes.splice(existingIndex, 1);
} else {
classes.push(className);
}
element.className = classes.join(' ');
}
}
function addEventListener(el, eventName, handler) {
if (el.addEventListener) {
el.addEventListener(eventName, handler);
} else {
el.attachEvent('on' + eventName, function () {
handler.call(el);
});
}
}
function getUrl(path) {
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
}
if (path.indexOf('./') === 0) {
path = path.slice(1); // Remove the .
var existingPath = window.location.pathname || '';
return window.location.origin + existingPath + path;
} else if (path) {
return window.location.origin + path;
} else {
return window.location.origin + window.location.pathname;
}
}
function documentReady(fn) {
if (document.readyState != 'loading') {
fn();
} else if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', fn);
} else {
document.attachEvent('onreadystatechange', function () {
if (document.readyState != 'loading') fn();
});
}
}
},{}]},{},[1]);
|