Skip to content

Commit

Permalink
Synchronizes front-end style defaults with styles.ini configuration f…
Browse files Browse the repository at this point in the history
…ile.
  • Loading branch information
davidmcclure committed Sep 12, 2013
1 parent 0546698 commit 6730fdd
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 38 deletions.
7 changes: 6 additions & 1 deletion helpers/Globals.php
Expand Up @@ -18,6 +18,10 @@
*/
function nl_globals($exhibit)
{

// Read style defaults from `styles.ini`.
$styles = new Zend_Config_Ini(NL_DIR.'/styles.ini');

return array('neatline' => array(

// Exhibit.
Expand All @@ -32,7 +36,8 @@ function nl_globals($exhibit)

// Constants.
// ----------------------------------------------------------------
'per_page' => (int) get_plugin_ini('Neatline', 'per_page'),
'per_page' => (int) get_plugin_ini('Neatline', 'per_page'),
'styles' => $styles->toArray(),

// Layers.
// ----------------------------------------------------------------
Expand Down
52 changes: 41 additions & 11 deletions models/NeatlineRecord.php
Expand Up @@ -27,17 +27,17 @@ class NeatlineRecord extends Neatline_Row_Expandable
public $coverage;
public $tags;
public $widgets;
public $presenter = 'StaticBubble';
public $fill_color = '#00aeff';
public $fill_color_select = '#00aeff';
public $stroke_color = '#000000';
public $stroke_color_select = '#000000';
public $fill_opacity = 0.3;
public $fill_opacity_select = 0.4;
public $stroke_opacity = 0.9;
public $stroke_opacity_select = 1.0;
public $stroke_width = 2;
public $point_radius = 10;
public $presenter;
public $fill_color;
public $fill_color_select;
public $stroke_color;
public $stroke_color_select;
public $fill_opacity;
public $fill_opacity_select;
public $stroke_opacity;
public $stroke_opacity_select;
public $stroke_width;
public $point_radius;
public $zindex;
public $weight;
public $start_date;
Expand All @@ -53,6 +53,24 @@ class NeatlineRecord extends Neatline_Row_Expandable
public $map_focus;


/**
* Required style attributes set in `styles.ini`.
*/
protected static $preset = array(
'presenter',
'fill_color',
'fill_color_select',
'stroke_color',
'stroke_color_select',
'fill_opacity',
'fill_opacity_select',
'stroke_opacity',
'stroke_opacity_select',
'stroke_width',
'point_radius'
);


/**
* Set exhibit and item references.
*
Expand All @@ -61,9 +79,21 @@ class NeatlineRecord extends Neatline_Row_Expandable
*/
public function __construct($exhibit=null, $item=null)
{

parent::__construct();

// Set exhibit and item foreign keys.
if (!is_null($exhibit)) $this->exhibit_id = $exhibit->id;
if (!is_null($item)) $this->item_id = $item->id;

// Read style defaults from `styles.ini`.
$styles = new Zend_Config_Ini(NL_DIR.'/styles.ini');

// Set default styles.
foreach (self::$preset as $prop) {
if (is_null($this->$prop)) $this->$prop = $styles->$prop;
}

}


Expand Down
11 changes: 11 additions & 0 deletions styles.ini
@@ -0,0 +1,11 @@
presenter="StaticBubble"
fill_color="#00aeff"
fill_color_select="#00aeff"
stroke_color="#000000"
stroke_color_select="#000000"
fill_opacity="0.3"
fill_opacity_select="0.4"
stroke_opacity="0.9"
stroke_opacity_select="1.0"
stroke_width="2"
point_radius="10"
Expand Up @@ -63,7 +63,7 @@ Neatline.module('Editor.Exhibit.Records', function(
*/
getModelByEvent: function(e) {
return this.records.get(
parseInt($(e.currentTarget).attr('data-id'), 10)
Number($(e.currentTarget).attr('data-id'))
);
},

Expand Down
4 changes: 2 additions & 2 deletions views/shared/javascripts/app/editor/map/map.view.js
Expand Up @@ -205,11 +205,11 @@ _.extend(Neatline.Map.View.prototype, {
// --------------------------------------------------------------------

// SNAP ANGLE
var snap = parseFloat(settings.poly.snap) || 0;
var snap = Number(settings.poly.snap) || 0;
this.controls.regPoly.handler.snapAngle = Math.max(0, snap);

// SIDES
var sides = parseInt(settings.poly.sides, 10) || 0;
var sides = Number(settings.poly.sides) || 0;
this.controls.regPoly.handler.sides = Math.max(3, sides);

// IRREGULAR
Expand Down
4 changes: 1 addition & 3 deletions views/shared/javascripts/app/editor/record/record.public.js
Expand Up @@ -31,10 +31,8 @@ Neatline.module('Editor.Record', function(
*/
var bindId = function(id, tab) {

id = parseInt(id, 10);

// Get or fetch the model.
Neatline.request('EDITOR:EXHIBIT:RECORDS:getModel', id,
Neatline.request('EDITOR:EXHIBIT:RECORDS:getModel', Number(id),
function(record) {
Record.__view.bind(record);
Record.__view.activateTab(tab);
Expand Down
8 changes: 4 additions & 4 deletions views/shared/javascripts/app/map/map.view.js
Expand Up @@ -432,7 +432,7 @@ Neatline.module('Map', function(
_.each(this.layers.vector, _.bind(function(layer, id) {

// Delete if model is absent and layer is unfrozen.
if (!_.contains(newIds, parseInt(id, 10)) && !layer.nFrozen) {
if (!_.contains(newIds, Number(id)) && !layer.nFrozen) {
this.removeVectorLayer(layer);
}

Expand Down Expand Up @@ -468,7 +468,7 @@ Neatline.module('Map', function(
_.each(this.layers.wms, _.bind(function(layer, id) {

// Delete if model is absent.
if (!_.contains(newIds, parseInt(id, 10))) {
if (!_.contains(newIds, Number(id))) {
this.removeWmsLayer(layer);
}

Expand Down Expand Up @@ -674,8 +674,8 @@ Neatline.module('Map', function(
fillOpacitySelect = parseFloat(fillOpacitySelect);
strokeOpacity = parseFloat(strokeOpacity);
strokeOpacitySelect = parseFloat(strokeOpacitySelect);
strokeWidth = parseInt(strokeWidth);
pointRadius = parseInt(pointRadius);
strokeWidth = Number(strokeWidth);
pointRadius = Number(pointRadius);

return new OpenLayers.StyleMap({

Expand Down
Expand Up @@ -52,8 +52,8 @@ Neatline.module('Shared.Record', function(
* @return {Array}: The records collection.
*/
parse: function(response) {
this.offset = parseInt(response.offset, 10);
this.count = parseInt(response.count, 10);
this.offset = Number(response.offset);
this.count = Number(response.count);
return response.records;
}

Expand Down
27 changes: 16 additions & 11 deletions views/shared/javascripts/app/shared/record/record.model.js
Expand Up @@ -28,20 +28,25 @@ Neatline.module('Shared.Record', function(


defaults: function() {

// Alias the style defaults.
var styles = Neatline.g.neatline.styles;

return {
exhibit_id: Neatline.g.neatline.exhibit.id,
presenter: 'StaticBubble',
fill_color: '#00aeff',
fill_color_select: '#00aeff',
stroke_color: '#000000',
stroke_color_select: '#000000',
fill_opacity: 0.3,
fill_opacity_select: 0.4,
stroke_opacity: 0.9,
stroke_opacity_select: 1.0,
point_radius: 10,
stroke_width: 2
presenter: styles.presenter,
fill_color: styles.fill_color,
fill_color_select: styles.fill_color_select,
stroke_color: styles.stroke_color,
stroke_color_select: styles.stroke_color_select,
fill_opacity: Number(styles.fill_opacity),
fill_opacity_select: Number(styles.fill_opacity_select),
stroke_opacity: Number(styles.stroke_opacity),
stroke_opacity_select: Number(styles.stroke_opacity_select),
point_radius: Number(styles.point_radius),
stroke_width: Number(styles.stroke_width)
};

}


Expand Down
4 changes: 2 additions & 2 deletions views/shared/javascripts/payloads/neatline-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/shared/javascripts/payloads/neatline-public.js

Large diffs are not rendered by default.

0 comments on commit 6730fdd

Please sign in to comment.