Skip to content

Commit

Permalink
0.0.3, src/ and dist/
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Apr 1, 2013
1 parent 8c1d587 commit 0c4188c
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ module.exports = function(grunt) {
+" * codecode.\n"
+" * v<%= pkg.version %> @stephenplusplus <%= grunt.template.today('m/d/yy') %>\n"
+" * github.com/stephenplusplus/codecode\n"
+" */\n\n"
+" */\n"
},
build: {
src: ['codecode.js'],
dest: 'codecode.min.js'
src: ['src/codecode.js'],
dest: 'dist/codecode.js'
}
},

Expand All @@ -25,11 +25,11 @@ module.exports = function(grunt) {
mangle: true,
compress: true,
preserveComments: 'some',
sourceMap: 'codecode.js.map'
sourceMap: 'dist/codecode.js.map'
},
build: {
src: 'codecode.min.js',
dest: 'codecode.min.js'
src: ['dist/codecode.js'],
dest: 'dist/codecode.min.js'
}
}
});
Expand Down
1 change: 0 additions & 1 deletion codecode.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions component.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "codecode",
"version": "0.0.2",
"version": "0.0.3",
"author": "Stephen Sawchuk",
"description": "codecode allows your readers to dock your syntax-highlighted code blocks to the bottom of the page, allowing them to refer back without losing their place in your article.",
"homepage": "http://stephenplusplus.github.com/codecode",
"main": "./codecode.js",
"main": "./dist/codecode.js",
"readme": "./readme.md",
"repository": {
"type": "git",
Expand Down
193 changes: 193 additions & 0 deletions dist/codecode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
/*!
* codecode.
* v0.0.3 @stephenplusplus 4/1/13
* github.com/stephenplusplus/codecode
*/
(function($, win, doc) {
var styles
='.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 {'
+ '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;'
+'}';

var el = {};
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>');

el.gobacktothecode
= el.codecodecode.find('.gobacktothecode');

el.closecodecode
= el.codecodecode.find('.closecodecode');

el.codecode
= el.codecodecode.find('.codecode');

el.body
.append('<style>'+styles+'</style>')
.append(el.codecodecode);

var codeposition;

var gobacktothecode = function(e) {
e.preventDefault();

closecodecode();

el.body.animate({ scrollTop: codeposition - 20 }, 2000);
};

var closecodecode = function(e, callback) {
if ($.type(e) === 'object')
e.preventDefault();

el.body.off('keyup');

el.codecodecode
.animate({ bottom: '-300px' }, 300, callback || $.noop);

$('.acodecodeactive').removeClass('acodecodeactive');
};

var opencodecode = function(codeblock) {
el.codecodecode
.animate({ bottom: 0 }, 500);

el.body.on('keyup', function(e) {
if (e.which === 27)
closecodecode();
});

codeblock
.addClass('acodecodeactive');
};

var bindcodecodeclick = function(selector) {
el.body.on('click', selector, function() {
var codeblock = $(this);

if (codeblock.hasClass('acodecodeactive') || codeblock.hasClass('codecode'))
return;

codeposition = $(this).position().top;

var 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);
});
};

el.gobacktothecode
.on('click', gobacktothecode);

el.closecodecode
.on('click', closecodecode);

$.fn.codecode = function() {
bindcodecodeclick(this.selector);

return this.addClass('acodecode');
};

if (typeof SyntaxHighlighter !== 'undefined')
SyntaxHighlighter.all = (function() {
var callsyntaxhighlighter = SyntaxHighlighter.all
, syntaxactivated = false
, checkforsyntaxels
, tried = 0;

var hassyntaxbeenhighlighted = function() {
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);
1 change: 1 addition & 0 deletions dist/codecode.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions codecode.min.js → dist/codecode.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codecode",
"version": "0.0.2",
"version": "0.0.3",
"author": "Stephen Sawchuk",
"dependencies": {
"grunt": "~0.4.1",
Expand Down
File renamed without changes.

0 comments on commit 0c4188c

Please sign in to comment.