mirror of
https://github.com/sstent/node.git
synced 2026-01-27 15:41:43 +00:00
73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
// Generated by CoffeeScript 1.3.1
|
|
var app, cssProperty, get, ready, render, view, _ref;
|
|
|
|
_ref = app = require('./index'), get = _ref.get, ready = _ref.ready, view = _ref.view;
|
|
|
|
render = require('./shared').render;
|
|
|
|
view.fn('cssProperty', cssProperty = function(style) {
|
|
if (style.active) {
|
|
return "" + (style.prop || '') + ": " + (style.value || '') + ";";
|
|
} else {
|
|
return '';
|
|
}
|
|
});
|
|
|
|
get('/live-css', function(page, model) {
|
|
return model.subscribe('liveCss', function(err, liveCss) {
|
|
liveCss.setNull({
|
|
styles: [
|
|
{
|
|
prop: 'color',
|
|
value: '#c00',
|
|
active: true
|
|
}, {
|
|
prop: 'font-weight',
|
|
value: 'bold',
|
|
active: true
|
|
}, {
|
|
prop: 'font-size',
|
|
value: '18px',
|
|
active: false
|
|
}
|
|
],
|
|
outputText: 'Edit this text...'
|
|
});
|
|
model.fn('_hasActiveStyles', 'liveCss.styles', function(styles) {
|
|
var style, _i, _len;
|
|
for (_i = 0, _len = styles.length; _i < _len; _i++) {
|
|
style = styles[_i];
|
|
if (style.active) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
});
|
|
model.del('_poppedOut');
|
|
return render(page, 'liveCss');
|
|
});
|
|
});
|
|
|
|
get({
|
|
from: '/live-css',
|
|
to: '/live-css/popout'
|
|
}, {
|
|
forward: function(model) {
|
|
return model.set('_poppedOut', true);
|
|
},
|
|
back: function(model) {
|
|
return model.del('_poppedOut');
|
|
}
|
|
});
|
|
|
|
ready(function(model) {
|
|
return app.liveCss = {
|
|
addStyle: function() {
|
|
return model.push('liveCss.styles', {});
|
|
},
|
|
deleteStyle: function(e, el) {
|
|
return model.at(el).remove();
|
|
}
|
|
};
|
|
});
|