Removed global client-side scripts array and refactored page-specific scripts, now that library code is loaded at once

This commit is contained in:
Tobi Schäfer 2015-01-30 23:59:40 +01:00
parent 29175bec5c
commit 6276392100
15 changed files with 26 additions and 32 deletions

View file

@ -9,10 +9,6 @@ require('uikit-bower/js/uikit');
require('uikit-bower/js/components/form-password');
$(function() {
for (var i = 0; i < scripts.length; i += 1) {
scripts[i].call();
}
// Extend jQuery with selectText() method.
$.fn.selectText = function() {
var element = this.get(0);

View file

@ -107,7 +107,7 @@
</div>
</form>
<script type="text/javascript">
scripts.push(function() {
$(function() {
$("#creationScope").on('change', function() {
var disabled = $(this).val() === "regular" ? false : true;
$("#probationPeriod").attr("disabled", disabled);

View file

@ -24,7 +24,7 @@
</div>
</div>
<script type="text/javascript">
scripts.push(function() {
$(function() {
$('#confirmation').hide();
$('#mode').on('click', function() {
if ($(this).prop('checked')) {

View file

@ -64,7 +64,7 @@
</div>
</form>
<script type="text/javascript">
scripts.push(function() {
$(function() {
if ('<% file.name %>') {
$('#name').attr('disabled', true);
}

View file

@ -38,7 +38,7 @@
</div>
</div>
<script>
scripts.push(function () {
$(function () {
$('.av-upload input[type="file"]').on('change', function (event) {
$('#<% param.name %>_origin').val($(this).val());
});

View file

@ -102,7 +102,7 @@
</div>
</form>
<script type="text/javascript">
scripts.push(function() {
$(function() {
if ('<% image.name %>') {
$('#name').attr('disabled', true);
$('#maxWidth').attr('disabled', true);

View file

@ -36,7 +36,7 @@
</div>
</form>
<script type='text/javascript'>
scripts.push(function() {
$(function() {
$('#addVariable').on('click', function (event) {
event.preventDefault();
var name = prompt('<% gettext "Please enter the name of the new variable:" %>');

View file

@ -68,7 +68,7 @@
</div>
</form>
<script type="text/javascript">
scripts.push(function() {
$(function() {
$("form#login").on('submit', function (event) {
var name = $("#name").val();
$.ajax({
@ -129,7 +129,7 @@ scripts.push(function() {
</div>
</form>
<script type="text/javascript">
scripts.push(function() {
$(function() {
$("form#register").submit(function() {
var token = "<% session.token %>";
var password = $("#password").val();

View file

@ -120,7 +120,7 @@ else
</div>
</form>
<script type="text/javascript">
scripts.push(function() {
$(function() {
var index = $(".choice").length + 1;
$("#add").on('click', function (event) {
event.preventDefault();

View file

@ -3,12 +3,17 @@
<% #urlPreview %>
<a id='av-site-url-preview'></a>
<script>
scripts.push(function () {
<script type='text/javascript'>
$(function () {
$('#name').on('keyup', function (event) {
var url = '<% root.href %>' + $(this).val();
var html = '<% root.href %>' + '<b>' + $(this).val() + '</b>';
$('#av-site-url-preview').html(html).attr('href', url);
var name = $(this).val();
if (name) {
var url = '<% root.href %>' + name;
var html = '<% root.href %>' + '<b>' + name + '</b>';
$('#av-site-url-preview').html(html).attr('href', url);
} else {
$('#av-site-url-preview').html(name);
}
});
});
</script>

View file

@ -79,16 +79,12 @@ document.addEventListener('DOMContentLoaded', function () {
<% site.skin Site#javascript | script %>
window.scripts = [];
<% #include %>
(function (url) {
//document.writeln("<script type='text/javascript' src='<% param.href %>'></script>");
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
var scripts = document.head.getElementsByTagName('script');
document.head.insertBefore(script, scripts[0]);
document.head.appendChild(script);
})('<% param.href %>');
<% #stylesheet %>
@ -552,7 +548,7 @@ a.gs-title:hover {
</tbody>
</table>
<script type="text/javascript">
scripts.push(function () {
$(function () {
var query = new Antville.Query();
var spamFilter = new Antville.Filter([<% site.spamfilter %>]);
var searchFilter = new Antville.Filter(query.filter);
@ -829,7 +825,7 @@ scripts.push(function () {
</div>
</form>
<script>
scripts.push(function () {
$(function () {
$('input#callbackMode').on('click', function(event) {
$('input#callbackUrl').prop('disabled', !this.checked);
});

View file

@ -36,7 +36,7 @@
<% skin.textarea source %>
</form>
<script type='text/javascript'>
scripts.push(function() {
$(function() {
var mode;
if (location.href.indexOf('stylesheet') > -1) {
mode = 'text/css';

View file

@ -63,7 +63,7 @@ else
<% #restore %>
<script type="text/javascript">
scripts.push(function() {
$(function() {
var url = "<% site.href backup.js %>";
var input = $(".backup :input");

View file

@ -20,7 +20,7 @@
<% list.nextLink text="<i class='uk-icon-arrow-right'></i>" prefix=<li> suffix=</li> default="<li class='uk-disabled'><span><i class='uk-icon-arrow-right'></i></span></li>" %>
</ul>
<script type='text/javascript'>
scripts.push(function () {
$(function () {
$(function() {
var resizeTimer = null;
$('.av-tagged').collageCaption();

View file

@ -87,9 +87,8 @@
</div>
</form>
<script type="text/javascript">
scripts.push(function () {
$(function () {
$("#submit").click(function (event) {
//event.preventDefault();
var token = "<% session.token %>";
var salt = "<% session.salt %>";
var password = $("#password").val();
@ -97,9 +96,7 @@ scripts.push(function () {
var hash = $.md5(password + token);
$("#hash").val(hash);
$("#password").val("");
//$("#digest").val($.md5($.md5(password + salt) + token));
}
return true;
});
});
</script>