-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c4188c
commit 304b708
Showing
10 changed files
with
185 additions
and
442 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
.acodecode { | ||
cursor: pointer; | ||
} | ||
|
||
.acodecodeactive { | ||
cursor: default; | ||
} | ||
|
||
.codecodecode { | ||
position: fixed; | ||
z-index: 100; | ||
left: 2%; | ||
bottom: -30px; | ||
width: 96%; | ||
height: 0; | ||
max-height: 270px; | ||
text-align: left; | ||
} | ||
|
||
.codecodecode > div { | ||
box-shadow: 0 0 3px #444; | ||
} | ||
|
||
.codecodecontrols { | ||
height: 30px; | ||
margin-top: -30px; | ||
background-color: #fff; | ||
background-color: rgba(255, 255, 255, .8); | ||
border-radius: 8px 8px 0 0; | ||
} | ||
|
||
.codecodecontrols a { | ||
float: left; | ||
line-height: 30px; | ||
margin-left: 6px; | ||
font-family: Arial; | ||
font-size: 12px; | ||
} | ||
|
||
.codecodecontrols .closeCodeCode { | ||
float: right; | ||
margin-right: 6px; | ||
} | ||
|
||
.codecode, | ||
.acodecode.codecode { | ||
border-radius: 0 !important; | ||
position: relative !important; | ||
width: 100% !important; | ||
margin: 0 !important; | ||
overflow: auto !important; | ||
cursor: default !important; | ||
} | ||
|
||
div.codecode [id^=highlighter] div.bar.show, | ||
div.codecode [id^=highlighter] div.toolbar { | ||
display: none !important; | ||
}; |
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,122 @@ | ||
(function ($, win, doc) { | ||
'use strict'; | ||
|
||
var el = {}; | ||
var codePosition; | ||
|
||
el.body = $(doc.body); | ||
|
||
el.codecodecode = $([ | ||
'<div class="codecodecode">', | ||
' <div class="codecodecontrols">', | ||
' <a class="goBackToTheCode" href="#">go back to the code.</a>', | ||
' <a class="closeCodeCode" href="#">close.</a>', | ||
' </div>', | ||
' <div class="codecode"></div>', | ||
'</div>' | ||
].join('\n')); | ||
|
||
el.goBackToTheCode = el.codecodecode.find('.goBackToTheCode'); | ||
el.closeCodeCode = el.codecodecode.find('.closeCodeCode'); | ||
el.codecode = el.codecodecode.find('.codecode'); | ||
|
||
el.body.append(el.codecodecode); | ||
|
||
el.goBackToTheCode.on('click', goBackToTheCode); | ||
el.closeCodeCode.on('click', closeCodeCode); | ||
|
||
function goBackToTheCode(e) { | ||
e.preventDefault(); | ||
|
||
closeCodeCode(); | ||
|
||
el.body.animate({ scrollTop: codePosition - 20 }, 2000); | ||
}; | ||
|
||
function closeCodeCode(e, callback) { | ||
if ($.type(e) === 'object') { | ||
e.preventDefault(); | ||
} | ||
|
||
el.body.off('keyup'); | ||
|
||
el.codecodecode.animate({ bottom: '-300px' }, 300, callback || $.noop); | ||
|
||
$('.acodecodeactive').removeClass('acodecodeactive'); | ||
}; | ||
|
||
function openCodeCode(codeblock) { | ||
el.codecodecode.animate({ bottom: 0 }, 500); | ||
|
||
el.body.on('keyup', function (e) { | ||
if (e.which === 27) { | ||
closeCodeCode(); | ||
} | ||
}); | ||
|
||
codeblock.addClass('acodecodeactive'); | ||
}; | ||
|
||
function bindCodeCodeClick(selector) { | ||
el.body.on('click', selector, function () { | ||
var codeblock = $(this); | ||
var clone; | ||
|
||
if (codeblock.hasClass('acodecodeactive') || | ||
codeblock.hasClass('codecode')) { | ||
return; | ||
} | ||
|
||
codePosition = $(this).position().top; | ||
|
||
clone = codeblock.clone().addClass('codecode'); | ||
|
||
closeCodeCode(null, function () { | ||
el.codecode | ||
.empty() | ||
.append(clone.css('margin', '0 !important')) | ||
.height('auto'); | ||
|
||
el.codecodecode.height( | ||
(el.codecode.height() >= 270) ? 270 : el.codecode.height() | ||
); | ||
|
||
el.codecode.height('100%'); | ||
}); | ||
|
||
openCodeCode(codeblock); | ||
}); | ||
}; | ||
|
||
$.fn.codecode = function () { | ||
bindCodeCodeClick(this.selector); | ||
|
||
return this.addClass('acodecode'); | ||
}; | ||
|
||
if (typeof SyntaxHighlighter !== 'undefined') { | ||
SyntaxHighlighter.all = (function () { | ||
var callSyntaxHighlighter = SyntaxHighlighter.all; | ||
var syntaxActivated = false; | ||
var checkForSyntaxEls; | ||
var tried = 0; | ||
|
||
function hasSyntaxBeenHighlighted() { | ||
if ($('.syntaxhighlighter').length > 0) { | ||
$('.syntaxhighlighter').codecode(); | ||
syntaxActivated = true; | ||
} | ||
|
||
if (syntaxActivated || tried++ > 50) { | ||
win.clearInterval(checkForSyntaxEls); | ||
} | ||
}; | ||
|
||
return function () { | ||
callSyntaxHighlighter(); | ||
|
||
checkForSyntaxEls = win.setInterval(hasSyntaxBeenHighlighted, 50); | ||
} | ||
})(); | ||
} | ||
})(jQuery, window, document); |
Oops, something went wrong.