-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from MPIB/refactor-lagerregal-js
Refactor: reduce amount of inline javascript
- Loading branch information
Showing
25 changed files
with
189 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-08-08 15:32+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
#: static/js/lagerregal.js:50 | ||
msgid "" | ||
"Hi! I am Clippy, your Lagerregal assistant. Would you like some assistance " | ||
"totday?" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
# This file is distributed under the same license as the PACKAGE package. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-08-08 15:32+0200\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
#: static/js/lagerregal.js:50 | ||
msgid "" | ||
"Hi! I am Clippy, your Lagerregal assistant. Would you like some assistance " | ||
"totday?" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
(function() { | ||
$(document).ajaxSend(function (event, xhr, settings) { | ||
function getCookie(name) { | ||
var cookieValue = null; | ||
if (document.cookie && document.cookie != '') { | ||
var cookies = document.cookie.split(';'); | ||
for (var i = 0; i < cookies.length; i++) { | ||
var cookie = jQuery.trim(cookies[i]); | ||
// Does this cookie string begin with the name we want? | ||
if (cookie.substring(0, name.length + 1) == (name + '=')) { | ||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); | ||
break; | ||
} | ||
} | ||
} | ||
return cookieValue; | ||
} | ||
|
||
function sameOrigin(url) { | ||
// url could be relative or scheme relative or absolute | ||
var host = document.location.host; // host + port | ||
var protocol = document.location.protocol; | ||
var sr_origin = '//' + host; | ||
var origin = protocol + sr_origin; | ||
// Allow absolute or scheme relative URLs to same origin | ||
return (url == origin || url.slice(0, origin.length + 1) == origin + '/') || | ||
(url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') || | ||
// or any other URL that isn't scheme relative or absolute i.e relative. | ||
!(/^(\/\/|http:|https:).*/.test(url)); | ||
} | ||
|
||
function safeMethod(method) { | ||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); | ||
} | ||
|
||
if (!safeMethod(settings.type) && sameOrigin(settings.url)) { | ||
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); | ||
} | ||
}); | ||
|
||
var helper; | ||
$(document).ready(function() { | ||
$("#id_searchname").focusin( function() { | ||
window.setTimeout( function() { | ||
if ($("#id_searchname").is(":focus")) { | ||
if (helper == undefined) { | ||
clippy.load('Clippy', function (agent) { | ||
helper = agent; | ||
helper.show(); | ||
helper.speak(django.gettext("Hi! I am Clippy, your Lagerregal assistant. Would you like some assistance totday?")); | ||
}); | ||
} | ||
} else { | ||
helper.animate(); | ||
} | ||
}, 60000 ); | ||
}); | ||
|
||
$('[data-timeago]').timeago(); | ||
$('[data-toggle="popover"]').popover(); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.