Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/clippy.swf
Binary file not shown.
16 changes: 9 additions & 7 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ input { font-size: 14px; border: 1px solid #777; box-sha
/* =MODULES
====================================================== */
/* preview */
.arrow_box { padding: 40px; width: 280px; height: 100px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.arrow_box { padding: 40px; width: 280px; height: 100px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }

/* logo */
.logo { color: #ddf8c6; text-align: center; font-size: 54px; line-height: 54px; font-weight: bold; text-transform: uppercase; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.logo { color: #ddf8c6; text-align: center; font-size: 54px; line-height: 54px; font-weight: bold; text-transform: uppercase; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }

/* configuration */
.configuration { margin-top: 20px; }
Expand All @@ -43,11 +43,13 @@ input { font-size: 14px; border: 1px solid #777; box-sha
.configuration .section label { display: inline-block; width: 112px; }

.configuration .size,
.configuration .border_width { width: 28px; text-align: right; }
.configuration .border_width { width: 28px; text-align: right; }

.configuration .color { width: 65px; text-align: center }
.configuration .color { width: 65px; text-align: center }

.configuration .unit { font-size: 14px; color: rgba(0, 0, 0, 0.4); text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5); margin-left: 5px; }
.configuration .unit { font-size: 14px; color: rgba(0, 0, 0, 0.4); text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5); margin-left: 5px; }

/* result_code */
.result_code { position: relative; white-space: pre; padding: 10px; float: right; width: 380px; font-size: 12px; font-family: 'Courier new'; font-weight: bold; background: rgba(0, 0, 0, 0.15); border-radius: 4px; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.2); box-shadow: 0 1px 1px 0 rgba(255, 255, 255, 0.3), inset 0 1px 5px rgba(0, 0, 0, 0.1); }
/* css_result */
.css_result { position: relative; float: right; width: 402px; }
.css_result .code { white-space: pre; padding: 10px; display: block; width: 380px; font-size: 12px; font-family: 'Courier new'; font-weight: bold; background: rgba(0, 0, 0, 0.15); border-radius: 4px; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.2); box-shadow: 0 1px 1px 0 rgba(255, 255, 255, 0.3), inset 0 1px 5px rgba(0, 0, 0, 0.1); }
.css_result .copy_code { position: absolute; bottom: 5px; right: 10px; width: 14px; height: 22px; background: url(../img/clippy.png) no-repeat 0 4px; }
Binary file added public/img/clippy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ <h2>Arrow configuration</h2>
</div>
</form>
</div>
<code class='result_code' readonly='readonly'></code>

<div class='css_result'>
<code class='code' readonly='readonly'></code>
<div class='copy_code'></div>
</div>

</div>

Expand All @@ -67,7 +71,8 @@ <h2>Arrow configuration</h2>
</footer>

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script type="text/javascript" src="js/vendor/jscolor/jscolor.js"></script>
<script src="js/vendor/jquery.clippy/jquery.clippy.min.js"></script>
<script src="js/vendor/jscolor/jscolor.js"></script>
<link rel="stylesheet" type="text/css" href="js/vendor/jscolor/jscolor.css">

<script src='js/lib/models/arrow.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion public/js/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};
this.views = [
new G.ArrowConfigurationView({ model: model, container: $('.configuration') }),
new G.ArrowPreviewView({ model: model, container: $('<style type="text/css"></style>').appendTo('body') }),
new G.ArrowCSSView({ model: model, container: $('.result_code') }),
new G.ArrowCSSView({ model: model, container: $('.css_result') }),
];
},

Expand Down
11 changes: 9 additions & 2 deletions public/js/lib/views/arrow_css_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};

init: function (options) {
this.container = options.container;
this.model = options.model;
this._codeNode = this.container.find('.code');
this._copyNode = this.container.find('.copy_code');

this.model = options.model;
this.model.on('change', this._handleChange, this);
},

Expand All @@ -35,7 +37,12 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};
@chainable
**/
render: function () {
this.container.text( this.model.toCSS() );
var css = this.model.toCSS();

this._codeNode.text( css );
this._copyNode.text( css )
.clippy({ transparent: true });

return this;
}

Expand Down
4 changes: 2 additions & 2 deletions public/js/lib/views/arrow_preview_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};

/**
@method render
@description borrows the render function from ArrowCSSView
@description renders the css to style the preview
@chainable
**/
render: function () {
G.ArrowCSSView.prototype.render.call(this);
this.container.text( this.model.toCSS() );
return this;
}

Expand Down
20 changes: 17 additions & 3 deletions public/js/spec/views/arrow_css_view_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,38 @@ describe("CSSArrowPlease.ArrowCSSView", function () {
var arrow, arrowCSSView, $container;

beforeEach(function () {
$container = $('<div/>');
$container = $('<div><div class="code"></div><div class="copy_code"></div></div>');
$code = $container.find('.code');
$copy = $container.find('.copy_code');

arrow = new CSSArrowPlease.Arrow();

arrowCSSView = new CSSArrowPlease.ArrowCSSView({
model: arrow,
container: $container
});

spyOn( $copy, 'clippy' );

arrowCSSView._codeNode = $code;
arrowCSSView._copyNode = $copy;
});

describe('render', function () {

it('returns itself for chainability', function () {
expect( arrowCSSView.render() ).toBe( arrowCSSView );
});

it('renders the css when render is called', function () {
expect( $container.text() ).toBe( '' );
expect( $code.text() ).toBe( '' );
arrowCSSView.render();
expect( $code.text() ).toBe( arrow.toCSS() );
});

it('calls clippy() on the copy_code node', function () {
arrowCSSView.render();
expect( $container.text() ).toBe( arrow.toCSS() );
expect( $copy.clippy ).toHaveBeenCalled();
});
});

Expand Down
5 changes: 1 addition & 4 deletions public/js/spec/views/arrow_preview_view_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ describe("CSSArrowPlease.ArrowPreviewView", function() {
});

it('render delegates to ArrowCSSView.render', function () {
spyOn(CSSArrowPlease.ArrowCSSView.prototype, 'render');

arrowPreviewView.render();

expect(CSSArrowPlease.ArrowCSSView.prototype.render).toHaveBeenCalled();
expect( $container.text() ).toBe( arrow.toCSS() );
});
});

Expand Down
1 change: 1 addition & 0 deletions public/js/spec_runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script type="text/javascript" src="vendor/jasmine/jasmine.js"></script>
<script type="text/javascript" src="vendor/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="vendor/jquery.clippy/jquery.clippy.min.js"></script>

<!-- include spec files here... -->
<script type="text/javascript" src="spec/models/arrow_spec.js"></script>
Expand Down
1 change: 1 addition & 0 deletions public/js/vendor/jquery.clippy/jquery.clippy.min.js

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