diff --git a/assets/autopilot.css b/assets/autopilot.css index dab0fd7..0f14489 100644 --- a/assets/autopilot.css +++ b/assets/autopilot.css @@ -55,7 +55,7 @@ ul.autopilot { max-height:none; } -ul.autopilot li { +ul.autopilot > li { position:relative; background:#eee; padding:10px 30px 0px; @@ -134,15 +134,13 @@ ul.autopilot li .aspects { padding:10px; } position:relative; background:#fff; padding:0px 224px 0px 0px; - height:0px; + display:none; + border-top:1px solid #ccc; margin:0px -30px 0px; - box-shadow:inset #ddd 0px 1px; - transition:height 100ms; - -moz-transition:height 100ms; - -webkit-transition:height 100ms; + min-height:200px; } -.aspect.active { height:220px; } +.aspect.active { display:block } .aspects a.active:after { content:''; @@ -158,22 +156,29 @@ ul.autopilot li .aspects { padding:10px; } } .aspect ul.form li.active { display:block; } -.aspect ul.form li { padding:5px 20px 4px 100px; } -.aspect ul.form li.text { padding:10px 20px 9px; } -.aspect ul.form li label { width:70px; margin-left:-80px; text-align:left; } +.aspect ul.form li { max-width:none; padding:5px 10px 4px 100px; } +.aspect ul.form li.text { padding:10px 10px 9px; } +.aspect ul.form li label { width:80px; margin-left:-90px; text-align:left; } +.aspect ul.form li:last-child { border:0px; } -.aspect .text .joined { - position:absolute; - top:10px; - right:10px; +#page .aspect ul.form li.filter { + padding-right:40px; + background-color:#ddd; + border-color:#ccc; } +.aspect ul.form li.filter .ui-slider:before { background-color:#eee; } +.aspect ul.form li.filter label { font-size:11px; text-transform:uppercase; } +.aspect ul.form li.filter a.close { position:absolute; right:10px; top:5px; } + +.aspect .text .filters { position:absolute; top:10px; right:10px; } +.aspect .text .filters select { width:80px; } +.aspect .text .filters > * { vertical-align:middle; } .aspect .colorpicker { position:absolute; background:#fff; z-index:1; border-left:1px solid #ddd; - box-shadow:inset #ddd 0px 1px; padding:10px; } @@ -187,7 +192,7 @@ ul.autopilot li .aspects { padding:10px; } .aspect .ui-slider-handle { width:40px; color:#fff; - font-size:9px; + font-size:10px; line-height:16px; text-shadow:rgba(0,0,0,0.5) 0px 1px; text-align:center; @@ -197,19 +202,23 @@ ul.autopilot li .aspects { padding:10px; } .aspect option.null { color:#999; } -.aspect .shades { - height:20px; - margin:0px 0px 5px; - overflow:hidden; - position:relative; - } +.aspect .shade-links { margin-top:5px; } .aspect .swatch { - width:24px; - margin-right:1px; + float:none; + display:inline-block; + vertical-align:middle; + width:20px; + height:16px; background:#888 url(/assets/tilemill-autopilot/autopilot.png) -40px -40px; } +.aspect .swatch.active { + box-shadow: + #fff 0px 0px 0px 1px, + #888 0px 0px 0px 3px; +} + .aspect .swatch, .aspect .swatch .fill { border-radius:3px; @@ -217,4 +226,3 @@ ul.autopilot li .aspects { padding:10px; } } .aspect .swatch.active { display:block; } - diff --git a/models/Chart.bones b/models/Chart.bones index fe43c66..e570497 100644 --- a/models/Chart.bones +++ b/models/Chart.bones @@ -1,11 +1,48 @@ model = Backbone.Model.extend(); +model.prototype.deepGet = function(key) { + var deepGet = function(attr, keys) { + var key = keys.shift(); + if (keys.length) { + return deepGet(attr[key] || {}, keys); + } else { + return attr[key]; + } + } + return deepGet(this.attributes, key.split('.')); +}; + +model.prototype.deepSet = function(key, val, options) { + var deepSet = function(attr, keys, val) { + var key = keys.shift(); + if (keys.length) { + if (keys.length === 1 && !isNaN(parseInt(keys[0]))) { + attr[key] = attr[key] || []; + } else { + attr[key] = attr[key] || {}; + } + attr[key] = deepSet(attr[key], keys, val); + } else { + attr[key] = val; + } + return attr; + } + var root = key.split('.').shift(); + var attr = {}; + attr[root] = this.attributes[root]; + console.warn(attr[root]); + return this.set(deepSet(attr, key.split('.'), val), options) + .trigger('change') + .trigger('change:' + root); +}; + model.prototype.compile = function(layer) { function zoomRules(rules, scale, zoom, key, val) { if (scale <= 1) { rules[key] = val; return; } + zoom = zoom || [0,22]; for (var z = zoom[0], i = 0; z <= zoom[1]; z++, i++) { rules['[zoom='+z+']'] = rules['[zoom='+z+']'] || {}; rules['[zoom='+z+']'][key] = val + '*' + Math.pow(scale,i).toFixed(2); @@ -34,12 +71,12 @@ model.prototype.compile = function(layer) { if (key === 'id') return memo; if (key.indexOf('_') === 0) return memo; var prefix = key.split('-')[0]; - var zoom = this.get('_'+prefix+'-zoom') || [0,22]; + var filters = this.get('_'+prefix+'-filters') || {}; var scale = this.get('_'+prefix+'-scale') || 1; - var group = _('::<%=p%>[zoom>=<%=z[0]%>][zoom<=<%=z[1]%>]').template({ - z:zoom, - p:prefix - }); + var group = '::' + prefix + _(filters).map(function(val, key) { + return _('[<%=k%>>=<%=v[0]%>][<%=k%><=<%=v[1]%>]') + .template({ k:key, v:val }); + }).join(''); switch (prefix) { case 'background': memo[key] = val; @@ -61,7 +98,7 @@ model.prototype.compile = function(layer) { memo[group] = memo[group] || {}; switch (key) { case 'line-width': - zoomRules(memo[group], scale, zoom, key, val); + zoomRules(memo[group], scale, filters.zoom, key, val); break; default: memo[group][key] = val; @@ -76,7 +113,7 @@ model.prototype.compile = function(layer) { switch (key) { case 'text-size': case 'text-character-spacing': - zoomRules(memo[group], scale, zoom, key, val); + zoomRules(memo[group], scale, filters.zoom, key, val); break; default: memo[group][key] = val; @@ -90,7 +127,7 @@ model.prototype.compile = function(layer) { switch(key) { case 'marker-width': case 'marker-line-width': - zoomRules(memo[group], scale, zoom, key, val); + zoomRules(memo[group], scale, filters.zoom, key, val); break; default: memo[group][key] = val; diff --git a/templates/AspectFilters._ b/templates/AspectFilters._ new file mode 100644 index 0000000..acd74e3 --- /dev/null +++ b/templates/AspectFilters._ @@ -0,0 +1,25 @@ +
  • +

    <%=type[0].toUpperCase() + type.substr(1)%>

    + + + + +
  • +<% _(model.get('_'+type+'-filters')||{}).each(function(filter, key) { %> +<% var info = datasource.get('fields')[key]; %> +<% if (info) { %> +
  • + +
    + +
  • +<% } %> +<% }); %> diff --git a/templates/Aspectline._ b/templates/Aspectline._ index 326bd68..f273631 100644 --- a/templates/Aspectline._ +++ b/templates/Aspectline._ @@ -1,12 +1,6 @@