Skip to content

Commit

Permalink
Fixed few bugs on Opera and FF in Portal and Client app.
Browse files Browse the repository at this point in the history
  • Loading branch information
bubersson committed May 1, 2012
1 parent 0df7ec7 commit d978499
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,4 +1,4 @@
/nbproject/**
/toys/**
/public/data/slides
/public/data/slides/**
/cache/**
6 changes: 0 additions & 6 deletions handlers/ajaxcrawling.js
Expand Up @@ -15,12 +15,6 @@ var SLIDES_DIRECTORY = (path.join(path.dirname(__filename), '../public/data/slid
var jquery = fs.readFileSync('./public/lib/jquery-1.7.min.js').toString();
var jsdom = require('jsdom');

/** ---- WINDOWS SAVING FILES:
var pathSep=process.platform =='win32' ? '\\' : '/';
path.replace('/',pathSep)]
*
**/


/** Make slides AJAX Crawable
* - get one slide HTML
Expand Down
8 changes: 4 additions & 4 deletions handlers/comments.js
Expand Up @@ -19,7 +19,7 @@ app.get('/api/:course/:lecture/:slide/comments', function(req, res) {
slideID: p.slide
});
query.asc('date');
query.limit(10);
query.limit(10); // TODO: vymyslet listování po deseti!!!


query.exec(function (err, com) {
Expand Down Expand Up @@ -47,7 +47,7 @@ app.post('/api/:course/:lecture/:slide/comments', function(req, res, next){
console.log("REQ-body "+JSON.stringify(req.body));
console.log("REQ-user "+JSON.stringify(req.user));
if (!req.isAuthenticated()) {
res.writeHead(401); //BAD_REQUEST
res.writeHead(401); //UNAUTHORIZED
res.write("You ain't no logged, bro!");
res.end();
return;
Expand All @@ -68,7 +68,7 @@ app.post('/api/:course/:lecture/:slide/comments', function(req, res, next){
com.author = {
username:req.user.email,
email:req.user.email
}; // TODO: implementovat ověřování
};
com.save(function(err) {
if(err) {
console.log("ERR");
Expand All @@ -83,6 +83,6 @@ app.post('/api/:course/:lecture/:slide/comments', function(req, res, next){
});


app.del('/api/:course/:lecture/:slide/comments', function(req, res, next){
app.put('/api/:course/:lecture/:slide/comments', function(req, res, next){
//TODO: napsat buď jako DELETE, nebo jako PUT
});
Binary file added public/humla/icons/m-facebook.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/humla/lib/config.json
Expand Up @@ -370,6 +370,18 @@
} ],
"enabled" : true
},
{
"id" : "social",
"object" : "ex_social",
"scripts" : [ {
"src" : "ext/social/social.js"
} ],
"styles" : [ {
"src" : "ext/social/social.css",
"media" : "screen, print"
} ],
"enabled" : true
},

{
"id" : "editor",
Expand Down
2 changes: 1 addition & 1 deletion public/humla/lib/core/humla-core.js
Expand Up @@ -537,7 +537,7 @@ var User = function(check) {
} else { //status == 401 or fail
this.email = null;
this.username = null;
this.logged = true;
this.logged = false;
if(cb) cb(err ? err : true);
}
});
Expand Down
1 change: 1 addition & 0 deletions public/humla/lib/ext/database/indexeddb.js
Expand Up @@ -30,6 +30,7 @@ var ext_indexeddb = {
console.log(e);
},
open : function(callback){
if(!indexedDB) return; // Opera doesn't have indexedDB a fails on this one, TODO: edit
var request = indexedDB.open(ext_indexeddb.dbName);

request.onsuccess = function(e) {
Expand Down
31 changes: 3 additions & 28 deletions public/humla/lib/ext/github.js
Expand Up @@ -19,33 +19,8 @@ var ex_github = {
return;
}

var updateCode = function(code) {
var fc = code ? code : "";
if (fc === "") {
// create empty code with the same size as the resulting code
for (var i = 0; i < this.lineTo - this.lineFrom + 2; i++)
fc += " \n";
this.element.style.opacity = "0.3";
} else {
var s = fc.split("\n"), fc = "";
for (var i = this.lineFrom - 1; i < this.lineTo; i++)
if (i < s.length)
fc += s[i] + "\n";
this.element.style.opacity = "1";
}
this.pre.innerHTML = fc.replace(/</g, "&lt;");
this.element.innerHTML = "";
this.element.appendChild(this.pre);
SyntaxHighlighter.highlight(null, this.pre);

var shl = this.element.getElementsByClassName("syntaxhighlighter");
if (shl && shl.length > 0) {
shl[0].tb = config.tb;
shl[0].setAttribute("onmouseover", "this.tb.className = 'toolbar2-visible'");
shl[0].setAttribute("onmouseout", "this.tb.className = 'toolbar2'");
shl[0].appendChild(config.tb);
}
};



var refreshCode = function() {
var xhr = new XMLHttpRequest();
Expand All @@ -62,7 +37,7 @@ var ex_github = {
xhr.send();
};

for (var i = 0; i < el.length; i++) {
for (i = 0; i < el.length; i++) {
// get attributes
var config = {
element : el[i],
Expand Down
5 changes: 5 additions & 0 deletions public/humla/lib/ext/social/social.css
@@ -0,0 +1,5 @@


nav #menu-item-social {
background-image: url("../../../icons/m-facebook.png");
}
31 changes: 31 additions & 0 deletions public/humla/lib/ext/social/social.js
@@ -0,0 +1,31 @@
/**
* Social Extension
* ~~~~~~~~~~~~~~~
* Ability to share slides on facebook
*
*/


var ex_social = {

processMenu: function(menu) {

menu.addTab("social",{
name:"Share on Facebook",
cb: function() {
var presentationUrl = window.location.origin + window.location.pathname + window.location.hash;
//var presentationUrl = window.location.href;
//https://www.facebook.com/sharer.php?u=<url to share>&t=<title of content>
var link ="http://www.facebook.com/sharer.php?";
link += "u="+encodeURIComponent(presentationUrl);
link += "&t=Lecture";
//link += "&p[summary]=YOUR_SUMMARY";
//link += "&p[images][0]=YOUR_IMAGE_TO_SHARE_OBJECT";
humla.utils.window.location.href = link;
},
show_layer:false // pro callback bez menu-layeru se dá false

});
}

}
20 changes: 12 additions & 8 deletions public/humla/lib/ext/tests/tests.css
@@ -1,22 +1,24 @@


.test .button {
width: 116px;
.test .buttons{
position: absolute;
bottom: 40px;
left: 20px;
}

.test .button {
font-size: 140%;
text-align: center;
cursor: pointer;
background: white;
background: -webkit-gradient(linear, left top, left bottom, from(white), to(#DDD));
color: #444;
/*float: right;*/
margin: 12px 4px;
padding: 2px 5px;
padding: 2px 16px;
border: 1px solid #888;
-webkit-border-radius: 5px;
border-radius: 5px;
position: absolute;
bottom: 40px;
left: 20px;
float: left;
}


Expand All @@ -32,6 +34,7 @@

.test .question {
display: block;
max-width: 246px;
font-size: 120%;
text-shadow: 1px 1px 2px #CCC;
padding: 0px 10px;
Expand Down Expand Up @@ -88,7 +91,8 @@
font-size:200%;
position: absolute;
bottom: 50px;
left: 240px;
right: 20px;
width: 400px;
}
.test #tests-result .percent {
font-size: 140%;
Expand Down
25 changes: 19 additions & 6 deletions public/humla/lib/ext/tests/tests.js
Expand Up @@ -20,7 +20,7 @@ var ex_tests = {
// Functions
testsClick: null,
testsConfirm: null,

testsClear: null,

processSlide : function(slide) {

Expand Down Expand Up @@ -77,6 +77,17 @@ var ex_tests = {
ex_tests.results[val[0]].answers[val[1]].selected = !checked;
}

// Clear answers
this.testsClear = function() {
// clear all clicked
for(i = 0; i<this.results.length;i++) {
for(j=0;j<this.results[i].answers.length;j++) {
this.results[i].answers[j].selected= false;
}
}
this.showQuestions(slide, false)
}

// listener čeká na zmáčknutí ohodnocení
this.testsConfirm = function() {
var text = "";
Expand Down Expand Up @@ -117,14 +128,14 @@ var ex_tests = {
// počet celkových bodů


this.showQuestions(slide, false)
this.showQuestions(slide, true)


}
},

showQuestions: function (slide, showAns) {
var hg = slide.element.getElementsByTagName("hgroup"),
var hg = slide.element.getElementsByTagName("hgroup"),
h = (hg.length === 0 ? "<hgroup><h1>Test</h1></hgroup>" : "<hgroup>"+hg[0].innerHTML+"</hgroup>");

h+= "<div id='tests-questions'>";
Expand All @@ -135,7 +146,8 @@ var ex_tests = {
h+= res.question;
h+='</h2><ul class="answers">'
for(j=0;j<res.answers.length;j++) {
h+='<li class="'+(res.answers[j].selected?'checked':'')+'"onclick="ex_tests.testsClick(this);" title="'+i+';'+j+'" data-test-question="'+i+'" data-test-answer="'+j+'">';

h+='<li class="'+(res.answers[j].selected && showAns ?'checked':'')+'"onclick="ex_tests.testsClick(this);" title="'+i+';'+j+'" data-test-question="'+i+'" data-test-answer="'+j+'">';
h+= res.answers[j].text;
h+='</li>';
}
Expand All @@ -144,8 +156,9 @@ var ex_tests = {
}
h+="</div>";

// Add button
h+='<div class="button" onclick="ex_tests.testsConfirm(this);">Show answers</div>'
// Add buttons
h+='<div class="buttons"><div class="button" onclick="ex_tests.testsConfirm(this);">Show answers</div>'
h+='<div class="button" onclick="ex_tests.testsClear(this);">Clear</div></div>'

h+="<div id='tests-result'></div>";

Expand Down
4 changes: 2 additions & 2 deletions public/humla/lib/humla.js
Expand Up @@ -390,7 +390,7 @@ var Utils = function(window) {
this.firstUserStyle = "";

// style has not been found - add it
if (this.firstUserStyle == "")
if (this.firstUserStyle == "" || this.browser == "Opera" || this.browser == "Firefox") // opera, ff hack
this.documentHead.appendChild(this.createStyleElement(style, media));
else
this.documentHead.insertBefore(this.createStyleElement(style, media), this.firstUserStyle);
Expand Down Expand Up @@ -568,7 +568,7 @@ document.addEventListener("DOMContentLoaded", function() {
if (navigator.userAgent == "no-ga-tv" ||
(browser.browser == "Chrome" && browser.version >= 13) ||
(browser.browser == "Firefox" && browser.version >= 4) ||
(browser.browser == "Safari" && browser.version >= 5.1) ||
(browser.browser == "Safari" && browser.version >= 5.1) ||
(browser.browser == "Opera") ||
browser.browser == "wkhtmltopdf") {
document.getElementsByTagName("body")[0].style.visibility = "hidden";
Expand Down
12 changes: 10 additions & 2 deletions public/pages/css/style.css
Expand Up @@ -194,23 +194,31 @@ nav #presentations:hover {
border-left: 1px solid #8C5D26;
border-top: 1px solid #8C5D26;
border-right: 1px solid #8C5D26;

}

nav #tools:hover {
background: #3F9DCD;
border-left: 1px solid #26698C;
border-top: 1px solid #26698C;
border-right: 1px solid #26698C;

}

nav #about:hover {
background: #CE4079;
border-left: 1px solid #8C2664;
border-top: 1px solid #8C2664;
border-right: 1px solid #8C2664;
}

nav #facet:hover {
background: #53CF3F;
border-left: 1px solid #2D8C26;
border-top: 1px solid #2D8C26;
border-right: 1px solid #2D8C26;
}



nav li > a.active {
opacity: 1;
}
Expand Down
14 changes: 7 additions & 7 deletions public/pages/lib/page-script.js
Expand Up @@ -112,8 +112,8 @@ function DataAccess() {
console.log("_"+c.presentationURL);
new_element.setAttribute('data-link', c.presentationURL);
new_element.setAttribute('data-id', c._id);
new_element.setAttribute('id', c.courseID+';'+c.lectureID);
new_element.setAttribute('title', c.presentationURL); // kvulit IE
new_element.setAttribute('id', c.courseID+';'+c.lectureID+';'+c._id);
new_element.setAttribute('title', c.presentationURL);
lectures_ul.insertBefore(new_element, lectures_ul.firstChild);
}

Expand Down Expand Up @@ -147,8 +147,8 @@ function DataAccess() {
// First fill all available info about slide and then send request to index API
this.loadInfo = function (elm) { //(course_id,lect_id) {
var url = elm.dataset ? elm.dataset.link : elm.title;
var lecture = this.findLecture(elm.dataset ? elm.dataset.id : -1);
var t = ($(elm).attr('id')).split(';');
var lecture = this.findLecture(elm.dataset ? elm.dataset.id : t[2]); // hack kvuli IE

var a = '<h2 id="lecturename">'+lecture.title+'</h2>';
a+= '<div id="buttons"><a href="http://'+url+'" target="_blank" class="button" tabindex="3">Open</a>';
Expand Down Expand Up @@ -184,12 +184,12 @@ function DataAccess() {
var t = index.structure.index[item];
ul.push('<li class="slideindex-li"><a class="slideindex-structure-top" href="http://'+t.url+'">'+t.title+'</a>');
if(t.chapters && t.chapters.length>0){ // TODO: zarovnat všechny podle šipky
ul.push("<img src=\"../../../humla/lib/ext/slideindex-left.png\" onClick=\"pageHandler.dropdown(this, 'slideindex-structure-secondLevel"+item+"');\" title=\"Show content\" alt=\"Show content\"/><ul id=\"slideindex-structure-secondLevel"+item+"\" class=\"slideindex-hidden\" >");
ul.push("<img src=\"../../../humla/lib/ext/slideindex/slideindex-left.png\" onClick=\"pageHandler.dropdown(this, 'slideindex-structure-secondLevel"+item+"');\" title=\"Show content\" alt=\"Show content\"/><ul id=\"slideindex-structure-secondLevel"+item+"\" class=\"slideindex-hidden\" >");
for(var chapter in t.chapters){
var ch = t.chapters[chapter];
ul.push("<li class=\"slideindex-li\"><a class=\"slideindex-structure-chapter\" href=\"http://"+ch.url+"\">"+ch.title+"</a>");
if(ch.slides && ch.slides.length>0){
ul.push("<img src=\"../../../humla/lib/ext/slideindex-left.png\" onClick=\"pageHandler.dropdown(this, 'slideindex-structure-thirdLevel"+chapter+"');\" title=\"Show content\" alt=\"Show content\"/><ul id=\"slideindex-structure-thirdLevel"+chapter+"\" class=\"slideindex-hidden\" >");
ul.push("<img src=\"../../../humla/lib/ext/slideindex/slideindex-left.png\" onClick=\"pageHandler.dropdown(this, 'slideindex-structure-thirdLevel"+chapter+"');\" title=\"Show content\" alt=\"Show content\"/><ul id=\"slideindex-structure-thirdLevel"+chapter+"\" class=\"slideindex-hidden\" >");
for(var s in ch.slides){
var simpleSlide = ch.slides[s];
ul.push("<li class=\"slideindex-li\"><a class=\"slideindex-structure-slide\" href=\"http://"+simpleSlide.url+"\">"+simpleSlide.title+"</a>");
Expand Down Expand Up @@ -343,12 +343,12 @@ function PageHandler(){
// Make dropdown clicks
this.dropdown = function (img,idOflist) {
if(img.src.indexOf("left")>0){
img.src="../../../humla/lib/ext/slideindex-down.png";
img.src="../../../humla/lib/ext/slideindex/slideindex-down.png";
img.title = "Hide content";
img.alt="Hide content";
document.getElementById(idOflist).setAttribute("class", 'slideindex-visible');
}else{
img.src="../../../humla/lib/ext/slideindex-left.png";
img.src="../../../humla/lib/ext/slideindex/slideindex-left.png";
document.getElementById(idOflist).setAttribute("class", 'slideindex-hidden');
img.title = "Show content";
img.alt="Show content";
Expand Down

0 comments on commit d978499

Please sign in to comment.