diff --git a/code/haitiwater/static-common/javascripts/theme.admin.extension.js b/code/haitiwater/static-common/javascripts/theme.admin.extension.js
new file mode 100644
index 0000000..031ebb4
--- /dev/null
+++ b/code/haitiwater/static-common/javascripts/theme.admin.extension.js
@@ -0,0 +1,1632 @@
+
+window.admin = {};
+
+// Panels
+(function( $ ) {
+
+ $(function() {
+ $('.panel')
+ .on( 'click', '.panel-actions a.fa-caret-up', function( e ) {
+ e.preventDefault();
+
+ var $this,
+ $panel;
+
+ $this = $( this );
+ $panel = $this.closest( '.panel' );
+
+ $this
+ .removeClass( 'fa-caret-up' )
+ .addClass( 'fa-caret-down' );
+
+ $panel.find('.panel-body, .panel-footer').slideDown( 200 );
+ })
+ .on( 'click', '.panel-actions a.fa-caret-down', function( e ) {
+ e.preventDefault();
+
+ var $this,
+ $panel;
+
+ $this = $( this );
+ $panel = $this.closest( '.panel' );
+
+ $this
+ .removeClass( 'fa-caret-down' )
+ .addClass( 'fa-caret-up' );
+
+ $panel.find('.panel-body, .panel-footer').slideUp( 200 );
+ })
+ .on( 'click', '.panel-actions a.fa-times', function( e ) {
+ e.preventDefault();
+
+ var $panel,
+ $row;
+
+ $panel = $(this).closest('.panel');
+
+ if ( !!( $panel.parent('div').attr('class') || '' ).match( /col-(xs|sm|md|lg)/g ) && $panel.siblings().length === 0 ) {
+ $row = $panel.closest('.row');
+ $panel.parent('div').remove();
+ if ( $row.children().length === 0 ) {
+ $row.remove();
+ }
+ } else {
+ $panel.remove();
+ }
+ });
+ });
+
+})( jQuery );
+
+// Chart Circular
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'easyPieChart' ]) ) {
+
+ $(function() {
+ $('[data-plugin-chart-circular], .circular-bar-chart:not(.manual)').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginChartCircular(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Chart Circular
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__chartCircular';
+
+ var PluginChartCircular = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginChartCircular.defaults = {
+ accX: 0,
+ accY: -150,
+ delay: 1,
+ barColor: '#0088CC',
+ trackColor: '#f2f2f2',
+ scaleColor: false,
+ scaleLength: 5,
+ lineCap: 'round',
+ lineWidth: 13,
+ size: 175,
+ rotate: 0,
+ animate: ({
+ duration: 2500,
+ enabled: true
+ })
+ };
+
+ PluginChartCircular.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend(true, {}, PluginChartCircular.defaults, opts, {
+ wrapper: this.$el
+ });
+
+ return this;
+ },
+
+ build: function() {
+ var self = this,
+ $el = this.options.wrapper,
+ value = ($el.attr('data-percent') ? $el.attr('data-percent') : 0),
+ percentEl = $el.find('.percent'),
+ shouldAnimate,
+ data;
+
+ shouldAnimate = $.isFunction($.fn[ 'appear' ]) && ( typeof $.browser !== 'undefined' && !$.browser.mobile );
+ data = { accX: self.options.accX, accY: self.options.accY };
+
+ $.extend(true, self.options, {
+ onStep: function(from, to, currentValue) {
+ percentEl.html(parseInt(currentValue));
+ }
+ });
+
+ $el.attr('data-percent', (shouldAnimate ? 0 : value) );
+
+ $el.easyPieChart( this.options );
+
+ if ( shouldAnimate ) {
+ $el.appear(function() {
+ setTimeout(function() {
+ $el.data('easyPieChart').update(value);
+ $el.attr('data-percent', value);
+
+ }, self.options.delay);
+ }, data);
+ } else {
+ $el.data('easyPieChart').update(value);
+ $el.attr('data-percent', value);
+ }
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(true, admin, {
+ Chart: {
+ PluginChartCircular: PluginChartCircular
+ }
+ });
+
+ // jquery plugin
+ $.fn.adminPluginChartCircular = function(opts) {
+ return this.map(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginChartCircular($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// Slider
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'slider' ]) ) {
+
+ $(function() {
+ $('[data-plugin-slider]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions) {
+ opts = pluginOptions;
+ }
+
+ $this.adminPluginSlider(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Slider
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__slider';
+
+ var PluginSlider = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSlider.defaults = {
+
+ };
+
+ PluginSlider.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setVars()
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setVars: function() {
+ var $output = $( this.$el.data('plugin-slider-output') );
+ this.$output = $output.get(0) ? $output : null;
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ var _self = this;
+ this.options = $.extend( true, {}, PluginSlider.defaults, opts );
+
+ if ( this.$output ) {
+ $.extend( this.options, {
+ slide: function( event, ui ) {
+ _self.onSlide( event, ui );
+ }
+ });
+ }
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.slider( this.options );
+
+ return this;
+ },
+
+ onSlide: function( event, ui ) {
+ if ( !ui.values ) {
+ this.$output.val( ui.value );
+ } else {
+ this.$output.val( ui.values[ 0 ] + '/' + ui.values[ 1 ] );
+ }
+
+ this.$output.trigger('change');
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginSlider: PluginSlider
+ });
+
+ // jquery plugin
+ $.fn.adminPluginSlider = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSlider($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// Data Tables - Config
+(function($) {
+
+ 'use strict';
+
+ // we overwrite initialize of all datatables here
+ // because we want to use select2, give search input a bootstrap look
+ // keep in mind if you overwrite this fnInitComplete somewhere,
+ // you should run the code inside this function to keep functionality.
+ //
+ // there's no better way to do this at this time :(
+ if ( $.isFunction( $.fn[ 'dataTable' ] ) ) {
+
+ $.extend(true, $.fn.dataTable.defaults, {
+ sDom: "<'row datatables-header form-inline'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>r><'table-responsive't><'row datatables-footer'<'col-sm-12 col-md-6'i><'col-sm-12 col-md-6'p>>",
+ oLanguage: {
+ sLengthMenu: '_MENU_ records per page',
+ sProcessing: ' Loading'
+ },
+ fnInitComplete: function( settings, json ) {
+ // select 2
+ if ( $.isFunction( $.fn[ 'select2' ] ) ) {
+ $('.dataTables_length select', settings.nTableWrapper).select2({
+ minimumResultsForSearch: -1
+ });
+ }
+
+ var options = $( 'table', settings.nTableWrapper ).data( 'plugin-options' ) || {};
+
+ // search
+ var $search = $('.dataTables_filter input', settings.nTableWrapper);
+
+ $search
+ .attr({
+ placeholder: typeof options.searchPlaceholder !== 'undefined' ? options.searchPlaceholder : 'Search'
+ })
+ .addClass('form-control');
+
+ if ( $.isFunction( $.fn.placeholder ) ) {
+ $search.placeholder();
+ }
+ }
+ });
+
+ }
+
+}).apply( this, [ jQuery ]);
+
+// Codemirror
+(function( $ ) {
+
+ 'use strict';
+
+ if ( typeof CodeMirror !== 'undefined' ) {
+
+ $(function() {
+ $('[data-plugin-codemirror]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginCodeMirror(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Codemirror
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__codemirror';
+
+ var PluginCodeMirror = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginCodeMirror.defaults = {
+ lineNumbers: true,
+ styleActiveLine: true,
+ matchBrackets: true,
+ theme: 'monokai'
+ };
+
+ PluginCodeMirror.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginCodeMirror.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ CodeMirror.fromTextArea( this.$el.get(0), this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginCodeMirror: PluginCodeMirror
+ });
+
+ // jquery plugin
+ $.fn.adminPluginCodeMirror = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginCodeMirror($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// Colorpicker
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'colorpicker' ]) ) {
+
+ $(function() {
+ $('[data-plugin-colorpicker]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginColorPicker(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Colorpicker
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__colorpicker';
+
+ var PluginColorPicker = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginColorPicker.defaults = {
+ };
+
+ PluginColorPicker.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginColorPicker.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.colorpicker( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginColorPicker: PluginColorPicker
+ });
+
+ // jquery plugin
+ $.fn.adminPluginColorPicker = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginColorPicker($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// Datepicker
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'datepicker' ]) ) {
+
+ $(function() {
+ $('[data-plugin-datepicker]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginDatePicker(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Datepicker
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__datepicker';
+
+ var PluginDatePicker = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginDatePicker.defaults = {
+ };
+
+ PluginDatePicker.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setVars()
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setVars: function() {
+ this.skin = this.$el.data( 'plugin-skin' );
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginDatePicker.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.datepicker( this.options );
+
+ if ( !!this.skin ) {
+ this.$el.data('datepicker').picker.addClass( 'datepicker-' + this.skin );
+ }
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginDatePicker: PluginDatePicker
+ });
+
+ // jquery plugin
+ $.fn.adminPluginDatePicker = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginDatePicker($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// iosSwitcher
+(function( $ ) {
+
+ 'use strict';
+
+ if ( typeof Switch !== 'undefined' && $.isFunction( Switch ) ) {
+
+ $(function() {
+ $('[data-plugin-ios-switch]').each(function() {
+ var $this = $( this );
+
+ $this.adminPluginIOS7Switch();
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// iosSwitcher
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__IOS7Switch';
+
+ var PluginIOS7Switch = function($el) {
+ return this.initialize($el);
+ };
+
+ PluginIOS7Switch.prototype = {
+ initialize: function($el) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ build: function() {
+ var switcher = new Switch( this.$el.get(0) );
+
+ $( switcher.el ).on( 'click', function( e ) {
+ e.preventDefault();
+ switcher.toggle();
+ });
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginIOS7Switch: PluginIOS7Switch
+ });
+
+ // jquery plugin
+ $.fn.adminPluginIOS7Switch = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginIOS7Switch($this);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// Markdown
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'markdown' ]) ) {
+
+ $(function() {
+ $('[data-plugin-markdown-editor]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginMarkdownEditor(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Markdown
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__markdownEditor';
+
+ var PluginMarkdownEditor = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMarkdownEditor.defaults = {
+ iconlibrary: 'fa'
+ };
+
+ PluginMarkdownEditor.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMarkdownEditor.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.markdown( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginMarkdownEditor: PluginMarkdownEditor
+ });
+
+ // jquery plugin
+ $.fn.adminPluginMarkdownEditor = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMarkdownEditor($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// Masked Input
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'mask' ]) ) {
+
+ $(function() {
+ $('[data-plugin-masked-input]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginMaskedInput(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Masked Input
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__maskedInput';
+
+ var PluginMaskedInput = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMaskedInput.defaults = {
+ };
+
+ PluginMaskedInput.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMaskedInput.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.mask( this.$el.data('input-mask'), this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginMaskedInput: PluginMaskedInput
+ });
+
+ // jquery plugin
+ $.fn.adminPluginMaskedInput = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMaskedInput($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// MaxLength
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn[ 'maxlength' ]) ) {
+
+ $(function() {
+ $('[data-plugin-maxlength]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginMaxLength(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// MaxLength
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__maxlength';
+
+ var PluginMaxLength = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMaxLength.defaults = {
+ alwaysShow: true,
+ placement: 'bottom-left',
+ warningClass: 'label label-success bottom-left',
+ limitReachedClass: 'label label-danger bottom-left'
+ };
+
+ PluginMaxLength.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMaxLength.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.maxlength( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginMaxLength: PluginMaxLength
+ });
+
+ // jquery plugin
+ $.fn.adminPluginMaxLength = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMaxLength($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// MultiSelect
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn[ 'multiselect' ] ) ) {
+
+ $(function() {
+ $( '[data-plugin-multiselect]' ).each(function() {
+
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginMultiSelect(opts);
+
+ });
+ });
+
+ }
+
+}).apply( this, [ jQuery ]);
+
+// MultiSelect
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__multiselect';
+
+ var PluginMultiSelect = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMultiSelect.defaults = {
+ templates: {
+ filter: '
'
+ }
+ };
+
+ PluginMultiSelect.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMultiSelect.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.multiselect( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginMultiSelect: PluginMultiSelect
+ });
+
+ // jquery plugin
+ $.fn.adminPluginMultiSelect = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMultiSelect($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn[ 'placeholder' ]) ) {
+
+ $('input[placeholder]').placeholder();
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+
+// Select2
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'select2' ]) ) {
+
+ $(function() {
+ $('[data-plugin-selectTwo]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginSelect2(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Select2
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__select2';
+
+ var PluginSelect2 = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSelect2.defaults = {
+ };
+
+ PluginSelect2.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginSelect2.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.select2( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginSelect2: PluginSelect2
+ });
+
+ // jquery plugin
+ $.fn.adminPluginSelect2 = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSelect2($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// Spinner
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'spinner' ]) ) {
+
+ $(function() {
+ $('[data-plugin-spinner]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginSpinner(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Spinner
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__spinner';
+
+ var PluginSpinner = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSpinner.defaults = {
+ };
+
+ PluginSpinner.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginSpinner.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.spinner( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginSpinner: PluginSpinner
+ });
+
+ // jquery plugin
+ $.fn.adminPluginSpinner = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSpinner($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// SummerNote
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'summernote' ]) ) {
+
+ $(function() {
+ $('[data-plugin-summernote]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginSummerNote(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// SummerNote
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__summernote';
+
+ var PluginSummerNote = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSummerNote.defaults = {
+ onfocus: function() {
+ $( this ).closest( '.note-editor' ).addClass( 'active' );
+ },
+ onblur: function() {
+ $( this ).closest( '.note-editor' ).removeClass( 'active' );
+ }
+ };
+
+ PluginSummerNote.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginSummerNote.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.summernote( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginSummerNote: PluginSummerNote
+ });
+
+ // jquery plugin
+ $.fn.adminPluginSummerNote = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSummerNote($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// TextArea AutoSize
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'autosize' ]) ) {
+
+ $(function() {
+ $('[data-plugin-textarea-autosize]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginTextAreaAutoSize(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// TextArea AutoSize
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var initialized = false;
+ var instanceName = '__textareaAutosize';
+
+ var PluginTextAreaAutoSize = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginTextAreaAutoSize.defaults = {
+ };
+
+ PluginTextAreaAutoSize.prototype = {
+ initialize: function($el, opts) {
+ if (initialized) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginTextAreaAutoSize.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.autosize( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginTextAreaAutoSize: PluginTextAreaAutoSize
+ });
+
+ // jquery plugin
+ $.fn.adminPluginTextAreaAutoSize = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginTextAreaAutoSize($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
+
+// TimePicker
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'timepicker' ]) ) {
+
+ $(function() {
+ $('[data-plugin-timepicker]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.adminPluginTimePicker(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// TimePicker
+(function(admin, $) {
+
+ admin = admin || {};
+
+ var instanceName = '__timepicker';
+
+ var PluginTimePicker = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginTimePicker.defaults = {
+ disableMousewheel: true
+ };
+
+ PluginTimePicker.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginTimePicker.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.timepicker( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(admin, {
+ PluginTimePicker: PluginTimePicker
+ });
+
+ // jquery plugin
+ $.fn.adminPluginTimePicker = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginTimePicker($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.admin, jQuery ]);
\ No newline at end of file
diff --git a/code/haitiwater/static-common/javascripts/theme.custom.js b/code/haitiwater/static-common/javascripts/theme.custom.js
new file mode 100644
index 0000000..9e923a3
--- /dev/null
+++ b/code/haitiwater/static-common/javascripts/theme.custom.js
@@ -0,0 +1 @@
+/* Add here all your JS customizations */
\ No newline at end of file
diff --git a/code/haitiwater/static-common/javascripts/theme.init.js b/code/haitiwater/static-common/javascripts/theme.init.js
new file mode 100644
index 0000000..8d2e527
--- /dev/null
+++ b/code/haitiwater/static-common/javascripts/theme.init.js
@@ -0,0 +1,623 @@
+// Popover
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn['popover'] ) ) {
+ $( '[data-toggle=popover]' ).popover();
+ }
+
+}).apply( this, [ jQuery ]);
+
+// Tooltip
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn['tooltip'] ) ) {
+ $( '[data-toggle=tooltip],[rel=tooltip]' ).tooltip({ container: 'body' });
+ }
+
+}).apply( this, [ jQuery ]);
+
+// Sidebar Widgets
+(function( $ ) {
+
+ 'use strict';
+
+ function expand( content ) {
+ content.children( '.widget-content' ).slideDown( 'fast', function() {
+ $(this).css( 'display', '' );
+ content.removeClass( 'widget-collapsed' );
+ });
+ }
+
+ function collapse( content ) {
+ content.children('.widget-content' ).slideUp( 'fast', function() {
+ content.addClass( 'widget-collapsed' );
+ $(this).css( 'display', '' );
+ });
+ }
+
+ var $widgets = $( '.sidebar-widget' );
+
+ $widgets.each( function() {
+
+ var $widget = $( this ),
+ $toggler = $widget.find( '.widget-toggle' );
+
+ $toggler.on('click.widget-toggler', function() {
+ $widget.hasClass('widget-collapsed') ? expand($widget) : collapse($widget);
+ });
+ });
+
+}).apply( this, [ jQuery ]);
+
+// Codemirror
+(function( $ ) {
+
+ 'use strict';
+
+ if ( typeof CodeMirror !== 'undefined' ) {
+
+ $(function() {
+ $('[data-plugin-codemirror]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginCodeMirror(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Colorpicker
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'colorpicker' ]) ) {
+
+ $(function() {
+ $('[data-plugin-colorpicker]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginColorPicker(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Datepicker
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'datepicker' ]) ) {
+
+ $(function() {
+ $('[data-plugin-datepicker]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginDatePicker(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// iosSwitcher
+(function( $ ) {
+
+ 'use strict';
+
+ if ( typeof Switch !== 'undefined' && $.isFunction( Switch ) ) {
+
+ $(function() {
+ $('[data-plugin-ios-switch]').each(function() {
+ var $this = $( this );
+
+ $this.themePluginIOS7Switch();
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Markdown
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'markdown' ]) ) {
+
+ $(function() {
+ $('[data-plugin-markdown-editor]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginMarkdownEditor(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Masked Input
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'mask' ]) ) {
+
+ $(function() {
+ $('[data-plugin-masked-input]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginMaskedInput(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// MaxLength
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn[ 'maxlength' ]) ) {
+
+ $(function() {
+ $('[data-plugin-maxlength]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginMaxLength(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// MultiSelect
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn[ 'multiselect' ] ) ) {
+
+ $(function() {
+ $( '[data-plugin-multiselect]' ).each(function() {
+
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginMultiSelect(opts);
+
+ });
+ });
+
+ }
+
+}).apply( this, [ jQuery ]);
+
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction( $.fn[ 'placeholder' ]) ) {
+
+ $('input[placeholder]').placeholder();
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+
+// Select2
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'select2' ]) ) {
+
+ $(function() {
+ $('[data-plugin-selectTwo]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginSelect2(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Spinner
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'spinner' ]) ) {
+
+ $(function() {
+ $('[data-plugin-spinner]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginSpinner(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// SummerNote
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'summernote' ]) ) {
+
+ $(function() {
+ $('[data-plugin-summernote]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginSummerNote(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// TextArea AutoSize
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'autosize' ]) ) {
+
+ $(function() {
+ $('[data-plugin-textarea-autosize]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginTextAreaAutoSize(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// TimePicker
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'timepicker' ]) ) {
+
+ $(function() {
+ $('[data-plugin-timepicker]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginTimePicker(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Mailbox
+(function( $ ) {
+
+ 'use strict';
+
+ $(function() {
+ $('[data-mailbox]').each(function() {
+ var $this = $( this );
+
+ $this.themeMailbox();
+ });
+ });
+
+}).apply(this, [ jQuery ]);
+
+// Animate
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'appear' ]) ) {
+
+ $(function() {
+ $('[data-plugin-animate], [data-appear-animation]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginAnimate(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Carousel
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'owlCarousel' ]) ) {
+
+ $(function() {
+ $('[data-plugin-carousel]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginCarousel(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Chart Circular
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'easyPieChart' ]) ) {
+
+ $(function() {
+ $('[data-plugin-chart-circular], .circular-bar-chart:not(.manual)').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginChartCircular(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Lightbox
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'magnificPopup' ]) ) {
+
+ $(function() {
+ $('[data-plugin-lightbox], .lightbox:not(.manual)').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginLightbox(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Portlets
+(function( $ ) {
+
+ 'use strict';
+
+ $(function() {
+ $('[data-plugin-portlet]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginPortlet(opts);
+ });
+ });
+
+}).apply(this, [ jQuery ]);
+
+// Slider
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'slider' ]) ) {
+
+ $(function() {
+ $('[data-plugin-slider]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions) {
+ opts = pluginOptions;
+ }
+
+ $this.themePluginSlider(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Toggle
+(function( $ ) {
+
+ 'use strict';
+
+ $(function() {
+ $('[data-plugin-toggle]').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginToggle(opts);
+ });
+ });
+
+}).apply(this, [ jQuery ]);
+
+// Widget - Todo
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'themePluginWidgetTodoList' ]) ) {
+
+ $(function() {
+ $('[data-plugin-todo-list], ul.widget-todo-list').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginWidgetTodoList(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Widget - Toggle
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'themePluginWidgetToggleExpand' ]) ) {
+
+ $(function() {
+ $('[data-plugin-toggle-expand], .widget-toggle-expand').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginWidgetToggleExpand(opts);
+ });
+ });
+ }
+
+}).apply(this, [ jQuery ]);
+
+// Word Rotate
+(function( $ ) {
+
+ 'use strict';
+
+ if ( $.isFunction($.fn[ 'themePluginWordRotate' ]) ) {
+
+ $(function() {
+ $('[data-plugin-word-rotate], .word-rotate:not(.manual)').each(function() {
+ var $this = $( this ),
+ opts = {};
+
+ var pluginOptions = $this.data('plugin-options');
+ if (pluginOptions)
+ opts = pluginOptions;
+
+ $this.themePluginWordRotate(opts);
+ });
+ });
+
+ }
+
+}).apply(this, [ jQuery ]);
\ No newline at end of file
diff --git a/code/haitiwater/static-common/javascripts/theme.js b/code/haitiwater/static-common/javascripts/theme.js
new file mode 100644
index 0000000..4981b9b
--- /dev/null
+++ b/code/haitiwater/static-common/javascripts/theme.js
@@ -0,0 +1,3997 @@
+
+window.theme = {};
+
+// Navigation
+(function( $ ) {
+
+ 'use strict';
+
+ var $items = $( '.nav-main li.nav-parent' );
+
+ function expand( li ) {
+ li.children( 'ul.nav-children' ).slideDown( 'fast', function() {
+ li.addClass( 'nav-expanded' );
+ $(this).css( 'display', '' );
+ ensureVisible( li );
+ });
+ }
+
+ function collapse( li ) {
+ li.children('ul.nav-children' ).slideUp( 'fast', function() {
+ $(this).css( 'display', '' );
+ li.removeClass( 'nav-expanded' );
+ });
+ }
+
+ function ensureVisible( li ) {
+ var scroller = li.offsetParent();
+ if ( !scroller.get(0) ) {
+ return false;
+ }
+
+ var top = li.position().top;
+ if ( top < 0 ) {
+ scroller.animate({
+ scrollTop: scroller.scrollTop() + top
+ }, 'fast');
+ }
+ }
+
+ $items.find('> a').on('click', function() {
+ var prev = $( this ).closest('ul.nav').find('> li.nav-expanded' ),
+ next = $( this ).closest('li');
+
+ if ( prev.get( 0 ) !== next.get( 0 ) ) {
+ collapse( prev );
+ expand( next );
+ } else {
+ collapse( prev );
+ }
+ });
+
+}).apply( this, [ jQuery ]);
+
+// Skeleton
+(function(theme, $) {
+
+ 'use strict';
+
+ theme = theme || {};
+
+ var $body = $( 'body' ),
+ $html = $( 'html' ),
+ $window = $( window ),
+ isAndroid = navigator.userAgent.toLowerCase().indexOf('android') > -1;
+
+ // mobile devices with fixed has a lot of issues when focus inputs and others...
+ if ( typeof $.browser !== 'undefined' && $.browser.mobile && $html.hasClass('fixed') ) {
+ $html.removeClass( 'fixed' ).addClass( 'scroll' );
+ }
+
+ var Skeleton = {
+
+ options: {
+ sidebars: {
+ menu: '#content-menu',
+ left: '#sidebar-left',
+ right: '#sidebar-right'
+ }
+ },
+
+ customScroll: ( !Modernizr.overflowscrolling && !isAndroid && $.fn.nanoScroller !== 'undefined'),
+
+ initialize: function() {
+ this
+ .setVars()
+ .build()
+ .events();
+ },
+
+ setVars: function() {
+ this.sidebars = {};
+
+ this.sidebars.left = {
+ $el: $( this.options.sidebars.left )
+ };
+
+ this.sidebars.right = {
+ $el: $( this.options.sidebars.right ),
+ isOpened: $html.hasClass( 'sidebar-right-opened' )
+ };
+
+ this.sidebars.menu = {
+ $el: $( this.options.sidebars.menu ),
+ isOpened: $html.hasClass( 'inner-menu-opened' )
+ };
+
+ return this;
+ },
+
+ build: function() {
+
+ if ( typeof $.browser !== 'undefined' && $.browser.mobile ) {
+ $html.addClass( 'mobile-device' );
+ } else {
+ $html.addClass( 'no-mobile-device' );
+ }
+
+ $html.addClass( 'custom-scroll' );
+ if ( this.customScroll ) {
+ this.buildSidebarLeft();
+ this.buildContentMenu();
+ }
+
+ this.buildSidebarRight();
+
+ return this;
+ },
+
+ events: function() {
+ if ( this.customScroll ) {
+ this.eventsSidebarLeft();
+ }
+
+ this.eventsSidebarRight();
+ this.eventsContentMenu();
+
+ if ( typeof $.browser !== 'undefined' && !this.customScroll && isAndroid ) {
+ this.fixScroll();
+ }
+
+ return this;
+ },
+
+ fixScroll: function() {
+ var _self = this;
+
+ $window
+ .on( 'sidebar-left-opened sidebar-right-toggle', function( e, data ) {
+ _self.preventBodyScrollToggle( data.added );
+ });
+ },
+
+ buildSidebarLeft: function() {
+ this.sidebars.left.$nano = this.sidebars.left.$el.find( '.nano' );
+
+ this.sidebars.left.$nano.nanoScroller({
+ alwaysVisible: true,
+ preventPageScrolling: true
+ });
+
+ return this;
+ },
+
+ eventsSidebarLeft: function() {
+
+ var $nano = this.sidebars.left.$nano;
+
+ var updateNanoScroll = function() {
+ if ( $.support.transition ) {
+ $nano.nanoScroller();
+ $nano
+ .one('bsTransitionEnd', updateNanoScroll)
+ .emulateTransitionEnd(150)
+ } else {
+ updateNanoScroll();
+ }
+ };
+
+ this.sidebars.left.$el
+ .on( 'click', function() {
+ updateNanoScroll();
+ });
+
+ $nano
+ .on( 'mouseenter', function() {
+ if ( $html.hasClass( 'sidebar-left-collapsed' ) ) {
+ $nano.nanoScroller();
+ }
+ })
+ .on( 'mouseleave', function() {
+ if ( $html.hasClass( 'sidebar-left-collapsed' ) ) {
+ $nano.nanoScroller();
+ }
+ });
+
+ return this;
+ },
+
+ buildSidebarRight: function() {
+ this.sidebars.right.isOpened = $html.hasClass( 'sidebar-right-opened' );
+
+ if ( this.customScroll ) {
+ this.sidebars.right.$nano = this.sidebars.right.$el.find( '.nano' );
+
+ this.sidebars.right.$nano.nanoScroller({
+ alwaysVisible: true,
+ preventPageScrolling: true
+ });
+ }
+
+ return this;
+ },
+
+ eventsSidebarRight: function() {
+ var _self = this;
+
+ var open = function() {
+ if ( _self.sidebars.right.isOpened ) {
+ return close();
+ }
+
+ _self.sidebars.right.isOpened = true;
+
+ $html.addClass( 'sidebar-right-opened' );
+
+ $window.trigger( 'sidebar-right-toggle', {
+ added: true,
+ removed: false
+ });
+
+ $html.on( 'click.close-right-sidebar', function(e) {
+ e.stopPropagation();
+ close(e);
+ });
+ };
+
+ var close = function(e) {
+ if ( !!e && !!e.target && ($(e.target).closest( '.sidebar-right' ).get(0) || !$(e.target).closest( 'html' ).get(0)) ) {
+ e.preventDefault();
+ return false;
+ }
+
+ $html.removeClass( 'sidebar-right-opened' );
+ $html.off( 'click.close-right-sidebar' );
+
+ $window.trigger( 'sidebar-right-toggle', {
+ added: false,
+ removed: true
+ });
+
+ _self.sidebars.right.isOpened = false;
+ };
+
+ var bind = function() {
+ $('[data-open="sidebar-right"]').on('click', function(e) {
+ var $el = $(this);
+ e.stopPropagation();
+
+ if ( $el.is('a') )
+ e.preventDefault();
+
+ open();
+ });
+ };
+
+ this.sidebars.right.$el.find( '.mobile-close' )
+ .on( 'click', function( e ) {
+ e.preventDefault();
+ $html.trigger( 'click.close-right-sidebar' );
+ });
+
+ bind();
+
+ return this;
+ },
+
+ buildContentMenu: function() {
+ if ( !$html.hasClass( 'fixed' ) ) {
+ return false;
+ }
+
+ this.sidebars.menu.$nano = this.sidebars.menu.$el.find( '.nano' );
+
+ this.sidebars.menu.$nano.nanoScroller({
+ alwaysVisible: true,
+ preventPageScrolling: true
+ });
+
+ return this;
+ },
+
+ eventsContentMenu: function() {
+ var _self = this;
+
+ var open = function() {
+ if ( _self.sidebars.menu.isOpened ) {
+ return close();
+ }
+
+ _self.sidebars.menu.isOpened = true;
+
+ $html.addClass( 'inner-menu-opened' );
+
+ $window.trigger( 'inner-menu-toggle', {
+ added: true,
+ removed: false
+ });
+
+ $html.on( 'click.close-inner-menu', function(e) {
+
+ close(e);
+ });
+
+ };
+
+ var close = function(e) {
+ if ( !!e && !!e.target && !$(e.target).closest( '.inner-menu-collapse' ).get(0) && ($(e.target).closest( '.inner-menu' ).get(0) || !$(e.target).closest( 'html' ).get(0)) ) {
+ return false;
+ }
+
+ e.stopPropagation();
+
+ $html.removeClass( 'inner-menu-opened' );
+ $html.off( 'click.close-inner-menu' );
+
+ $window.trigger( 'inner-menu-toggle', {
+ added: false,
+ removed: true
+ });
+
+ _self.sidebars.menu.isOpened = false;
+ };
+
+ var bind = function() {
+ $('[data-open="inner-menu"]').on('click', function(e) {
+ var $el = $(this);
+ e.stopPropagation();
+
+ if ( $el.is('a') )
+ e.preventDefault();
+
+ open();
+ });
+ };
+
+ bind();
+
+ /* Nano Scroll */
+ if ( $html.hasClass( 'fixed' ) ) {
+ var $nano = this.sidebars.menu.$nano;
+
+ var updateNanoScroll = function() {
+ if ( $.support.transition ) {
+ $nano.nanoScroller();
+ $nano
+ .one('bsTransitionEnd', updateNanoScroll)
+ .emulateTransitionEnd(150)
+ } else {
+ updateNanoScroll();
+ }
+ };
+
+ this.sidebars.menu.$el
+ .on( 'click', function() {
+ updateNanoScroll();
+ });
+ }
+
+ return this;
+ },
+
+ preventBodyScrollToggle: function( shouldPrevent, $el ) {
+ setTimeout(function() {
+ if ( shouldPrevent ) {
+ $body
+ .data( 'scrollTop', $body.get(0).scrollTop )
+ .css({
+ position: 'fixed',
+ top: $body.get(0).scrollTop * -1
+ })
+ } else {
+ $body
+ .css({
+ position: '',
+ top: ''
+ })
+ .scrollTop( $body.data( 'scrollTop' ) );
+ }
+ }, 150);
+ }
+
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ Skeleton: Skeleton
+ });
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Base
+(function(theme, $) {
+
+ 'use strict';
+
+ theme = theme || {};
+
+ theme.Skeleton.initialize();
+
+}).apply(this, [ window.theme, jQuery ]);
+
+/*
+Name: Theme Admin Extension
+Written by: Okler Themes - (http://www.okler.net)
+Theme Version: 1.3.0
+*/
+
+window.theme = {};
+
+// Mailbox
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__mailbox';
+
+ var capitalizeString = function( str ) {
+ return str.charAt( 0 ).toUpperCase() + str.slice( 1 );
+ }
+
+ var Mailbox = function($wrapper) {
+ return this.initialize($wrapper);
+ };
+
+ Mailbox.prototype = {
+ initialize: function($wrapper) {
+ if ( $wrapper.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$wrapper = $wrapper;
+
+ this
+ .setVars()
+ .setData()
+ .build()
+ .events();
+
+ return this;
+ },
+
+ setVars: function() {
+ this.view = capitalizeString( this.$wrapper.data( 'mailbox-view' ) || "" );
+
+ return this;
+ },
+
+ setData: function() {
+ this.$wrapper.data(instanceName, this);
+
+ return this;
+ },
+
+ build: function() {
+
+ if ( typeof this[ 'build' + this.view ] === 'function' ) {
+ this[ 'build' + this.view ].call( this );
+ }
+
+
+ return this;
+ },
+
+ events: function() {
+ if ( typeof this[ 'events' + this.view ] === 'function' ) {
+ this[ 'events' + this.view ].call( this );
+ }
+
+ return this;
+ },
+
+ buildFolder: function() {
+ this.$wrapper.find('.mailbox-email-list .nano').nanoScroller({
+ alwaysVisible: true,
+ preventPageScrolling: true
+ });
+ },
+
+ buildEmail: function() {
+ this.buildComposer();
+ },
+
+ buildCompose: function() {
+ this.buildComposer();
+ },
+
+ buildComposer: function() {
+ this.$wrapper.find( '#compose-field' ).summernote({
+ height: 250,
+ toolbar: [
+ ['style', ['style']],
+ ['font', ['bold', 'italic', 'underline', 'clear']],
+ ['fontname', ['fontname']],
+ ['color', ['color']],
+ ['para', ['ul', 'ol', 'paragraph']],
+ ['height', ['height']],
+ ['table', ['table']],
+ ['insert', ['link', 'picture', 'video']],
+ ['view', ['fullscreen']],
+ ['help', ['help']]
+ ]
+ });
+ },
+
+ eventsCompose: function() {
+ var $composer,
+ $contentBody,
+ $html,
+ $innerBody;
+
+ $composer = $( '.note-editable' );
+ $contentBody = $( '.content-body' );
+ $html = $( 'html' );
+ $innerBody = $( '.inner-body' );
+
+ var adjustComposeSize = function() {
+ var composerHeight,
+ composerTop,
+ contentBodyPaddingBottom,
+ innerBodyHeight,
+ viewportHeight,
+ viewportWidth;
+
+
+ contentBodyPaddingBottom = parseInt( $contentBody.css('paddingBottom'), 10 ) || 0;
+ viewportHeight = Math.max( document.documentElement.clientHeight, window.innerHeight || 0 );
+ viewportWidth = Math.max( document.documentElement.clientWidth, window.innerWidth || 0 );
+
+ $composer.css( 'height', '' );
+
+ if ( viewportWidth < 767 || $html.hasClass('mobile-device') ) {
+ composerTop = $composer.offset().top;
+ composerHeight = viewportHeight - composerTop;
+ } else {
+ if ( $html.hasClass( 'fixed' ) ) {
+ composerTop = $composer.offset().top;
+ } else {
+ composerTop = $composer.position().top;
+ }
+ composerHeight = $innerBody.outerHeight() - composerTop;
+ }
+
+ composerHeight -= contentBodyPaddingBottom;
+
+ $composer.css({
+ height: composerHeight
+ });
+ };
+
+ var timer;
+ $(window)
+ .on( 'resize orientationchange sidebar-left-toggle mailbox-recalc', function() {
+ clearTimeout( timer );
+ timer = setTimeout(function() {
+ adjustComposeSize();
+ }, 100);
+ });
+
+ adjustComposeSize();
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ Mailbox: Mailbox
+ });
+
+ // jquery plugin
+ $.fn.themeMailbox = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new Mailbox($this);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Lock Screen
+(function( $ ) {
+
+ 'use strict';
+
+ var LockScreen = {
+
+ initialize: function() {
+ this.$body = $( 'body' );
+
+ this
+ .build()
+ .events();
+ },
+
+ build: function() {
+ var lockHTML,
+ userinfo;
+
+ userinfo = this.getUserInfo();
+ this.lockHTML = this.buildTemplate( userinfo );
+
+ this.$lock = this.$body.children( '#LockScreenInline' );
+ this.$userPicture = this.$lock.find( '#LockUserPicture' );
+ this.$userName = this.$lock.find( '#LockUserName' );
+ this.$userEmail = this.$lock.find( '#LockUserEmail' );
+
+ return this;
+ },
+
+ events: function() {
+ var _self = this;
+
+ this.$body.find( '[data-lock-screen="true"]' ).on( 'click', function( e ) {
+ e.preventDefault();
+
+ _self.show();
+ });
+
+ return this;
+ },
+
+ formEvents: function( $form ) {
+ var _self = this;
+
+ $form.on( 'submit', function( e ) {
+ e.preventDefault();
+
+ _self.hide();
+ });
+ },
+
+ show: function() {
+ var _self = this,
+ userinfo = this.getUserInfo();
+
+ this.$userPicture.attr( 'src', userinfo.picture );
+ this.$userName.text( userinfo.username );
+ this.$userEmail.text( userinfo.email );
+
+ this.$body.addClass( 'show-lock-screen' );
+
+ $.magnificPopup.open({
+ items: {
+ src: this.lockHTML,
+ type: 'inline'
+ },
+ modal: true,
+ mainClass: 'mfp-lock-screen',
+ callbacks: {
+ change: function() {
+ _self.formEvents( this.content.find( 'form' ) );
+ }
+ }
+ });
+ },
+
+ hide: function() {
+ $.magnificPopup.close();
+ },
+
+ getUserInfo: function() {
+ var $info,
+ picture,
+ name,
+ email;
+
+ // always search in case something is changed through ajax
+ $info = $( '#userbox' );
+ picture = $info.find( '.profile-picture img' ).attr( 'data-lock-picture' );
+ name = $info.find( '.profile-info' ).attr( 'data-lock-name' );
+ email = $info.find( '.profile-info' ).attr( 'data-lock-email' );
+
+ return {
+ picture: picture,
+ username: name,
+ email: email
+ };
+ },
+
+ buildTemplate: function( userinfo ) {
+ return [
+ ''
+ ]
+ .join( '' )
+ .replace( /\{\{picture\}\}/, userinfo.picture )
+ .replace( /\{\{username\}\}/, userinfo.username )
+ .replace( /\{\{email\}\}/, userinfo.email );
+ }
+
+ };
+
+ this.LockScreen = LockScreen;
+
+ $(function() {
+ LockScreen.initialize();
+ });
+
+}).apply(this, [ jQuery ]);
+
+// Panels
+(function( $ ) {
+
+ $(function() {
+ $('.panel')
+ .on( 'click', '.panel-actions a.fa-caret-up', function( e ) {
+ e.preventDefault();
+
+ var $this,
+ $panel;
+
+ $this = $( this );
+ $panel = $this.closest( '.panel' );
+
+ $this
+ .removeClass( 'fa-caret-up' )
+ .addClass( 'fa-caret-down' );
+
+ $panel.find('.panel-body, .panel-footer').slideDown( 200 );
+ })
+ .on( 'click', '.panel-actions a.fa-caret-down', function( e ) {
+ e.preventDefault();
+
+ var $this,
+ $panel;
+
+ $this = $( this );
+ $panel = $this.closest( '.panel' );
+
+ $this
+ .removeClass( 'fa-caret-down' )
+ .addClass( 'fa-caret-up' );
+
+ $panel.find('.panel-body, .panel-footer').slideUp( 200 );
+ })
+ .on( 'click', '.panel-actions a.fa-times', function( e ) {
+ e.preventDefault();
+
+ var $panel,
+ $row;
+
+ $panel = $(this).closest('.panel');
+
+ if ( !!( $panel.parent('div').attr('class') || '' ).match( /col-(xs|sm|md|lg)/g ) && $panel.siblings().length === 0 ) {
+ $row = $panel.closest('.row');
+ $panel.parent('div').remove();
+ if ( $row.children().length === 0 ) {
+ $row.remove();
+ }
+ } else {
+ $panel.remove();
+ }
+ });
+ });
+
+})( jQuery );
+
+// Bootstrap Toggle
+(function( $ ) {
+
+ 'use strict';
+
+ var $window = $( window );
+
+ var toggleClass = function( $el ) {
+ if ( !!$el.data('toggleClassBinded') ) {
+ return false;
+ }
+
+ var $target,
+ className,
+ eventName;
+
+ $target = $( $el.attr('data-target') );
+ className = $el.attr('data-toggle-class');
+ eventName = $el.attr('data-fire-event');
+
+
+ $el.on('click.toggleClass', function(e) {
+ e.preventDefault();
+ $target.toggleClass( className );
+
+ var hasClass = $target.hasClass( className );
+
+ if ( !!eventName ) {
+ $window.trigger( eventName, {
+ added: hasClass,
+ removed: !hasClass
+ });
+ }
+ });
+
+ $el.data('toggleClassBinded', true);
+
+ return true;
+ };
+
+ $(function() {
+ $('[data-toggle-class][data-target]').each(function() {
+ toggleClass( $(this) );
+ });
+ });
+
+}).apply( this, [ jQuery ]);
+
+// Form to Object
+(function( $ ) {
+
+ 'use strict';
+
+ $.fn.formToObject = function() {
+ var arrayData,
+ objectData;
+
+ arrayData = this.serializeArray();
+ objectData = {};
+
+ $.each( arrayData, function() {
+ var value;
+
+ if (this.value != null) {
+ value = this.value;
+ } else {
+ value = '';
+ }
+
+ if (objectData[this.name] != null) {
+ if (!objectData[this.name].push) {
+ objectData[this.name] = [objectData[this.name]];
+ }
+
+ objectData[this.name].push(value);
+ } else {
+ objectData[this.name] = value;
+ }
+ });
+
+ return objectData;
+ };
+
+})( jQuery );
+
+// Codemirror
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__codemirror';
+
+ var PluginCodeMirror = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginCodeMirror.defaults = {
+ lineNumbers: true,
+ styleActiveLine: true,
+ matchBrackets: true,
+ theme: 'monokai'
+ };
+
+ PluginCodeMirror.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginCodeMirror.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ CodeMirror.fromTextArea( this.$el.get(0), this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginCodeMirror: PluginCodeMirror
+ });
+
+ // jquery plugin
+ $.fn.themePluginCodeMirror = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginCodeMirror($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Colorpicker
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__colorpicker';
+
+ var PluginColorPicker = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginColorPicker.defaults = {
+ };
+
+ PluginColorPicker.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginColorPicker.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.colorpicker( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginColorPicker: PluginColorPicker
+ });
+
+ // jquery plugin
+ $.fn.themePluginColorPicker = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginColorPicker($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Datepicker
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__datepicker';
+
+ var PluginDatePicker = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginDatePicker.defaults = {
+ };
+
+ PluginDatePicker.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setVars()
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setVars: function() {
+ this.skin = this.$el.data( 'plugin-skin' );
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginDatePicker.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.datepicker( this.options );
+
+ if ( !!this.skin ) {
+ this.$el.data('datepicker').picker.addClass( 'datepicker-' + this.skin );
+ }
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginDatePicker: PluginDatePicker
+ });
+
+ // jquery plugin
+ $.fn.themePluginDatePicker = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginDatePicker($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// iosSwitcher
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__IOS7Switch';
+
+ var PluginIOS7Switch = function($el) {
+ return this.initialize($el);
+ };
+
+ PluginIOS7Switch.prototype = {
+ initialize: function($el) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ build: function() {
+ var switcher = new Switch( this.$el.get(0) );
+
+ $( switcher.el ).on( 'click', function( e ) {
+ e.preventDefault();
+ switcher.toggle();
+ });
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginIOS7Switch: PluginIOS7Switch
+ });
+
+ // jquery plugin
+ $.fn.themePluginIOS7Switch = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginIOS7Switch($this);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Markdown
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__markdownEditor';
+
+ var PluginMarkdownEditor = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMarkdownEditor.defaults = {
+ iconlibrary: 'fa'
+ };
+
+ PluginMarkdownEditor.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMarkdownEditor.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.markdown( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginMarkdownEditor: PluginMarkdownEditor
+ });
+
+ // jquery plugin
+ $.fn.themePluginMarkdownEditor = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMarkdownEditor($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Masked Input
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__maskedInput';
+
+ var PluginMaskedInput = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMaskedInput.defaults = {
+ };
+
+ PluginMaskedInput.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMaskedInput.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.mask( this.$el.data('input-mask'), this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginMaskedInput: PluginMaskedInput
+ });
+
+ // jquery plugin
+ $.fn.themePluginMaskedInput = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMaskedInput($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// MaxLength
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__maxlength';
+
+ var PluginMaxLength = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMaxLength.defaults = {
+ alwaysShow: true,
+ placement: 'bottom-left',
+ warningClass: 'label label-success bottom-left',
+ limitReachedClass: 'label label-danger bottom-left'
+ };
+
+ PluginMaxLength.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMaxLength.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.maxlength( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginMaxLength: PluginMaxLength
+ });
+
+ // jquery plugin
+ $.fn.themePluginMaxLength = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMaxLength($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// MultiSelect
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__multiselect';
+
+ var PluginMultiSelect = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginMultiSelect.defaults = {
+ templates: {
+ filter: '
'
+ }
+ };
+
+ PluginMultiSelect.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginMultiSelect.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.multiselect( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginMultiSelect: PluginMultiSelect
+ });
+
+ // jquery plugin
+ $.fn.themePluginMultiSelect = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginMultiSelect($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Select2
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__select2';
+
+ var PluginSelect2 = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSelect2.defaults = {
+ };
+
+ PluginSelect2.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginSelect2.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.select2( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginSelect2: PluginSelect2
+ });
+
+ // jquery plugin
+ $.fn.themePluginSelect2 = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSelect2($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Spinner
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__spinner';
+
+ var PluginSpinner = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSpinner.defaults = {
+ };
+
+ PluginSpinner.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginSpinner.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.spinner( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginSpinner: PluginSpinner
+ });
+
+ // jquery plugin
+ $.fn.themePluginSpinner = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSpinner($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// SummerNote
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__summernote';
+
+ var PluginSummerNote = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSummerNote.defaults = {
+ onfocus: function() {
+ $( this ).closest( '.note-editor' ).addClass( 'active' );
+ },
+ onblur: function() {
+ $( this ).closest( '.note-editor' ).removeClass( 'active' );
+ }
+ };
+
+ PluginSummerNote.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginSummerNote.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.summernote( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginSummerNote: PluginSummerNote
+ });
+
+ // jquery plugin
+ $.fn.themePluginSummerNote = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSummerNote($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// TextArea AutoSize
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var initialized = false;
+ var instanceName = '__textareaAutosize';
+
+ var PluginTextAreaAutoSize = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginTextAreaAutoSize.defaults = {
+ };
+
+ PluginTextAreaAutoSize.prototype = {
+ initialize: function($el, opts) {
+ if (initialized) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginTextAreaAutoSize.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.autosize( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginTextAreaAutoSize: PluginTextAreaAutoSize
+ });
+
+ // jquery plugin
+ $.fn.themePluginTextAreaAutoSize = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginTextAreaAutoSize($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// TimePicker
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__timepicker';
+
+ var PluginTimePicker = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginTimePicker.defaults = {
+ disableMousewheel: true
+ };
+
+ PluginTimePicker.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, PluginTimePicker.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.timepicker( this.options );
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginTimePicker: PluginTimePicker
+ });
+
+ // jquery plugin
+ $.fn.themePluginTimePicker = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginTimePicker($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Map Builder
+(function( theme, $ ) {
+
+ 'use strict';
+
+ // prevent undefined var
+ theme = theme || {};
+
+ // internal var to check if reached limit
+ var timeouts = 0;
+
+ // instance
+ var instanceName = '__gmapbuilder';
+
+ // private
+ var roundNumber = function( number, precision ) {
+ if( precision < 0 ) {
+ precision = 0;
+ } else if( precision > 10 ) {
+ precision = 10;
+ }
+ var a = [ 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000 ];
+
+ return Math.round( number * a[ precision ] ) / a[ precision ];
+ };
+
+ // definition
+ var GMapBuilder = function( $wrapper, opts ) {
+ return this.initialize( $wrapper, opts );
+ };
+
+ GMapBuilder.defaults = {
+ mapSelector: '#gmap',
+
+ markers: {
+ modal: '#MarkerModal',
+ list: '#MarkersList',
+ removeAll: '#MarkerRemoveAll'
+ },
+
+ previewModal: '#ModalPreview',
+ getCodeModal: '#ModalGetCode',
+
+ mapOptions: {
+ center: {
+ lat: -38.908133,
+ lng: -13.692628
+ },
+ panControl: true,
+ zoom: 3
+ }
+ };
+
+ GMapBuilder.prototype = {
+
+ markers: [],
+
+ initialize: function( $wrapper, opts ) {
+ this.$wrapper = $wrapper;
+
+ this
+ .setData()
+ .setOptions( opts )
+ .setVars()
+ .build()
+ .events();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$wrapper.data( instanceName, this );
+
+ return this;
+ },
+
+ setOptions: function( opts ) {
+ this.options = $.extend( true, {}, GMapBuilder.defaults, opts );
+
+ return this;
+ },
+
+ setVars: function() {
+ this.$mapContainer = this.$wrapper.find( this.options.mapSelector );
+
+ this.$previewModal = $( this.options.previewModal );
+ this.$getCodeModal = $( this.options.getCodeModal );
+
+ this.marker = {};
+ this.marker.$modal = $( this.options.markers.modal );
+ this.marker.$form = this.marker.$modal.find( 'form' );
+ this.marker.$list = $( this.options.markers.list );
+ this.marker.$removeAll = $( this.options.markers.removeAll );
+
+ return this;
+ },
+
+ build: function() {
+ var _self = this;
+
+ if ( !!window.SnazzyThemes ) {
+ var themeOpts = [];
+
+ $.each( window.SnazzyThemes, function( i, theme ) {
+ themeOpts.push( $('').data( 'json', theme.json ) );
+ });
+
+ this.$wrapper.find( '[data-builder-field="maptheme"]' ).append( themeOpts );
+ }
+
+ this.geocoder = new google.maps.Geocoder();
+
+ google.maps.event.addDomListener( window, 'load', function() {
+ _self.options.mapOptions.center = new google.maps.LatLng( _self.options.mapOptions.center.lat, _self.options.mapOptions.center.lng );
+
+ _self.map = new google.maps.Map( _self.$mapContainer.get(0), _self.options.mapOptions );
+
+ _self
+ .updateControl( 'latlng' )
+ .updateControl( 'zoomlevel' );
+
+ _self.mapEvents();
+ });
+
+ return this;
+ },
+
+ events: function() {
+ var _self = this;
+
+ this.$wrapper.find( '[data-builder-field]' ).each(function() {
+ var $this = $( this ),
+ field,
+ value;
+
+ field = $this.data( 'builder-field' );
+
+ $this.on( 'change', function() {
+
+ if ( $this.is( 'select' ) ) {
+ value = $this.children( 'option:selected' ).val().toLowerCase();
+ } else {
+ value = $this.val().toLowerCase();
+ }
+
+ _self.updateMap( field, value );
+ });
+
+ });
+
+ this.marker.$form.on( 'submit', function( e ) {
+ e.preventDefault();
+
+ _self.saveMarker( _self.marker.$form.formToObject() );
+ });
+
+ this.marker.$removeAll.on( 'click', function( e ) {
+ e.preventDefault();
+ _self.removeAllMarkers();
+ });
+
+ // preview events
+ this.$previewModal.on( 'shown.bs.modal', function() {
+ _self.preview();
+ });
+
+ this.$previewModal.on( 'hidden.bs.modal', function() {
+ _self.$previewModal.find( 'iframe' ).get(0).contentWindow.document.body.innerHTML = '';
+ });
+
+ // get code events
+ this.$getCodeModal.on( 'shown.bs.modal', function() {
+ _self.getCode();
+ });
+
+ return this;
+ },
+
+ // MAP FUNCTIONS
+ // -----------------------------------------------------------------------------
+ mapEvents: function() {
+ var _self = this;
+
+ google.maps.event.addDomListener( _self.map, 'resize', function() {
+ google.maps.event.trigger( _self.map, 'resize' );
+ });
+
+ google.maps.event.addListener( this.map, 'center_changed', function() {
+ var coords = _self.map.getCenter();
+ _self.updateControl( 'latlng', {
+ lat: roundNumber( coords.lat(), 6 ),
+ lng: roundNumber( coords.lng(), 6 )
+ });
+ });
+
+ google.maps.event.addListener( this.map, 'zoom_changed', function() {
+ _self.updateControl( 'zoomlevel', _self.map.getZoom() );
+ });
+
+ google.maps.event.addListener( this.map, 'maptypeid_changed', function() {
+ _self.updateControl( 'maptype', _self.map.getMapTypeId() );
+ });
+
+ return this;
+ },
+
+ updateMap: function( prop, value ) {
+ var updateFn;
+
+ updateFn = this.updateMapProperty[ prop ];
+
+ if ( $.isFunction( updateFn ) ) {
+ updateFn.apply( this, [ value ] );
+ } else {
+ console.info( 'missing update function for', prop );
+ }
+
+ return this;
+ },
+
+ updateMapProperty: {
+
+ latlng: function() {
+ var lat,
+ lng;
+
+ lat = this.$wrapper.find('[data-builder-field][name="latitude"]').val();
+ lng = this.$wrapper.find('[data-builder-field][name="longitude"]').val();
+
+ if ( lat.length > 0 && lng.length > 0 ) {
+ this.map.setCenter( new google.maps.LatLng( lat, lng ) );
+ }
+
+ return this;
+ },
+
+ zoomlevel: function( value ) {
+ var value = arguments[ 0 ];
+
+ this.map.setZoom( parseInt( value, 10 ) );
+
+ return this;
+ },
+
+ maptypecontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ if ( value === 'false' ){
+ options.mapTypeControl = false;
+ } else {
+ options = {
+ mapTypeControl: true,
+ mapTypeControlOptions: {
+ style: google.maps.MapTypeControlStyle[ value.toUpperCase() ]
+ }
+ };
+ }
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ zoomcontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ if ( value === 'false' ){
+ options.zoomControl = false;
+ } else {
+ options = {
+ zoomControl: true,
+ zoomControlOptions: {
+ style: google.maps.ZoomControlStyle[ value.toUpperCase() ]
+ }
+ };
+ }
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ scalecontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ options.scaleControl = value !== 'false';
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ streetviewcontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ options.streetViewControl = value !== 'false';
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ pancontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ options.panControl = value !== 'false';
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ overviewcontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ if ( value === 'false' ){
+ options.overviewMapControl = false;
+ } else {
+ options = {
+ overviewMapControl: true,
+ overviewMapControlOptions: {
+ opened: value === 'opened'
+ }
+ };
+ }
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ draggablecontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ options.draggable = value !== 'false';
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ clicktozoomcontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ options.disableDoubleClickZoom = value === 'false';
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ scrollwheelcontrol: function( value ) {
+ var options;
+
+ options = {};
+
+ options.scrollwheel = value !== 'false';
+
+ this.map.setOptions( options );
+
+ return this;
+ },
+
+ maptype: function( value ) {
+ var options,
+ mapStyles,
+ mapType;
+
+ mapStyles = this.$wrapper.find( '[data-builder-field="maptheme"]' ).children( 'option' ).filter( ':selected' ).data( 'json' );
+ mapType = google.maps.MapTypeId[ value.toUpperCase() ];
+
+ options = {
+ mapTypeId: mapType
+ };
+
+ if ( $.inArray( google.maps.MapTypeId[ value.toUpperCase() ], [ 'terrain', 'roadmap' ]) > -1 && !!mapStyles ) {
+ options.styles = eval( mapStyles );
+ } else {
+ options.styles = false;
+ this.updateControl( 'maptheme' );
+ }
+
+ this.map.setOptions( options );
+ },
+
+ maptheme: function( value ) {
+ var json,
+ mapType,
+ options;
+
+ mapType = google.maps.MapTypeId[ this.map.getMapTypeId() === 'terrain' ? 'TERRAIN' : 'ROADMAP' ];
+ options = {};
+ json = this.$wrapper.find( '[data-builder-field="maptheme"]' ).children( 'option' ).filter( ':selected' ).data( 'json' );
+
+ if ( !json ) {
+ options = {
+ mapTypeId: mapType,
+ styles: false
+ };
+ } else {
+ options = {
+ mapTypeId: mapType,
+ styles: eval( json )
+ };
+ }
+
+ this.map.setOptions( options );
+ }
+
+ },
+
+ // CONTROLS FUNCTIONS
+ // -----------------------------------------------------------------------------
+ updateControl: function( prop ) {
+ var updateFn;
+
+ updateFn = this.updateControlValue[ prop ];
+
+ if ( $.isFunction( updateFn ) ) {
+ updateFn.apply( this );
+ } else {
+ console.info( 'missing update function for', prop );
+ }
+
+ return this;
+ },
+
+ updateControlValue: {
+
+ latlng: function() {
+ var center = this.map.getCenter();
+
+ this.$wrapper.find('[data-builder-field][name="latitude"]').val( roundNumber( center.lat() , 6 ) );
+ this.$wrapper.find('[data-builder-field][name="longitude"]').val( roundNumber( center.lng() , 6 ) );
+ },
+
+ zoomlevel: function() {
+ var $control,
+ level;
+
+ level = this.map.getZoom();
+
+ $control = this.$wrapper.find('[data-builder-field="zoomlevel"]');
+
+ $control
+ .children( 'option[value="' + level + '"]' )
+ .prop( 'selected', true );
+
+ if ( $control.hasClass( 'select2-offscreen' ) ) {
+ $control.select2( 'val', level );
+ }
+ },
+
+ maptype: function() {
+ var $control,
+ mapType;
+
+ mapType = this.map.getMapTypeId();
+ $control = this.$wrapper.find('[data-builder-field="maptype"]');
+
+ $control
+ .children( 'option[value="' + mapType + '"]' )
+ .prop( 'selected', true );
+
+ if ( $control.hasClass( 'select2-offscreen' ) ) {
+ $control.select2( 'val', mapType );
+ }
+ },
+
+ maptheme: function() {
+ var $control;
+
+ $control = this.$wrapper.find('[data-builder-field="maptheme"]');
+
+ $control
+ .children( 'option[value="false"]' )
+ .prop( 'selected', true );
+
+ if ( $control.hasClass( 'select2-offscreen' ) ) {
+ $control.select2( 'val', 'false' );
+ }
+ }
+
+ },
+
+ // MARKERS FUNCTIONS
+ // -----------------------------------------------------------------------------
+ editMarker: function( marker ) {
+ this.currentMarker = marker;
+
+ this.marker.$form
+ .find( '#MarkerLocation' ).val( marker.location );
+
+ this.marker.$form
+ .find( '#MarkerTitle' ).val( marker.title );
+
+ this.marker.$form
+ .find( '#MarkerDescription' ).val( marker.description );
+
+ this.marker.$modal.modal( 'show' );
+ },
+
+ removeMarker: function( marker ) {
+ var i;
+
+ marker._instance.setMap( null );
+ marker._$html.remove();
+
+ for( i = 0; i < this.markers.length; i++ ) {
+ if ( marker === this.markers[ i ] ) {
+ this.markers.splice( i, 1 );
+ break;
+ }
+ }
+
+ if ( this.markers.length === 0 ) {
+ this.marker.$list.addClass( 'hidden' );
+ }
+ },
+
+ saveMarker: function( marker ) {
+ this._geocode( marker );
+ },
+
+ removeAllMarkers: function() {
+ var i = 0,
+ l,
+ marker;
+
+ l = this.markers.length;
+
+ for( ; i < l; i++ ) {
+ marker = this.markers[ i ];
+
+ marker._instance.setMap( null );
+ marker._$html.remove();
+ }
+
+ this.markers = [];
+ this.marker.$list.addClass( 'hidden' );
+ },
+
+ _geocode: function( marker ) {
+ var _self = this,
+ status;
+
+ this.geocoder.geocode({ address: marker.location }, function( response, status ) {
+ _self._onGeocodeResult( marker, response, status );
+ });
+ },
+
+ _onGeocodeResult: function( marker, response, status ) {
+ var result;
+
+ if ( !response || status !== google.maps.GeocoderStatus.OK ) {
+ if ( status == google.maps.GeocoderStatus.ZERO_RESULTS ) {
+ // show notification
+ } else {
+ timeouts++;
+ if ( timeouts > 3 ) {
+ // show notification reached limit of requests
+ }
+ }
+ } else {
+ timeouts = 0;
+
+ if ( this.currentMarker ) {
+ this.removeMarker( this.currentMarker );
+ this.currentMarker = null;
+ }
+
+ // grab first result of the list
+ result = response[ 0 ];
+
+ // get lat & lng and set to marker
+ marker.lat = Math.round( result.geometry.location.lat() * 1000000 ) / 1000000;
+ marker.lng = Math.round( result.geometry.location.lng() * 1000000 ) / 1000000;
+
+ var opts = {
+ position: new google.maps.LatLng( marker.lat, marker.lng ),
+ map: this.map
+ };
+
+ if ( marker.title.length > 0 ) {
+ opts.title = marker.title;
+ }
+
+ if ( marker.description.length > 0 ) {
+ opts.desc = marker.description;
+ }
+
+ marker.position = opts.position;
+ marker._instance = new google.maps.Marker( opts );
+
+ if ( !!marker.title || !!marker.description ) {
+ this._bindMarkerClick( marker );
+ }
+
+ this.markers.push( marker );
+
+ // append to markers list
+ this._appendMarkerToList( marker );
+
+ // hide modal and reset form
+ this.marker.$form.get(0).reset();
+ this.marker.$modal.modal( 'hide' );
+ }
+ },
+
+ _appendMarkerToList: function( marker ) {
+ var _self = this,
+ html;
+
+ html = [
+ '',
+ '{location}
',
+ '',
+ '',
+ '',
+ ''
+ ].join('');
+
+ html = html.replace( /\{location\}/, !!marker.title ? marker.title : marker.location );
+
+ marker._$html = $( html );
+
+ // events
+ marker._$html.find( '.location-center' )
+ .on( 'click', function( e ) {
+ _self.map.setCenter( marker.position );
+ });
+
+ marker._$html.find( '.location-remove' )
+ .on( 'click', function( e ) {
+ e.preventDefault();
+ _self.removeMarker( marker );
+ });
+
+ marker._$html.find( '.location-edit' )
+ .on( 'click', function( e ) {
+ e.preventDefault();
+ _self.editMarker( marker );
+ });
+
+ this.marker.$list
+ .append( marker._$html )
+ .removeClass( 'hidden' );
+ },
+
+ _bindMarkerClick: function( marker ) {
+ var _self = this,
+ html;
+
+ html = [
+ '',
+ '{title}',
+ '{description}',
+ '
'
+ ].join('');
+
+ html = html.replace(/\{title\}/, !!marker.title ? ("" + marker.title + "
") : "" );
+ html = html.replace(/\{description\}/, !!marker.description ? ("" + marker.description + "
") : "" );
+
+ marker._infoWindow = new google.maps.InfoWindow({ content: html });
+
+ google.maps.event.addListener( marker._instance, 'click', function() {
+
+ if ( marker._infoWindow.isOpened ) {
+ marker._infoWindow.close();
+ marker._infoWindow.isOpened = false;
+ } else {
+ marker._infoWindow.open( _self.map, this );
+ marker._infoWindow.isOpened = true;
+ }
+
+ });
+ },
+
+ preview: function() {
+ var customScript,
+ googleScript,
+ iframe,
+ previewHtml;
+
+ previewHtml = [
+ '',
+ ''
+ ];
+
+ iframe = this.$previewModal.find( 'iframe' ).get(0).contentWindow.document;
+
+ iframe.body.innerHTML = previewHtml.join('');
+
+ customScript = iframe.createElement( 'script' );
+ customScript.type = 'text/javascript';
+ customScript.text = "window.initialize = function() { " + this.generate() + " init(); }; ";
+ iframe.body.appendChild( customScript );
+
+ googleScript = iframe.createElement( 'script' );
+ googleScript.type = 'text/javascript';
+ googleScript.text = 'function loadScript() { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "http://maps.googleapis.com/maps/api/js?key=&sensor=&callback=initialize"; document.body.appendChild(script); } loadScript()';
+ iframe.body.appendChild( googleScript );
+ },
+
+ getCode: function() {
+ this.$getCodeModal.find('.modal-body pre').html( this.generate().replace( //g, '>' ) );
+ },
+
+ // GENERATE CODE
+ // -----------------------------------------------------------------------------
+ generate: function() {
+ var i,
+ work;
+
+ var output = [
+ ' google.maps.event.addDomListener(window, "load", init);',
+ ' var map;',
+ ' function init() {',
+ ' var mapOptions = {',
+ ' center: new google.maps.LatLng({lat}, {lng}),',
+ ' zoom: {zoom},',
+ ' zoomControl: {zoomControl},',
+ ' {zoomControlOptions}',
+ ' disableDoubleClickZoom: {disableDoubleClickZoom},',
+ ' mapTypeControl: {mapTypeControl},',
+ ' {mapTypeControlOptions}',
+ ' scaleControl: {scaleControl},',
+ ' scrollwheel: {scrollwheel},',
+ ' panControl: {panControl},',
+ ' streetViewControl: {streetViewControl},',
+ ' draggable : {draggable},',
+ ' overviewMapControl: {overviewMapControl},',
+ ' {overviewMapControlOptions}',
+ ' mapTypeId: google.maps.MapTypeId.{mapTypeId}{styles}',
+ ' };',
+ '',
+ ' var mapElement = document.getElementById("{mapid}");',
+ ' var map = new google.maps.Map(mapElement, mapOptions);',
+ ' {locations}',
+ ' }'
+ ];
+
+ output = output.join("\r\n");
+
+ var zoomControl = this.$wrapper.find('[data-builder-field="zoomcontrol"] option:selected').val() !== 'false';
+ var mapTypeControl = this.$wrapper.find('[data-builder-field="maptypecontrol"] option:selected').val() !== 'false';
+ var overviewMapControl = this.$wrapper.find('[data-builder-field="overviewcontrol"] option:selected').val().toLowerCase();
+ var $themeControl = this.$wrapper.find('[data-builder-field="maptheme"] option:selected').filter( ':selected' );
+
+ output = output
+ .replace( /\{mapid\}/, this.$wrapper.find('[data-builder-field="mapid"]').val() )
+ .replace( /\{lat\}/, this.$wrapper.find('[data-builder-field][name="latitude"]').val() )
+ .replace( /\{lng\}/, this.$wrapper.find('[data-builder-field][name="longitude"]').val() )
+ .replace( /\{zoom\}/, this.$wrapper.find('[data-builder-field="zoomlevel"] option:selected').val() )
+ .replace( /\{zoomControl\}/, zoomControl )
+ .replace( /\{disableDoubleClickZoom\}/, this.$wrapper.find('[data-builder-field="clicktozoomcontrol"] option:selected').val() === 'false' )
+ .replace( /\{mapTypeControl\}/, mapTypeControl )
+ .replace( /\{scaleControl\}/, this.$wrapper.find('[data-builder-field="scalecontrol"] option:selected').val() !== 'false' )
+ .replace( /\{scrollwheel\}/, this.$wrapper.find('[data-builder-field="scrollwheelcontrol"] option:selected').val() !== 'false' )
+ .replace( /\{panControl\}/, this.$wrapper.find('[data-builder-field="pancontrol"] option:selected').val() !== 'false' )
+ .replace( /\{streetViewControl\}/, this.$wrapper.find('[data-builder-field="streetviewcontrol"] option:selected').val() !== 'false' )
+ .replace( /\{draggable\}/, this.$wrapper.find('[data-builder-field="draggablecontrol"] option:selected').val() !== 'false' )
+ .replace( /\{overviewMapControl\}/, overviewMapControl !== 'false' )
+ .replace( /\{mapTypeId\}/, this.$wrapper.find('[data-builder-field="maptype"] option:selected').val().toUpperCase() );
+
+ if ( zoomControl ) {
+ work = {
+ zoomControlOptions: {
+ style: this.$wrapper.find('[data-builder-field="maptypecontrol"] option:selected').val().toUpperCase()
+ }
+ };
+ output = output.replace( /\{zoomControlOptions\}/, "zoomControlOptions: {\r\n style: google.maps.ZoomControlStyle." + this.$wrapper.find('[data-builder-field="zoomcontrol"] option:selected').val().toUpperCase() + "\r\n\ },");
+ } else {
+ output = output.replace( /\{zoomControlOptions\}/, '' );
+ }
+
+ if ( mapTypeControl ) {
+ work = {
+ zoomControlOptions: {
+ style: this.$wrapper.find('[data-builder-field="maptypecontrol"] option:selected').val().toUpperCase()
+ }
+ };
+ output = output.replace( /\{mapTypeControlOptions\}/, "mapTypeControlOptions: {\r\n style: google.maps.MapTypeControlStyle." + this.$wrapper.find('[data-builder-field="maptypecontrol"] option:selected').val().toUpperCase() + "\r\n\ },");
+ } else {
+ output = output.replace( /\{mapTypeControlOptions\}/, '' );
+ }
+
+ if ( overviewMapControl !== 'false' ) {
+ output = output.replace( /\{overviewMapControlOptions\}/, "overviewMapControlOptions: {\r\n opened: " + (overviewMapControl === 'opened') + "\r\n\ },");
+ } else {
+ output = output.replace( /\{overviewMapControlOptions\}/, '' );
+ }
+
+ if ( $themeControl.val() !== 'false' ) {
+ output = output.replace( /\{styles\}/, ',\r\n styles: ' + $themeControl.data( 'json' ).replace(/\r\n/g, '') );
+ } else {
+ output = output.replace( /\{styles\}/, '' );
+ }
+
+ if ( this.markers.length > 0 ) {
+ var work = [ 'var locations = [' ];
+ var m,
+ object;
+
+ for( i = 0; i < this.markers.length; i++ ) {
+ m = this.markers[ i ];
+ object = '';
+
+ object += ' { lat: ' + m.lat + ', lng: ' + m.lng;
+
+ if ( !!m.title ) {
+ object += ', title: "' + m.title + '"';
+ }
+
+ if ( !!m.description ) {
+ object += ', description: "' + m.description + '"';
+ }
+
+ object += ' }';
+
+ if ( i + 1 < this.markers.length ) {
+ object += ',';
+ }
+
+ work.push( object );
+ }
+
+ work.push( ' ];\r\n' )
+
+ work.push( ' var opts = {};' )
+ work.push( ' for (var i = 0; i < locations.length; i++) {' );
+ work.push( ' opts.position = new google.maps.LatLng( locations[ i ].lat, locations[ i ].lng );' );
+ work.push( ' opts.map = map;' );
+ work.push( ' if ( !!locations[ i ] .title ) { opts.title = locations[ i ].title; }');
+ work.push( ' if ( !!locations[ i ] .description ) { opts.description = locations[ i ].description; }');
+ work.push( ' marker = new google.maps.Marker( opts );' );
+ work.push( '' );
+ work.push( ' (function() {' );
+ work.push( ' var html = [' );
+ work.push( ' \'\',' );
+ work.push( ' \'{title}\',' );
+ work.push( ' \'{description}\',' );
+ work.push( ' \'
\'' );
+ work.push( ' ].join(\'\');' );
+
+ work.push( '' );
+ work.push( ' html = html.replace(/\{title\}/, !!opts.title ? ("" + opts.title + "
") : "" );' );
+ work.push( ' html = html.replace(/\{description\}/, !!opts.description ? ("" + opts.description + "
") : "" );' );
+
+ work.push( ' var infoWindow = new google.maps.InfoWindow({ content: html });' );
+
+ work.push( ' google.maps.event.addListener( marker, \'click\', function() {' );
+ work.push( ' if ( infoWindow.isOpened ) {' );
+ work.push( ' infoWindow.close();' );
+ work.push( ' infoWindow.isOpened = false;' );
+ work.push( ' } else {' );
+ work.push( ' infoWindow.open( map, this );' );
+ work.push( ' infoWindow.isOpened = true;' );
+ work.push( ' }' );
+ work.push( ' });' );
+ work.push( ' })();' )
+ work.push( ' }');
+
+ output = output.replace( /\{locations\}/, work.join('\r\n') );
+ } else {
+ output = output.replace( /\{locations\}/, '' );
+ }
+
+ console.log( output );
+
+ return output;
+ }
+ };
+
+ // expose
+ $.extend( true, theme, {
+ Maps: {
+ GMapBuilder: GMapBuilder
+ }
+ });
+
+ // jQuery plugin
+ $.fn.themeGMapBuilder = function( opts ) {
+ return this.map(function() {
+ var $this = $( this ),
+ instance;
+
+ instance = $this.data( instanceName );
+
+ if ( instance ) {
+ return instance;
+ } else {
+ return (new GMapBuilder( $this, opts ));
+ }
+ });
+ };
+
+ // auto initialize
+ $(function() {
+ $('[data-theme-gmap-builder]').each(function() {
+ var $this = $( this );
+
+ window.builder = $this.themeGMapBuilder();
+ });
+ });
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Animate
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__animate';
+
+ var PluginAnimate = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginAnimate.defaults = {
+ accX: 0,
+ accY: -150,
+ delay: 1
+ };
+
+ PluginAnimate.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend(true, {}, PluginAnimate.defaults, opts, {
+ wrapper: this.$el
+ });
+
+ return this;
+ },
+
+ build: function() {
+ var self = this,
+ $el = this.options.wrapper,
+ delay = 0;
+
+ $el.addClass('appear-animation');
+
+ if(!$('html').hasClass('no-csstransitions') && $(window).width() > 767) {
+
+ $el.appear(function() {
+
+ delay = ($el.attr('data-appear-animation-delay') ? $el.attr('data-appear-animation-delay') : self.options.delay);
+
+ if(delay > 1) {
+ $el.css('animation-delay', delay + 'ms');
+ }
+
+ $el.addClass($el.attr('data-appear-animation'));
+
+ setTimeout(function() {
+ $el.addClass('appear-animation-visible');
+ }, delay);
+
+ }, {accX: self.options.accX, accY: self.options.accY});
+
+ } else {
+
+ $el.addClass('appear-animation-visible');
+
+ }
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginAnimate: PluginAnimate
+ });
+
+ // jquery plugin
+ $.fn.themePluginAnimate = function(opts) {
+ return this.map(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginAnimate($this, opts);
+ }
+
+ });
+ };
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Carousel
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var initialized = false;
+ var instanceName = '__carousel';
+
+ var PluginCarousel = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginCarousel.defaults = {
+ itemsDesktop: false,
+ itemsDesktopSmall: false,
+ itemsTablet: false,
+ itemsTabletSmall: false,
+ itemsMobile: false
+ };
+
+ PluginCarousel.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend(true, {}, PluginCarousel.defaults, opts, {
+ wrapper: this.$el
+ });
+
+ return this;
+ },
+
+ build: function() {
+ this.options.wrapper.owlCarousel(this.options).addClass("owl-carousel-init");
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginCarousel: PluginCarousel
+ });
+
+ // jquery plugin
+ $.fn.themePluginCarousel = function(opts) {
+ return this.map(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginCarousel($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Chart Circular
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__chartCircular';
+
+ var PluginChartCircular = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginChartCircular.defaults = {
+ accX: 0,
+ accY: -150,
+ delay: 1,
+ barColor: '#0088CC',
+ trackColor: '#f2f2f2',
+ scaleColor: false,
+ scaleLength: 5,
+ lineCap: 'round',
+ lineWidth: 13,
+ size: 175,
+ rotate: 0,
+ animate: ({
+ duration: 2500,
+ enabled: true
+ })
+ };
+
+ PluginChartCircular.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend(true, {}, PluginChartCircular.defaults, opts, {
+ wrapper: this.$el
+ });
+
+ return this;
+ },
+
+ build: function() {
+ var self = this,
+ $el = this.options.wrapper,
+ value = ($el.attr('data-percent') ? $el.attr('data-percent') : 0),
+ percentEl = $el.find('.percent'),
+ shouldAnimate,
+ data;
+
+ shouldAnimate = $.isFunction($.fn[ 'appear' ]) && ( typeof $.browser !== 'undefined' && !$.browser.mobile );
+ data = { accX: self.options.accX, accY: self.options.accY };
+
+ $.extend(true, self.options, {
+ onStep: function(from, to, currentValue) {
+ percentEl.html(parseInt(currentValue));
+ }
+ });
+
+ $el.attr('data-percent', (shouldAnimate ? 0 : value) );
+
+ $el.easyPieChart( this.options );
+
+ if ( shouldAnimate ) {
+ $el.appear(function() {
+ setTimeout(function() {
+ $el.data('easyPieChart').update(value);
+ $el.attr('data-percent', value);
+
+ }, self.options.delay);
+ }, data);
+ } else {
+ $el.data('easyPieChart').update(value);
+ $el.attr('data-percent', value);
+ }
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(true, theme, {
+ Chart: {
+ PluginChartCircular: PluginChartCircular
+ }
+ });
+
+ // jquery plugin
+ $.fn.themePluginChartCircular = function(opts) {
+ return this.map(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginChartCircular($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Lightbox
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__lightbox';
+
+ var PluginLightbox = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginLightbox.defaults = {
+ tClose: 'Close (Esc)', // Alt text on close button
+ tLoading: 'Loading...', // Text that is displayed during loading. Can contain %curr% and %total% keys
+ gallery: {
+ tPrev: 'Previous (Left arrow key)', // Alt text on left arrow
+ tNext: 'Next (Right arrow key)', // Alt text on right arrow
+ tCounter: '%curr% of %total%' // Markup for "1 of 7" counter
+ },
+ image: {
+ tError: 'The image could not be loaded.' // Error message when image could not be loaded
+ },
+ ajax: {
+ tError: 'The content could not be loaded.' // Error message when ajax request failed
+ }
+ };
+
+ PluginLightbox.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend(true, {}, PluginLightbox.defaults, opts, {
+ wrapper: this.$el
+ });
+
+ return this;
+ },
+
+ build: function() {
+ this.options.wrapper.magnificPopup(this.options);
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginLightbox: PluginLightbox
+ });
+
+ // jquery plugin
+ $.fn.themePluginLightbox = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginLightbox($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Portlets
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__portlet',
+ storageOrderKey = '__portletOrder',
+ storageStateKey = '__portletState';
+
+ var PluginPortlet = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginPortlet.defaults = {
+ connectWith: '[data-plugin-portlet]',
+ items: '[data-portlet-item]',
+ handle: '.portlet-handler',
+ opacity: 0.7,
+ placeholder: 'portlet-placeholder',
+ cancel: 'portlet-cancel',
+ forcePlaceholderSize: true,
+ forceHelperSize: true,
+ tolerance: 'pointer',
+ helper: 'original',
+ revert: 200
+ };
+
+ PluginPortlet.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ var _self = this;
+
+ this.options = $.extend(true, {}, PluginPortlet.defaults, opts, {
+ wrapper: this.$el,
+ update: _self.onUpdate,
+ create: _self.onLoad
+ });
+
+ return this;
+ },
+
+ onUpdate: function(event, ui) {
+ var key = storageOrderKey,
+ data = store.get(key),
+ $this = $(this),
+ porletId = $this.prop('id');
+
+ if (!data) {
+ data = {};
+ }
+
+ if (!!porletId) {
+ data[porletId] = $this.sortable('toArray');
+ store.set(key, data);
+ }
+ },
+
+ onLoad: function(event, ui) {
+ var key = storageOrderKey,
+ data = store.get(key),
+ $this = $(this),
+ porletId = $this.prop('id'),
+ portlet = $('#' + porletId);
+
+ if (!!data) {
+ var panels = data[porletId];
+
+ if (!!panels) {
+ $.each(panels, function(index, panelId) {
+ $('#' + panelId).appendTo(portlet);
+ });
+ }
+ }
+ },
+
+ saveState: function( panel ) {
+ var key = storageStateKey,
+ data = store.get(key),
+ panelId = panel.prop('id');
+
+ if (!data) {
+ data = {};
+ }
+
+ if (!panelId) {
+ return this;
+ }
+
+ var collapse = panel.find('.panel-actions').children('a.fa-caret-up, a.fa-caret-down'),
+ isCollapsed = !!collapse.hasClass('fa-caret-up'),
+ isRemoved = !panel.closest('body').get(0);
+
+ if (isRemoved) {
+ data[panelId] = 'removed';
+ } else if (isCollapsed) {
+ data[panelId] = 'collapsed';
+ } else {
+ delete data[panelId];
+ }
+
+ store.set(key, data);
+ return this;
+ },
+
+ loadState: function() {
+ var key = storageStateKey,
+ data = store.get(key);
+
+ if (!!data) {
+ $.each(data, function(panelId, state) {
+ var panel = $('#' + panelId);
+ if (!panel.data('portlet-state-loaded')) {
+ if (state == 'collapsed') {
+ panel.find('.panel-actions a.fa-caret-down').trigger('click');
+ } else if (state == 'removed') {
+ panel.find('.panel-actions a.fa-times').trigger('click');
+ }
+ panel.data('portlet-state-loaded', true);
+ }
+ });
+ }
+
+ return this;
+ },
+
+ build: function() {
+ var _self = this;
+
+ if ( $.isFunction( $.fn.sortable ) ) {
+ this.$el.sortable( this.options );
+ this.$el.find('[data-portlet-item]').each(function() {
+ _self.events( $(this) );
+ });
+ }
+
+ var portlet = this.$el;
+ portlet.css('min-height', 150);
+
+ return this;
+ },
+
+ events: function($el) {
+ var _self = this,
+ portlet = $el.closest('[data-plugin-portlet]');
+
+ this.loadState();
+
+ $el.find('.panel-actions').on( 'click', 'a.fa-caret-up, a.fa-caret-down, a.fa-times', function( e ) {
+ setTimeout(function() {
+ _self.saveState( $el );
+ }, 250);
+ });
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginPortlet: PluginPortlet
+ });
+
+ // jquery plugin
+ $.fn.themePluginPortlet = function(opts) {
+ return this.map(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginPortlet($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Slider
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__slider';
+
+ var PluginSlider = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginSlider.defaults = {
+
+ };
+
+ PluginSlider.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setVars()
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setVars: function() {
+ var $output = $( this.$el.data('plugin-slider-output') );
+ this.$output = $output.get(0) ? $output : null;
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ var _self = this;
+ this.options = $.extend( true, {}, PluginSlider.defaults, opts );
+
+ if ( this.$output ) {
+ $.extend( this.options, {
+ slide: function( event, ui ) {
+ _self.onSlide( event, ui );
+ }
+ });
+ }
+
+ return this;
+ },
+
+ build: function() {
+ this.$el.slider( this.options );
+
+ return this;
+ },
+
+ onSlide: function( event, ui ) {
+ if ( !ui.values ) {
+ this.$output.val( ui.value );
+ } else {
+ this.$output.val( ui.values[ 0 ] + '/' + ui.values[ 1 ] );
+ }
+
+ this.$output.trigger('change');
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginSlider: PluginSlider
+ });
+
+ // jquery plugin
+ $.fn.themePluginSlider = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginSlider($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Toggle
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__toggle';
+
+ var PluginToggle = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginToggle.defaults = {
+ duration: 350,
+ isAccordion: false,
+ addIcons: true
+ };
+
+ PluginToggle.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend(true, {}, PluginToggle.defaults, opts, {
+ wrapper: this.$el
+ });
+
+ return this;
+ },
+
+ build: function() {
+ var self = this,
+ $wrapper = this.options.wrapper,
+ $items = $wrapper.find('.toggle'),
+ $el = null;
+
+ $items.each(function() {
+ $el = $(this);
+
+ if(self.options.addIcons) {
+ $el.find('> label').prepend(
+ $('').addClass('fa fa-plus'),
+ $('').addClass('fa fa-minus')
+ );
+ }
+
+ if($el.hasClass('active')) {
+ $el.find('> p').addClass('preview-active');
+ $el.find('> .toggle-content').slideDown(self.options.duration);
+ }
+
+ self.events($el);
+ });
+
+ if(self.options.isAccordion) {
+ self.options.duration = self.options.duration/2;
+ }
+
+ return this;
+ },
+
+ events: function($el) {
+ var self = this,
+ previewParCurrentHeight = 0,
+ previewParAnimateHeight = 0,
+ toggleContent = null;
+
+ $el.find('> label').click(function(e) {
+
+ var $this = $(this),
+ parentSection = $this.parent(),
+ parentWrapper = $this.parents('.toggle'),
+ previewPar = null,
+ closeElement = null;
+
+ if(self.options.isAccordion && typeof(e.originalEvent) != 'undefined') {
+ closeElement = parentWrapper.find('.toggle.active > label');
+
+ if(closeElement[0] == $this[0]) {
+ return;
+ }
+ }
+
+ parentSection.toggleClass('active');
+
+ // Preview Paragraph
+ if(parentSection.find('> p').get(0)) {
+
+ previewPar = parentSection.find('> p');
+ previewParCurrentHeight = previewPar.css('height');
+ previewPar.css('height', 'auto');
+ previewParAnimateHeight = previewPar.css('height');
+ previewPar.css('height', previewParCurrentHeight);
+
+ }
+
+ // Content
+ toggleContent = parentSection.find('> .toggle-content');
+
+ if(parentSection.hasClass('active')) {
+
+ $(previewPar).animate({
+ height: previewParAnimateHeight
+ }, self.options.duration, function() {
+ $(this).addClass('preview-active');
+ });
+
+ toggleContent.slideDown(self.options.duration, function() {
+ if(closeElement) {
+ closeElement.trigger('click');
+ }
+ });
+
+ } else {
+
+ $(previewPar).animate({
+ height: 0
+ }, self.options.duration, function() {
+ $(this).removeClass('preview-active');
+ });
+
+ toggleContent.slideUp(self.options.duration);
+
+ }
+
+ });
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginToggle: PluginToggle
+ });
+
+ // jquery plugin
+ $.fn.themePluginToggle = function(opts) {
+ return this.map(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginToggle($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Widget - Todo
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__widgetTodoList';
+
+ var WidgetTodoList = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ WidgetTodoList.defaults = {
+ };
+
+ WidgetTodoList.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build()
+ .events();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, WidgetTodoList.defaults, opts );
+
+ return this;
+ },
+
+ check: function( input, label ) {
+ if ( input.is(':checked') ) {
+ label.addClass('line-through');
+ } else {
+ label.removeClass('line-through');
+ }
+ },
+
+ build: function() {
+ var _self = this,
+ $check = this.$el.find('.todo-check');
+
+ $check.each(function () {
+ var label = $(this).closest('li').find('.todo-label');
+ _self.check( $(this), label );
+ });
+
+ return this;
+ },
+
+ events: function() {
+ var _self = this,
+ $remove = this.$el.find( '.todo-remove' ),
+ $check = this.$el.find('.todo-check'),
+ $window = $( window );
+
+ $remove.on('click.widget-todo-list', function( ev ) {
+ ev.preventDefault();
+ $(this).closest("li").remove();
+ });
+
+ $check.on('change', function () {
+ var label = $(this).closest('li').find('.todo-label');
+ _self.check( $(this), label );
+ });
+
+ if ( $.isFunction( $.fn.sortable ) ) {
+ this.$el.sortable({
+ sort: function(event, ui) {
+ var top = event.pageY - _self.$el.offset().top - (ui.helper.outerHeight(true) / 2);
+ ui.helper.css({'top' : top + 'px'});
+ }
+ });
+ }
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ WidgetTodoList: WidgetTodoList
+ });
+
+ // jquery plugin
+ $.fn.themePluginWidgetTodoList = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new WidgetTodoList($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Widget - Toggle
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__widgetToggleExpand';
+
+ var WidgetToggleExpand = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ WidgetToggleExpand.defaults = {
+ };
+
+ WidgetToggleExpand.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build()
+ .events();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend( true, {}, WidgetToggleExpand.defaults, opts );
+
+ return this;
+ },
+
+ build: function() {
+ return this;
+ },
+
+ events: function() {
+ var _self = this,
+ $toggler = this.$el.find( '.widget-toggle' );
+
+ $toggler.on('click.widget-toggler', function() {
+ _self.$el.hasClass('widget-collapsed') ? _self.expand( _self.$el ) : _self.collapse( _self.$el );
+ });
+
+ return this;
+ },
+
+ expand: function( content ) {
+ content.children( '.widget-content-expanded' ).slideDown( 'fast', function() {
+ $(this).css( 'display', '' );
+ content.removeClass( 'widget-collapsed' );
+ });
+ },
+
+ collapse: function( content ) {
+ content.children('.widget-content-expanded' ).slideUp( 'fast', function() {
+ content.addClass( 'widget-collapsed' );
+ $(this).css( 'display', '' );
+ });
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ WidgetToggleExpand: WidgetToggleExpand
+ });
+
+ // jquery plugin
+ $.fn.themePluginWidgetToggleExpand = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new WidgetToggleExpand($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Word Rotate
+(function(theme, $) {
+
+ theme = theme || {};
+
+ var instanceName = '__wordRotate';
+
+ var PluginWordRotate = function($el, opts) {
+ return this.initialize($el, opts);
+ };
+
+ PluginWordRotate.defaults = {
+ delay: 2000
+ };
+
+ PluginWordRotate.prototype = {
+ initialize: function($el, opts) {
+ if ( $el.data( instanceName ) ) {
+ return this;
+ }
+
+ this.$el = $el;
+
+ this
+ .setData()
+ .setOptions(opts)
+ .build();
+
+ return this;
+ },
+
+ setData: function() {
+ this.$el.data(instanceName, this);
+
+ return this;
+ },
+
+ setOptions: function(opts) {
+ this.options = $.extend(true, {}, PluginWordRotate.defaults, opts, {
+ wrapper: this.$el
+ });
+
+ return this;
+ },
+
+ build: function() {
+ var $el = this.options.wrapper,
+ itemsWrapper = $el.find(".word-rotate-items"),
+ items = itemsWrapper.find("> span"),
+ firstItem = items.eq(0),
+ firstItemClone = firstItem.clone(),
+ itemHeight = firstItem.height(),
+ currentItem = 1,
+ currentTop = 0;
+
+ itemsWrapper.append(firstItemClone);
+
+ $el
+ .height(itemHeight)
+ .addClass("active");
+
+ setInterval(function() {
+
+ currentTop = (currentItem * itemHeight);
+
+ itemsWrapper.animate({
+ top: -(currentTop) + "px"
+ }, 300, function() {
+
+ currentItem++;
+
+ if(currentItem > items.length) {
+
+ itemsWrapper.css("top", 0);
+ currentItem = 1;
+
+ }
+
+ });
+
+ }, this.options.delay);
+
+ return this;
+ }
+ };
+
+ // expose to scope
+ $.extend(theme, {
+ PluginWordRotate: PluginWordRotate
+ });
+
+ // jquery plugin
+ $.fn.themePluginWordRotate = function(opts) {
+ return this.each(function() {
+ var $this = $(this);
+
+ if ($this.data(instanceName)) {
+ return $this.data(instanceName);
+ } else {
+ return new PluginWordRotate($this, opts);
+ }
+
+ });
+ }
+
+}).apply(this, [ window.theme, jQuery ]);
+
+// Data Tables - Config
+(function($) {
+
+ 'use strict';
+
+ // we overwrite initialize of all datatables here
+ // because we want to use select2, give search input a bootstrap look
+ // keep in mind if you overwrite this fnInitComplete somewhere,
+ // you should run the code inside this function to keep functionality.
+ //
+ // there's no better way to do this at this time :(
+ if ( $.isFunction( $.fn[ 'dataTable' ] ) ) {
+
+ $.extend(true, $.fn.dataTable.defaults, {
+ sDom: "<'row datatables-header form-inline'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>r><'table-responsive't><'row datatables-footer'<'col-sm-12 col-md-6'i><'col-sm-12 col-md-6'p>>",
+ oLanguage: {
+ sLengthMenu: '_MENU_ records per page',
+ sProcessing: ' Loading'
+ },
+ fnInitComplete: function( settings, json ) {
+ // select 2
+ if ( $.isFunction( $.fn[ 'select2' ] ) ) {
+ $('.dataTables_length select', settings.nTableWrapper).select2({
+ minimumResultsForSearch: -1
+ });
+ }
+
+ var options = $( 'table', settings.nTableWrapper ).data( 'plugin-options' ) || {};
+
+ // search
+ var $search = $('.dataTables_filter input', settings.nTableWrapper);
+
+ $search
+ .attr({
+ placeholder: typeof options.searchPlaceholder !== 'undefined' ? options.searchPlaceholder : 'Search'
+ })
+ .addClass('form-control');
+
+ if ( $.isFunction( $.fn.placeholder ) ) {
+ $search.placeholder();
+ }
+ }
+ });
+
+ }
+
+}).apply( this, [ jQuery ]);
+
+// Notifications - Config
+(function($) {
+
+ 'use strict';
+
+ // use font awesome icons if available
+ if ( typeof PNotify != 'undefined' ) {
+ PNotify.prototype.options.styling = "fontawesome";
+
+ $.extend(true, PNotify.prototype.options, {
+ shadow: false,
+ stack: {
+ spacing1: 15,
+ spacing2: 15
+ }
+ });
+
+ $.extend(PNotify.styling.fontawesome, {
+ // classes
+ container: "notification",
+ notice: "notification-warning",
+ info: "notification-info",
+ success: "notification-success",
+ error: "notification-danger",
+
+ // icons
+ notice_icon: "fa fa-exclamation",
+ info_icon: "fa fa-info",
+ success_icon: "fa fa-check",
+ error_icon: "fa fa-times"
+ });
+ }
+
+}).apply(this, [jQuery]);
\ No newline at end of file
diff --git a/code/haitiwater/static-common/vendor/modernizr/modernizr.js b/code/haitiwater/static-common/vendor/modernizr/modernizr.js
new file mode 100644
index 0000000..87669ad
--- /dev/null
+++ b/code/haitiwater/static-common/vendor/modernizr/modernizr.js
@@ -0,0 +1,480 @@
+/* Modernizr 2.8.3 (Custom Build) | MIT & BSD
+ * Build: http://modernizr.com/download/#-flexbox-flexboxlegacy-csstransforms-csstransforms3d-shiv-cssclasses-teststyles-testprop-testallprops-prefixes-domprefixes-css_overflow_scrolling-load
+ */
+;
+
+
+
+window.Modernizr = (function( window, document, undefined ) {
+
+ var version = '2.8.3',
+
+ Modernizr = {},
+
+ enableClasses = true,
+
+ docElement = document.documentElement,
+
+ mod = 'modernizr',
+ modElem = document.createElement(mod),
+ mStyle = modElem.style,
+
+ inputElem ,
+
+
+ toString = {}.toString,
+
+ prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),
+
+
+
+ omPrefixes = 'Webkit Moz O ms',
+
+ cssomPrefixes = omPrefixes.split(' '),
+
+ domPrefixes = omPrefixes.toLowerCase().split(' '),
+
+
+ tests = {},
+ inputs = {},
+ attrs = {},
+
+ classes = [],
+
+ slice = classes.slice,
+
+ featureName,
+
+
+ injectElementWithStyles = function( rule, callback, nodes, testnames ) {
+
+ var style, ret, node, docOverflow,
+ div = document.createElement('div'),
+ body = document.body,
+ fakeBody = body || document.createElement('body');
+
+ if ( parseInt(nodes, 10) ) {
+ while ( nodes-- ) {
+ node = document.createElement('div');
+ node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
+ div.appendChild(node);
+ }
+ }
+
+ style = ['',''].join('');
+ div.id = mod;
+ (body ? div : fakeBody).innerHTML += style;
+ fakeBody.appendChild(div);
+ if ( !body ) {
+ fakeBody.style.background = '';
+ fakeBody.style.overflow = 'hidden';
+ docOverflow = docElement.style.overflow;
+ docElement.style.overflow = 'hidden';
+ docElement.appendChild(fakeBody);
+ }
+
+ ret = callback(div, rule);
+ if ( !body ) {
+ fakeBody.parentNode.removeChild(fakeBody);
+ docElement.style.overflow = docOverflow;
+ } else {
+ div.parentNode.removeChild(div);
+ }
+
+ return !!ret;
+
+ },
+ _hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;
+
+ if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
+ hasOwnProp = function (object, property) {
+ return _hasOwnProperty.call(object, property);
+ };
+ }
+ else {
+ hasOwnProp = function (object, property) {
+ return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
+ };
+ }
+
+
+ if (!Function.prototype.bind) {
+ Function.prototype.bind = function bind(that) {
+
+ var target = this;
+
+ if (typeof target != "function") {
+ throw new TypeError();
+ }
+
+ var args = slice.call(arguments, 1),
+ bound = function () {
+
+ if (this instanceof bound) {
+
+ var F = function(){};
+ F.prototype = target.prototype;
+ var self = new F();
+
+ var result = target.apply(
+ self,
+ args.concat(slice.call(arguments))
+ );
+ if (Object(result) === result) {
+ return result;
+ }
+ return self;
+
+ } else {
+
+ return target.apply(
+ that,
+ args.concat(slice.call(arguments))
+ );
+
+ }
+
+ };
+
+ return bound;
+ };
+ }
+
+ function setCss( str ) {
+ mStyle.cssText = str;
+ }
+
+ function setCssAll( str1, str2 ) {
+ return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
+ }
+
+ function is( obj, type ) {
+ return typeof obj === type;
+ }
+
+ function contains( str, substr ) {
+ return !!~('' + str).indexOf(substr);
+ }
+
+ function testProps( props, prefixed ) {
+ for ( var i in props ) {
+ var prop = props[i];
+ if ( !contains(prop, "-") && mStyle[prop] !== undefined ) {
+ return prefixed == 'pfx' ? prop : true;
+ }
+ }
+ return false;
+ }
+
+ function testDOMProps( props, obj, elem ) {
+ for ( var i in props ) {
+ var item = obj[props[i]];
+ if ( item !== undefined) {
+
+ if (elem === false) return props[i];
+
+ if (is(item, 'function')){
+ return item.bind(elem || obj);
+ }
+
+ return item;
+ }
+ }
+ return false;
+ }
+
+ function testPropsAll( prop, prefixed, elem ) {
+
+ var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
+ props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
+
+ if(is(prefixed, "string") || is(prefixed, "undefined")) {
+ return testProps(props, prefixed);
+
+ } else {
+ props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
+ return testDOMProps(props, prefixed, elem);
+ }
+ } tests['flexbox'] = function() {
+ return testPropsAll('flexWrap');
+ };
+
+
+ tests['flexboxlegacy'] = function() {
+ return testPropsAll('boxDirection');
+ };
+
+ tests['csstransforms'] = function() {
+ return !!testPropsAll('transform');
+ };
+
+
+ tests['csstransforms3d'] = function() {
+
+ var ret = !!testPropsAll('perspective');
+
+ if ( ret && 'webkitPerspective' in docElement.style ) {
+
+ injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) {
+ ret = node.offsetLeft === 9 && node.offsetHeight === 3;
+ });
+ }
+ return ret;
+ };
+ for ( var feature in tests ) {
+ if ( hasOwnProp(tests, feature) ) {
+ featureName = feature.toLowerCase();
+ Modernizr[featureName] = tests[feature]();
+
+ classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
+ }
+ }
+
+
+
+ Modernizr.addTest = function ( feature, test ) {
+ if ( typeof feature == 'object' ) {
+ for ( var key in feature ) {
+ if ( hasOwnProp( feature, key ) ) {
+ Modernizr.addTest( key, feature[ key ] );
+ }
+ }
+ } else {
+
+ feature = feature.toLowerCase();
+
+ if ( Modernizr[feature] !== undefined ) {
+ return Modernizr;
+ }
+
+ test = typeof test == 'function' ? test() : test;
+
+ if (typeof enableClasses !== "undefined" && enableClasses) {
+ docElement.className += ' ' + (test ? '' : 'no-') + feature;
+ }
+ Modernizr[feature] = test;
+
+ }
+
+ return Modernizr;
+ };
+
+
+ setCss('');
+ modElem = inputElem = null;
+
+ ;(function(window, document) {
+ var version = '3.7.0';
+
+ var options = window.html5 || {};
+
+ var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
+
+ var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;
+
+ var supportsHtml5Styles;
+
+ var expando = '_html5shiv';
+
+ var expanID = 0;
+
+ var expandoData = {};
+
+ var supportsUnknownElements;
+
+ (function() {
+ try {
+ var a = document.createElement('a');
+ a.innerHTML = '';
+ supportsHtml5Styles = ('hidden' in a);
+
+ supportsUnknownElements = a.childNodes.length == 1 || (function() {
+ (document.createElement)('a');
+ var frag = document.createDocumentFragment();
+ return (
+ typeof frag.cloneNode == 'undefined' ||
+ typeof frag.createDocumentFragment == 'undefined' ||
+ typeof frag.createElement == 'undefined'
+ );
+ }());
+ } catch(e) {
+ supportsHtml5Styles = true;
+ supportsUnknownElements = true;
+ }
+
+ }());
+
+ function addStyleSheet(ownerDocument, cssText) {
+ var p = ownerDocument.createElement('p'),
+ parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
+
+ p.innerHTML = 'x';
+ return parent.insertBefore(p.lastChild, parent.firstChild);
+ }
+
+ function getElements() {
+ var elements = html5.elements;
+ return typeof elements == 'string' ? elements.split(' ') : elements;
+ }
+
+ function getExpandoData(ownerDocument) {
+ var data = expandoData[ownerDocument[expando]];
+ if (!data) {
+ data = {};
+ expanID++;
+ ownerDocument[expando] = expanID;
+ expandoData[expanID] = data;
+ }
+ return data;
+ }
+
+ function createElement(nodeName, ownerDocument, data){
+ if (!ownerDocument) {
+ ownerDocument = document;
+ }
+ if(supportsUnknownElements){
+ return ownerDocument.createElement(nodeName);
+ }
+ if (!data) {
+ data = getExpandoData(ownerDocument);
+ }
+ var node;
+
+ if (data.cache[nodeName]) {
+ node = data.cache[nodeName].cloneNode();
+ } else if (saveClones.test(nodeName)) {
+ node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
+ } else {
+ node = data.createElem(nodeName);
+ }
+
+ return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
+ }
+
+ function createDocumentFragment(ownerDocument, data){
+ if (!ownerDocument) {
+ ownerDocument = document;
+ }
+ if(supportsUnknownElements){
+ return ownerDocument.createDocumentFragment();
+ }
+ data = data || getExpandoData(ownerDocument);
+ var clone = data.frag.cloneNode(),
+ i = 0,
+ elems = getElements(),
+ l = elems.length;
+ for(;i= 1.7 recommended, but it'll probably work with
+ older versions)
+- [Raphael.js](http://raphaeljs.com/) (>= 2.0)
+
+## Usage
+
+See [the website](http://morrisjs.github.com/morris.js/).
+
+## Development
+
+Very daring.
+
+Fork, hack, possibly even add some tests, then send a pull request :)
+
+Remember that Morris.js is a coffeescript project. Please make your changes in
+the `.coffee` files, not in the compiled javascript files in the root directory
+of the project.
+
+### Developer quick-start
+
+You'll need [node.js](https://nodejs.org). I recommend using
+[nvm](https://github.com/creationix/nvm) for installing node in
+development environments.
+
+With node installed, install [grunt](https://github.com/cowboy/grunt) using
+`npm install -g grunt-cli`, and then the rest of the test/build dependencies
+with `npm install` in the morris.js project folder.
+
+Once you're all set up, you can compile, minify and run the tests using `grunt`.
+
+Note: I'm experimenting with using perceptual diffs to catch rendering
+regressions. Due to font rendering differences between platforms, the pdiff
+tests currently *only* pass on OS X.
+
+## Changelog
+
+### 0.5.1 - 15th June 2014
+
+- Fix touch event handling.
+- Fix stacked=false in bar chart [#275](https://github.com/morrisjs/morris.js/issues/275)
+- Configurable vertical segments [#297](https://github.com/morrisjs/morris.js/issues/297)
+- Deprecate continuousLine option.
+
+### 0.5.0 - 19th March 2014
+
+- Update grunt dependency [#288](https://github.com/morrisjs/morris.js/issues/228)
+- Donut segment color config in data objects [#281](https://github.com/morrisjs/morris.js/issues/281)
+- Customisable line widths and point drawing [#272](https://github.com/morrisjs/morris.js/issues/272)
+- Bugfix for @options.smooth [#266](https://github.com/morrisjs/morris.js/issues/266)
+- Option to disable axes individually [#253](https://github.com/morrisjs/morris.js/issues/253)
+- Range selection [#252](https://github.com/morrisjs/morris.js/issues/252)
+- Week format for x-labels [#250](https://github.com/morrisjs/morris.js/issues/250)
+- Update developer quickstart instructions [#243](https://github.com/morrisjs/morris.js/issues/243)
+- Experimenting with perceptual diffs.
+- Add original data row to hover callback [#264](https://github.com/morrisjs/morris.js/issues/264)
+- setData method for donut charts [#211](https://github.com/morrisjs/morris.js/issues/211)
+- Automatic resizing [#111](https://github.com/morrisjs/morris.js/issues/111)
+- Fix travis builds [#298](https://github.com/morrisjs/morris.js/issues/298)
+- Option for rounded corners on bar charts [#305](https://github.com/morrisjs/morris.js/issues/305)
+- Option to set padding for X axis labels [#306](https://github.com/morrisjs/morris.js/issues/306)
+- Use local javascript for examples.
+- Events on non-time series [#314](https://github.com/morrisjs/morris.js/issues/314)
+
+### 0.4.3 - 12th May 2013
+
+- Fix flickering hover box [#186](https://github.com/morrisjs/morris.js/issues/186)
+- xLabelAngle option (diagonal labels!!) [#239](https://github.com/morrisjs/morris.js/issues/239)
+- Fix area chart fill bug [#190](https://github.com/morrisjs/morris.js/issues/190)
+- Make event handlers chainable
+- gridTextFamily and gridTextWeight options
+- Fix hovers with setData [#213](https://github.com/morrisjs/morris.js/issues/213)
+- Fix hideHover behaviour [#236](https://github.com/morrisjs/morris.js/issues/236)
+
+### 0.4.2 - 14th April 2013
+
+- Fix DST handling [#191](https://github.com/morrisjs/morris.js/issues/191)
+- Parse data values from strings in Morris.Donut [#189](https://github.com/morrisjs/morris.js/issues/189)
+- Non-cumulative area charts [#199](https://github.com/morrisjs/morris.js/issues/199)
+- Round Y-axis labels to significant numbers [#162](https://github.com/morrisjs/morris.js/162)
+- Customising default hover content [#179](https://github.com/morrisjs/morris.js/179)
+
+### 0.4.1 - 8th February 2013
+
+- Fix goal and event rendering. [#181](https://github.com/morrisjs/morris.js/issues/181)
+- Don't break when empty data is passed to setData [#142](https://github.com/morrisjs/morris.js/issues/142)
+- labelColor option for donuts [#159](https://github.com/morrisjs/morris.js/issues/159)
+
+### 0.4.0 - 26th January 2013
+
+- Goals and events [#103](https://github.com/morrisjs/morris.js/issues/103).
+- Bower package manager metadata.
+- More flexible formatters [#107](https://github.com/morrisjs/morris.js/issues/107).
+- Color callbacks.
+- Decade intervals for time-axis labels.
+- Non-continous line tweaks [#116](https://github.com/morrisjs/morris.js/issues/116).
+- Stacked bars [#120](https://github.com/morrisjs/morris.js/issues/120).
+- HTML hover [#134](https://github.com/morrisjs/morris.js/issues/134).
+- yLabelFormat [#139](https://github.com/morrisjs/morris.js/issues/139).
+- Disable axes [#114](https://github.com/morrisjs/morris.js/issues/114).
+
+### 0.3.3 - 1st November 2012
+
+- **Bar charts!** [#101](https://github.com/morrisjs/morris.js/issues/101).
+
+### 0.3.2 - 28th October 2012
+
+- **Area charts!** [#47](https://github.com/morrisjs/morris.js/issues/47).
+- Some major refactoring and test suite improvements.
+- Set smooth parameter per series [#91](https://github.com/morrisjs/morris.js/issues/91).
+- Custom dateFormat for string x-values [#90](https://github.com/morrisjs/morris.js/issues/90).
+
+### 0.3.1 - 13th October 2012
+
+- Add `formatter` option for customising value labels in donuts [#75](https://github.com/morrisjs/morris.js/issues/75).
+- Cycle `lineColors` on line charts to avoid running out of colours [#78](https://github.com/morrisjs/morris.js/issues/78).
+- Add method to select donut segments. [#79](https://github.com/morrisjs/morris.js/issues/79).
+- Don't go negative on yMin when all y values are zero. [#80](https://github.com/morrisjs/morris.js/issues/80).
+- Don't sort data when parseTime is false [#83](https://github.com/morrisjs/morris.js/issues/83).
+- Customise styling for points. [#87](https://github.com/morrisjs/morris.js/issues/87).
+
+### 0.3.0 - 15th September 2012
+
+- Donut charts!
+- Bugfix: ymin/ymax bug [#71](https://github.com/morrisjs/morris.js/issues/71).
+- Bugfix: infinite loop when data indicates horizontal line [#66](https://github.com/morrisjs/morris.js/issues/66).
+
+### 0.2.10 - 26th June 2012
+
+- Support for decimal labels on y-axis [#58](https://github.com/morrisjs/morris.js/issues/58).
+- Better axis label clipping [#63](https://github.com/morrisjs/morris.js/issues/63).
+- Redraw graphs with updated data using `setData` method [#64](https://github.com/morrisjs/morris.js/issues/64).
+- Bugfix: series with zero or one non-null values [#65](https://github.com/morrisjs/morris.js/issues/65).
+
+### 0.2.9 - 15th May 2012
+
+- Bugfix: Fix zero-value regression
+- Bugfix: Don't modify user-supplied data
+
+### 0.2.8 - 10th May 2012
+
+- Customising x-axis labels with `xLabelFormat` option
+- Only use timezones when timezone info is specified
+- Fix old IE bugs (mostly in examples!)
+- Added `preunits` and `postunits` options
+- Better non-continuous series data support
+
+### 0.2.7 - 2nd April 2012
+
+- Added `xLabels` option
+- Refactored x-axis labelling
+- Better ISO date support
+- Fix bug with single value in non time-series graphs
+
+### 0.2.6 - 18th March 2012
+
+- Partial series support (see `null` y-values in `examples/quarters.html`)
+- `parseTime` option bugfix for non-time-series data
+
+### 0.2.5 - 15th March 2012
+
+- Raw millisecond timestamp support (with `dateFormat` option)
+- YYYY-MM-DD HH:MM[:SS[.SSS]] date support
+- Decimal number labels
+
+### 0.2.4 - 8th March 2012
+
+- Negative y-values support
+- `ymin` option
+- `units` options
+
+### 0.2.3 - 6th Mar 2012
+
+- jQuery no-conflict compatibility
+- Support ISO week-number dates
+- Optionally hide hover on mouseout (`hideHover`)
+- Optionally skip parsing dates, treating X values as an equally-spaced series (`parseTime`)
+
+### 0.2.2 - 29th Feb 2012
+
+- Bugfix: mouseover error when options.data.length == 2
+- Automatically sort options.data
+
+### 0.2.1 - 28th Feb 2012
+
+- Accept a DOM element *or* an ID in `options.element`
+- Add `smooth` option
+- Bugfix: clone `@default`
+- Add `ymax` option
+
+## License
+
+Copyright (c) 2012-2014, Olly Smith
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/code/haitiwater/static-common/vendor/morris/morris.css b/code/haitiwater/static-common/vendor/morris/morris.css
new file mode 100644
index 0000000..209f091
--- /dev/null
+++ b/code/haitiwater/static-common/vendor/morris/morris.css
@@ -0,0 +1,2 @@
+.morris-hover{position:absolute;z-index:1000}.morris-hover.morris-default-style{border-radius:10px;padding:6px;color:#666;background:rgba(255,255,255,0.8);border:solid 2px rgba(230,230,230,0.8);font-family:sans-serif;font-size:12px;text-align:center}.morris-hover.morris-default-style .morris-hover-row-label{font-weight:bold;margin:0.25em 0}
+.morris-hover.morris-default-style .morris-hover-point{white-space:nowrap;margin:0.1em 0}
diff --git a/code/haitiwater/static-common/vendor/morris/morris.js b/code/haitiwater/static-common/vendor/morris/morris.js
new file mode 100644
index 0000000..3a1a830
--- /dev/null
+++ b/code/haitiwater/static-common/vendor/morris/morris.js
@@ -0,0 +1,1892 @@
+/* @license
+morris.js v0.5.0
+Copyright 2014 Olly Smith All rights reserved.
+Licensed under the BSD-2-Clause License.
+*/
+
+
+(function() {
+ var $, Morris, minutesSpecHelper, secondsSpecHelper,
+ __slice = [].slice,
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+ Morris = window.Morris = {};
+
+ $ = jQuery;
+
+ Morris.EventEmitter = (function() {
+ function EventEmitter() {}
+
+ EventEmitter.prototype.on = function(name, handler) {
+ if (this.handlers == null) {
+ this.handlers = {};
+ }
+ if (this.handlers[name] == null) {
+ this.handlers[name] = [];
+ }
+ this.handlers[name].push(handler);
+ return this;
+ };
+
+ EventEmitter.prototype.fire = function() {
+ var args, handler, name, _i, _len, _ref, _results;
+ name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ if ((this.handlers != null) && (this.handlers[name] != null)) {
+ _ref = this.handlers[name];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ handler = _ref[_i];
+ _results.push(handler.apply(null, args));
+ }
+ return _results;
+ }
+ };
+
+ return EventEmitter;
+
+ })();
+
+ Morris.commas = function(num) {
+ var absnum, intnum, ret, strabsnum;
+ if (num != null) {
+ ret = num < 0 ? "-" : "";
+ absnum = Math.abs(num);
+ intnum = Math.floor(absnum).toFixed(0);
+ ret += intnum.replace(/(?=(?:\d{3})+$)(?!^)/g, ',');
+ strabsnum = absnum.toString();
+ if (strabsnum.length > intnum.length) {
+ ret += strabsnum.slice(intnum.length);
+ }
+ return ret;
+ } else {
+ return '-';
+ }
+ };
+
+ Morris.pad2 = function(number) {
+ return (number < 10 ? '0' : '') + number;
+ };
+
+ Morris.Grid = (function(_super) {
+ __extends(Grid, _super);
+
+ function Grid(options) {
+ this.resizeHandler = __bind(this.resizeHandler, this);
+ var _this = this;
+ if (typeof options.element === 'string') {
+ this.el = $(document.getElementById(options.element));
+ } else {
+ this.el = $(options.element);
+ }
+ if ((this.el == null) || this.el.length === 0) {
+ throw new Error("Graph container element not found");
+ }
+ if (this.el.css('position') === 'static') {
+ this.el.css('position', 'relative');
+ }
+ this.options = $.extend({}, this.gridDefaults, this.defaults || {}, options);
+ if (typeof this.options.units === 'string') {
+ this.options.postUnits = options.units;
+ }
+ this.raphael = new Raphael(this.el[0]);
+ this.elementWidth = null;
+ this.elementHeight = null;
+ this.dirty = false;
+ this.selectFrom = null;
+ if (this.init) {
+ this.init();
+ }
+ this.setData(this.options.data);
+ this.el.bind('mousemove', function(evt) {
+ var left, offset, right, width, x;
+ offset = _this.el.offset();
+ x = evt.pageX - offset.left;
+ if (_this.selectFrom) {
+ left = _this.data[_this.hitTest(Math.min(x, _this.selectFrom))]._x;
+ right = _this.data[_this.hitTest(Math.max(x, _this.selectFrom))]._x;
+ width = right - left;
+ return _this.selectionRect.attr({
+ x: left,
+ width: width
+ });
+ } else {
+ return _this.fire('hovermove', x, evt.pageY - offset.top);
+ }
+ });
+ this.el.bind('mouseleave', function(evt) {
+ if (_this.selectFrom) {
+ _this.selectionRect.hide();
+ _this.selectFrom = null;
+ }
+ return _this.fire('hoverout');
+ });
+ this.el.bind('touchstart touchmove touchend', function(evt) {
+ var offset, touch;
+ touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0];
+ offset = _this.el.offset();
+ return _this.fire('hovermove', touch.pageX - offset.left, touch.pageY - offset.top);
+ });
+ this.el.bind('click', function(evt) {
+ var offset;
+ offset = _this.el.offset();
+ return _this.fire('gridclick', evt.pageX - offset.left, evt.pageY - offset.top);
+ });
+ if (this.options.rangeSelect) {
+ this.selectionRect = this.raphael.rect(0, 0, 0, this.el.innerHeight()).attr({
+ fill: this.options.rangeSelectColor,
+ stroke: false
+ }).toBack().hide();
+ this.el.bind('mousedown', function(evt) {
+ var offset;
+ offset = _this.el.offset();
+ return _this.startRange(evt.pageX - offset.left);
+ });
+ this.el.bind('mouseup', function(evt) {
+ var offset;
+ offset = _this.el.offset();
+ _this.endRange(evt.pageX - offset.left);
+ return _this.fire('hovermove', evt.pageX - offset.left, evt.pageY - offset.top);
+ });
+ }
+ if (this.options.resize) {
+ $(window).bind('resize', function(evt) {
+ if (_this.timeoutId != null) {
+ window.clearTimeout(_this.timeoutId);
+ }
+ return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100);
+ });
+ }
+ this.el.css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)');
+ if (this.postInit) {
+ this.postInit();
+ }
+ }
+
+ Grid.prototype.gridDefaults = {
+ dateFormat: null,
+ axes: true,
+ grid: true,
+ gridLineColor: '#aaa',
+ gridStrokeWidth: 0.5,
+ gridTextColor: '#888',
+ gridTextSize: 12,
+ gridTextFamily: 'sans-serif',
+ gridTextWeight: 'normal',
+ hideHover: false,
+ yLabelFormat: null,
+ xLabelAngle: 0,
+ numLines: 5,
+ padding: 25,
+ parseTime: true,
+ postUnits: '',
+ preUnits: '',
+ ymax: 'auto',
+ ymin: 'auto 0',
+ goals: [],
+ goalStrokeWidth: 1.0,
+ goalLineColors: ['#666633', '#999966', '#cc6666', '#663333'],
+ events: [],
+ eventStrokeWidth: 1.0,
+ eventLineColors: ['#005a04', '#ccffbb', '#3a5f0b', '#005502'],
+ rangeSelect: null,
+ rangeSelectColor: '#eef',
+ resize: false
+ };
+
+ Grid.prototype.setData = function(data, redraw) {
+ var e, idx, index, maxGoal, minGoal, ret, row, step, total, y, ykey, ymax, ymin, yval, _ref;
+ if (redraw == null) {
+ redraw = true;
+ }
+ this.options.data = data;
+ if ((data == null) || data.length === 0) {
+ this.data = [];
+ this.raphael.clear();
+ if (this.hover != null) {
+ this.hover.hide();
+ }
+ return;
+ }
+ ymax = this.cumulative ? 0 : null;
+ ymin = this.cumulative ? 0 : null;
+ if (this.options.goals.length > 0) {
+ minGoal = Math.min.apply(Math, this.options.goals);
+ maxGoal = Math.max.apply(Math, this.options.goals);
+ ymin = ymin != null ? Math.min(ymin, minGoal) : minGoal;
+ ymax = ymax != null ? Math.max(ymax, maxGoal) : maxGoal;
+ }
+ this.data = (function() {
+ var _i, _len, _results;
+ _results = [];
+ for (index = _i = 0, _len = data.length; _i < _len; index = ++_i) {
+ row = data[index];
+ ret = {
+ src: row
+ };
+ ret.label = row[this.options.xkey];
+ if (this.options.parseTime) {
+ ret.x = Morris.parseDate(ret.label);
+ if (this.options.dateFormat) {
+ ret.label = this.options.dateFormat(ret.x);
+ } else if (typeof ret.label === 'number') {
+ ret.label = new Date(ret.label).toString();
+ }
+ } else {
+ ret.x = index;
+ if (this.options.xLabelFormat) {
+ ret.label = this.options.xLabelFormat(ret);
+ }
+ }
+ total = 0;
+ ret.y = (function() {
+ var _j, _len1, _ref, _results1;
+ _ref = this.options.ykeys;
+ _results1 = [];
+ for (idx = _j = 0, _len1 = _ref.length; _j < _len1; idx = ++_j) {
+ ykey = _ref[idx];
+ yval = row[ykey];
+ if (typeof yval === 'string') {
+ yval = parseFloat(yval);
+ }
+ if ((yval != null) && typeof yval !== 'number') {
+ yval = null;
+ }
+ if (yval != null) {
+ if (this.cumulative) {
+ total += yval;
+ } else {
+ if (ymax != null) {
+ ymax = Math.max(yval, ymax);
+ ymin = Math.min(yval, ymin);
+ } else {
+ ymax = ymin = yval;
+ }
+ }
+ }
+ if (this.cumulative && (total != null)) {
+ ymax = Math.max(total, ymax);
+ ymin = Math.min(total, ymin);
+ }
+ _results1.push(yval);
+ }
+ return _results1;
+ }).call(this);
+ _results.push(ret);
+ }
+ return _results;
+ }).call(this);
+ if (this.options.parseTime) {
+ this.data = this.data.sort(function(a, b) {
+ return (a.x > b.x) - (b.x > a.x);
+ });
+ }
+ this.xmin = this.data[0].x;
+ this.xmax = this.data[this.data.length - 1].x;
+ this.events = [];
+ if (this.options.events.length > 0) {
+ if (this.options.parseTime) {
+ this.events = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.options.events;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ e = _ref[_i];
+ _results.push(Morris.parseDate(e));
+ }
+ return _results;
+ }).call(this);
+ } else {
+ this.events = this.options.events;
+ }
+ this.xmax = Math.max(this.xmax, Math.max.apply(Math, this.events));
+ this.xmin = Math.min(this.xmin, Math.min.apply(Math, this.events));
+ }
+ if (this.xmin === this.xmax) {
+ this.xmin -= 1;
+ this.xmax += 1;
+ }
+ this.ymin = this.yboundary('min', ymin);
+ this.ymax = this.yboundary('max', ymax);
+ if (this.ymin === this.ymax) {
+ if (ymin) {
+ this.ymin -= 1;
+ }
+ this.ymax += 1;
+ }
+ if (((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'y') || this.options.grid === true) {
+ if (this.options.ymax === this.gridDefaults.ymax && this.options.ymin === this.gridDefaults.ymin) {
+ this.grid = this.autoGridLines(this.ymin, this.ymax, this.options.numLines);
+ this.ymin = Math.min(this.ymin, this.grid[0]);
+ this.ymax = Math.max(this.ymax, this.grid[this.grid.length - 1]);
+ } else {
+ step = (this.ymax - this.ymin) / (this.options.numLines - 1);
+ this.grid = (function() {
+ var _i, _ref1, _ref2, _results;
+ _results = [];
+ for (y = _i = _ref1 = this.ymin, _ref2 = this.ymax; step > 0 ? _i <= _ref2 : _i >= _ref2; y = _i += step) {
+ _results.push(y);
+ }
+ return _results;
+ }).call(this);
+ }
+ }
+ this.dirty = true;
+ if (redraw) {
+ return this.redraw();
+ }
+ };
+
+ Grid.prototype.yboundary = function(boundaryType, currentValue) {
+ var boundaryOption, suggestedValue;
+ boundaryOption = this.options["y" + boundaryType];
+ if (typeof boundaryOption === 'string') {
+ if (boundaryOption.slice(0, 4) === 'auto') {
+ if (boundaryOption.length > 5) {
+ suggestedValue = parseInt(boundaryOption.slice(5), 10);
+ if (currentValue == null) {
+ return suggestedValue;
+ }
+ return Math[boundaryType](currentValue, suggestedValue);
+ } else {
+ if (currentValue != null) {
+ return currentValue;
+ } else {
+ return 0;
+ }
+ }
+ } else {
+ return parseInt(boundaryOption, 10);
+ }
+ } else {
+ return boundaryOption;
+ }
+ };
+
+ Grid.prototype.autoGridLines = function(ymin, ymax, nlines) {
+ var gmax, gmin, grid, smag, span, step, unit, y, ymag;
+ span = ymax - ymin;
+ ymag = Math.floor(Math.log(span) / Math.log(10));
+ unit = Math.pow(10, ymag);
+ gmin = Math.floor(ymin / unit) * unit;
+ gmax = Math.ceil(ymax / unit) * unit;
+ step = (gmax - gmin) / (nlines - 1);
+ if (unit === 1 && step > 1 && Math.ceil(step) !== step) {
+ step = Math.ceil(step);
+ gmax = gmin + step * (nlines - 1);
+ }
+ if (gmin < 0 && gmax > 0) {
+ gmin = Math.floor(ymin / step) * step;
+ gmax = Math.ceil(ymax / step) * step;
+ }
+ if (step < 1) {
+ smag = Math.floor(Math.log(step) / Math.log(10));
+ grid = (function() {
+ var _i, _results;
+ _results = [];
+ for (y = _i = gmin; step > 0 ? _i <= gmax : _i >= gmax; y = _i += step) {
+ _results.push(parseFloat(y.toFixed(1 - smag)));
+ }
+ return _results;
+ })();
+ } else {
+ grid = (function() {
+ var _i, _results;
+ _results = [];
+ for (y = _i = gmin; step > 0 ? _i <= gmax : _i >= gmax; y = _i += step) {
+ _results.push(y);
+ }
+ return _results;
+ })();
+ }
+ return grid;
+ };
+
+ Grid.prototype._calc = function() {
+ var bottomOffsets, gridLine, h, i, w, yLabelWidths, _ref, _ref1;
+ w = this.el.width();
+ h = this.el.height();
+ if (this.elementWidth !== w || this.elementHeight !== h || this.dirty) {
+ this.elementWidth = w;
+ this.elementHeight = h;
+ this.dirty = false;
+ this.left = this.options.padding;
+ this.right = this.elementWidth - this.options.padding;
+ this.top = this.options.padding;
+ this.bottom = this.elementHeight - this.options.padding;
+ if ((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'y') {
+ yLabelWidths = (function() {
+ var _i, _len, _ref1, _results;
+ _ref1 = this.grid;
+ _results = [];
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ gridLine = _ref1[_i];
+ _results.push(this.measureText(this.yAxisFormat(gridLine)).width);
+ }
+ return _results;
+ }).call(this);
+ this.left += Math.max.apply(Math, yLabelWidths);
+ }
+ if ((_ref1 = this.options.axes) === true || _ref1 === 'both' || _ref1 === 'x') {
+ bottomOffsets = (function() {
+ var _i, _ref2, _results;
+ _results = [];
+ for (i = _i = 0, _ref2 = this.data.length; 0 <= _ref2 ? _i < _ref2 : _i > _ref2; i = 0 <= _ref2 ? ++_i : --_i) {
+ _results.push(this.measureText(this.data[i].text, -this.options.xLabelAngle).height);
+ }
+ return _results;
+ }).call(this);
+ this.bottom -= Math.max.apply(Math, bottomOffsets);
+ }
+ this.width = Math.max(1, this.right - this.left);
+ this.height = Math.max(1, this.bottom - this.top);
+ this.dx = this.width / (this.xmax - this.xmin);
+ this.dy = this.height / (this.ymax - this.ymin);
+ if (this.calc) {
+ return this.calc();
+ }
+ }
+ };
+
+ Grid.prototype.transY = function(y) {
+ return this.bottom - (y - this.ymin) * this.dy;
+ };
+
+ Grid.prototype.transX = function(x) {
+ if (this.data.length === 1) {
+ return (this.left + this.right) / 2;
+ } else {
+ return this.left + (x - this.xmin) * this.dx;
+ }
+ };
+
+ Grid.prototype.redraw = function() {
+ this.raphael.clear();
+ this._calc();
+ this.drawGrid();
+ this.drawGoals();
+ this.drawEvents();
+ if (this.draw) {
+ return this.draw();
+ }
+ };
+
+ Grid.prototype.measureText = function(text, angle) {
+ var ret, tt;
+ if (angle == null) {
+ angle = 0;
+ }
+ tt = this.raphael.text(100, 100, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).rotate(angle);
+ ret = tt.getBBox();
+ tt.remove();
+ return ret;
+ };
+
+ Grid.prototype.yAxisFormat = function(label) {
+ return this.yLabelFormat(label);
+ };
+
+ Grid.prototype.yLabelFormat = function(label) {
+ if (typeof this.options.yLabelFormat === 'function') {
+ return this.options.yLabelFormat(label);
+ } else {
+ return "" + this.options.preUnits + (Morris.commas(label)) + this.options.postUnits;
+ }
+ };
+
+ Grid.prototype.drawGrid = function() {
+ var lineY, y, _i, _len, _ref, _ref1, _ref2, _results;
+ if (this.options.grid === false && ((_ref = this.options.axes) !== true && _ref !== 'both' && _ref !== 'y')) {
+ return;
+ }
+ _ref1 = this.grid;
+ _results = [];
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ lineY = _ref1[_i];
+ y = this.transY(lineY);
+ if ((_ref2 = this.options.axes) === true || _ref2 === 'both' || _ref2 === 'y') {
+ this.drawYAxisLabel(this.left - this.options.padding / 2, y, this.yAxisFormat(lineY));
+ }
+ if (this.options.grid) {
+ _results.push(this.drawGridLine("M" + this.left + "," + y + "H" + (this.left + this.width)));
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+
+ Grid.prototype.drawGoals = function() {
+ var color, goal, i, _i, _len, _ref, _results;
+ _ref = this.options.goals;
+ _results = [];
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
+ goal = _ref[i];
+ color = this.options.goalLineColors[i % this.options.goalLineColors.length];
+ _results.push(this.drawGoal(goal, color));
+ }
+ return _results;
+ };
+
+ Grid.prototype.drawEvents = function() {
+ var color, event, i, _i, _len, _ref, _results;
+ _ref = this.events;
+ _results = [];
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
+ event = _ref[i];
+ color = this.options.eventLineColors[i % this.options.eventLineColors.length];
+ _results.push(this.drawEvent(event, color));
+ }
+ return _results;
+ };
+
+ Grid.prototype.drawGoal = function(goal, color) {
+ return this.raphael.path("M" + this.left + "," + (this.transY(goal)) + "H" + this.right).attr('stroke', color).attr('stroke-width', this.options.goalStrokeWidth);
+ };
+
+ Grid.prototype.drawEvent = function(event, color) {
+ return this.raphael.path("M" + (this.transX(event)) + "," + this.bottom + "V" + this.top).attr('stroke', color).attr('stroke-width', this.options.eventStrokeWidth);
+ };
+
+ Grid.prototype.drawYAxisLabel = function(xPos, yPos, text) {
+ return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor).attr('text-anchor', 'end');
+ };
+
+ Grid.prototype.drawGridLine = function(path) {
+ return this.raphael.path(path).attr('stroke', this.options.gridLineColor).attr('stroke-width', this.options.gridStrokeWidth);
+ };
+
+ Grid.prototype.startRange = function(x) {
+ this.hover.hide();
+ this.selectFrom = x;
+ return this.selectionRect.attr({
+ x: x,
+ width: 0
+ }).show();
+ };
+
+ Grid.prototype.endRange = function(x) {
+ var end, start;
+ if (this.selectFrom) {
+ start = Math.min(this.selectFrom, x);
+ end = Math.max(this.selectFrom, x);
+ this.options.rangeSelect.call(this.el, {
+ start: this.data[this.hitTest(start)].x,
+ end: this.data[this.hitTest(end)].x
+ });
+ return this.selectFrom = null;
+ }
+ };
+
+ Grid.prototype.resizeHandler = function() {
+ this.timeoutId = null;
+ this.raphael.setSize(this.el.width(), this.el.height());
+ return this.redraw();
+ };
+
+ return Grid;
+
+ })(Morris.EventEmitter);
+
+ Morris.parseDate = function(date) {
+ var isecs, m, msecs, n, o, offsetmins, p, q, r, ret, secs;
+ if (typeof date === 'number') {
+ return date;
+ }
+ m = date.match(/^(\d+) Q(\d)$/);
+ n = date.match(/^(\d+)-(\d+)$/);
+ o = date.match(/^(\d+)-(\d+)-(\d+)$/);
+ p = date.match(/^(\d+) W(\d+)$/);
+ q = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/);
+ r = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/);
+ if (m) {
+ return new Date(parseInt(m[1], 10), parseInt(m[2], 10) * 3 - 1, 1).getTime();
+ } else if (n) {
+ return new Date(parseInt(n[1], 10), parseInt(n[2], 10) - 1, 1).getTime();
+ } else if (o) {
+ return new Date(parseInt(o[1], 10), parseInt(o[2], 10) - 1, parseInt(o[3], 10)).getTime();
+ } else if (p) {
+ ret = new Date(parseInt(p[1], 10), 0, 1);
+ if (ret.getDay() !== 4) {
+ ret.setMonth(0, 1 + ((4 - ret.getDay()) + 7) % 7);
+ }
+ return ret.getTime() + parseInt(p[2], 10) * 604800000;
+ } else if (q) {
+ if (!q[6]) {
+ return new Date(parseInt(q[1], 10), parseInt(q[2], 10) - 1, parseInt(q[3], 10), parseInt(q[4], 10), parseInt(q[5], 10)).getTime();
+ } else {
+ offsetmins = 0;
+ if (q[6] !== 'Z') {
+ offsetmins = parseInt(q[8], 10) * 60 + parseInt(q[9], 10);
+ if (q[7] === '+') {
+ offsetmins = 0 - offsetmins;
+ }
+ }
+ return Date.UTC(parseInt(q[1], 10), parseInt(q[2], 10) - 1, parseInt(q[3], 10), parseInt(q[4], 10), parseInt(q[5], 10) + offsetmins);
+ }
+ } else if (r) {
+ secs = parseFloat(r[6]);
+ isecs = Math.floor(secs);
+ msecs = Math.round((secs - isecs) * 1000);
+ if (!r[8]) {
+ return new Date(parseInt(r[1], 10), parseInt(r[2], 10) - 1, parseInt(r[3], 10), parseInt(r[4], 10), parseInt(r[5], 10), isecs, msecs).getTime();
+ } else {
+ offsetmins = 0;
+ if (r[8] !== 'Z') {
+ offsetmins = parseInt(r[10], 10) * 60 + parseInt(r[11], 10);
+ if (r[9] === '+') {
+ offsetmins = 0 - offsetmins;
+ }
+ }
+ return Date.UTC(parseInt(r[1], 10), parseInt(r[2], 10) - 1, parseInt(r[3], 10), parseInt(r[4], 10), parseInt(r[5], 10) + offsetmins, isecs, msecs);
+ }
+ } else {
+ return new Date(parseInt(date, 10), 0, 1).getTime();
+ }
+ };
+
+ Morris.Hover = (function() {
+ Hover.defaults = {
+ "class": 'morris-hover morris-default-style'
+ };
+
+ function Hover(options) {
+ if (options == null) {
+ options = {};
+ }
+ this.options = $.extend({}, Morris.Hover.defaults, options);
+ this.el = $("");
+ this.el.hide();
+ this.options.parent.append(this.el);
+ }
+
+ Hover.prototype.update = function(html, x, y) {
+ if (!html) {
+ return this.hide();
+ } else {
+ this.html(html);
+ this.show();
+ return this.moveTo(x, y);
+ }
+ };
+
+ Hover.prototype.html = function(content) {
+ return this.el.html(content);
+ };
+
+ Hover.prototype.moveTo = function(x, y) {
+ var hoverHeight, hoverWidth, left, parentHeight, parentWidth, top;
+ parentWidth = this.options.parent.innerWidth();
+ parentHeight = this.options.parent.innerHeight();
+ hoverWidth = this.el.outerWidth();
+ hoverHeight = this.el.outerHeight();
+ left = Math.min(Math.max(0, x - hoverWidth / 2), parentWidth - hoverWidth);
+ if (y != null) {
+ top = y - hoverHeight - 10;
+ if (top < 0) {
+ top = y + 10;
+ if (top + hoverHeight > parentHeight) {
+ top = parentHeight / 2 - hoverHeight / 2;
+ }
+ }
+ } else {
+ top = parentHeight / 2 - hoverHeight / 2;
+ }
+ return this.el.css({
+ left: left + "px",
+ top: parseInt(top) + "px"
+ });
+ };
+
+ Hover.prototype.show = function() {
+ return this.el.show();
+ };
+
+ Hover.prototype.hide = function() {
+ return this.el.hide();
+ };
+
+ return Hover;
+
+ })();
+
+ Morris.Line = (function(_super) {
+ __extends(Line, _super);
+
+ function Line(options) {
+ this.hilight = __bind(this.hilight, this);
+ this.onHoverOut = __bind(this.onHoverOut, this);
+ this.onHoverMove = __bind(this.onHoverMove, this);
+ this.onGridClick = __bind(this.onGridClick, this);
+ if (!(this instanceof Morris.Line)) {
+ return new Morris.Line(options);
+ }
+ Line.__super__.constructor.call(this, options);
+ }
+
+ Line.prototype.init = function() {
+ if (this.options.hideHover !== 'always') {
+ this.hover = new Morris.Hover({
+ parent: this.el
+ });
+ this.on('hovermove', this.onHoverMove);
+ this.on('hoverout', this.onHoverOut);
+ return this.on('gridclick', this.onGridClick);
+ }
+ };
+
+ Line.prototype.defaults = {
+ lineWidth: 3,
+ pointSize: 4,
+ lineColors: ['#0b62a4', '#7A92A3', '#4da74d', '#afd8f8', '#edc240', '#cb4b4b', '#9440ed'],
+ pointStrokeWidths: [1],
+ pointStrokeColors: ['#ffffff'],
+ pointFillColors: [],
+ smooth: true,
+ xLabels: 'auto',
+ xLabelFormat: null,
+ xLabelMargin: 24,
+ hideHover: false
+ };
+
+ Line.prototype.calc = function() {
+ this.calcPoints();
+ return this.generatePaths();
+ };
+
+ Line.prototype.calcPoints = function() {
+ var row, y, _i, _len, _ref, _results;
+ _ref = this.data;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ row = _ref[_i];
+ row._x = this.transX(row.x);
+ row._y = (function() {
+ var _j, _len1, _ref1, _results1;
+ _ref1 = row.y;
+ _results1 = [];
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ y = _ref1[_j];
+ if (y != null) {
+ _results1.push(this.transY(y));
+ } else {
+ _results1.push(y);
+ }
+ }
+ return _results1;
+ }).call(this);
+ _results.push(row._ymax = Math.min.apply(Math, [this.bottom].concat((function() {
+ var _j, _len1, _ref1, _results1;
+ _ref1 = row._y;
+ _results1 = [];
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ y = _ref1[_j];
+ if (y != null) {
+ _results1.push(y);
+ }
+ }
+ return _results1;
+ })())));
+ }
+ return _results;
+ };
+
+ Line.prototype.hitTest = function(x) {
+ var index, r, _i, _len, _ref;
+ if (this.data.length === 0) {
+ return null;
+ }
+ _ref = this.data.slice(1);
+ for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
+ r = _ref[index];
+ if (x < (r._x + this.data[index]._x) / 2) {
+ break;
+ }
+ }
+ return index;
+ };
+
+ Line.prototype.onGridClick = function(x, y) {
+ var index;
+ index = this.hitTest(x);
+ return this.fire('click', index, this.data[index].src, x, y);
+ };
+
+ Line.prototype.onHoverMove = function(x, y) {
+ var index;
+ index = this.hitTest(x);
+ return this.displayHoverForRow(index);
+ };
+
+ Line.prototype.onHoverOut = function() {
+ if (this.options.hideHover !== false) {
+ return this.displayHoverForRow(null);
+ }
+ };
+
+ Line.prototype.displayHoverForRow = function(index) {
+ var _ref;
+ if (index != null) {
+ (_ref = this.hover).update.apply(_ref, this.hoverContentForRow(index));
+ return this.hilight(index);
+ } else {
+ this.hover.hide();
+ return this.hilight();
+ }
+ };
+
+ Line.prototype.hoverContentForRow = function(index) {
+ var content, j, row, y, _i, _len, _ref;
+ row = this.data[index];
+ content = "" + row.label + "
";
+ _ref = row.y;
+ for (j = _i = 0, _len = _ref.length; _i < _len; j = ++_i) {
+ y = _ref[j];
+ content += "\n " + this.options.labels[j] + ":\n " + (this.yLabelFormat(y)) + "\n
";
+ }
+ if (typeof this.options.hoverCallback === 'function') {
+ content = this.options.hoverCallback(index, this.options, content, row.src);
+ }
+ return [content, row._x, row._ymax];
+ };
+
+ Line.prototype.generatePaths = function() {
+ var coords, i, r, smooth;
+ return this.paths = (function() {
+ var _i, _ref, _ref1, _results;
+ _results = [];
+ for (i = _i = 0, _ref = this.options.ykeys.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
+ smooth = typeof this.options.smooth === "boolean" ? this.options.smooth : (_ref1 = this.options.ykeys[i], __indexOf.call(this.options.smooth, _ref1) >= 0);
+ coords = (function() {
+ var _j, _len, _ref2, _results1;
+ _ref2 = this.data;
+ _results1 = [];
+ for (_j = 0, _len = _ref2.length; _j < _len; _j++) {
+ r = _ref2[_j];
+ if (r._y[i] !== void 0) {
+ _results1.push({
+ x: r._x,
+ y: r._y[i]
+ });
+ }
+ }
+ return _results1;
+ }).call(this);
+ if (coords.length > 1) {
+ _results.push(Morris.Line.createPath(coords, smooth, this.bottom));
+ } else {
+ _results.push(null);
+ }
+ }
+ return _results;
+ }).call(this);
+ };
+
+ Line.prototype.draw = function() {
+ var _ref;
+ if ((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'x') {
+ this.drawXAxis();
+ }
+ this.drawSeries();
+ if (this.options.hideHover === false) {
+ return this.displayHoverForRow(this.data.length - 1);
+ }
+ };
+
+ Line.prototype.drawXAxis = function() {
+ var drawLabel, l, labels, prevAngleMargin, prevLabelMargin, row, ypos, _i, _len, _results,
+ _this = this;
+ ypos = this.bottom + this.options.padding / 2;
+ prevLabelMargin = null;
+ prevAngleMargin = null;
+ drawLabel = function(labelText, xpos) {
+ var label, labelBox, margin, offset, textBox;
+ label = _this.drawXAxisLabel(_this.transX(xpos), ypos, labelText);
+ textBox = label.getBBox();
+ label.transform("r" + (-_this.options.xLabelAngle));
+ labelBox = label.getBBox();
+ label.transform("t0," + (labelBox.height / 2) + "...");
+ if (_this.options.xLabelAngle !== 0) {
+ offset = -0.5 * textBox.width * Math.cos(_this.options.xLabelAngle * Math.PI / 180.0);
+ label.transform("t" + offset + ",0...");
+ }
+ labelBox = label.getBBox();
+ if (((prevLabelMargin == null) || prevLabelMargin >= labelBox.x + labelBox.width || (prevAngleMargin != null) && prevAngleMargin >= labelBox.x) && labelBox.x >= 0 && (labelBox.x + labelBox.width) < _this.el.width()) {
+ if (_this.options.xLabelAngle !== 0) {
+ margin = 1.25 * _this.options.gridTextSize / Math.sin(_this.options.xLabelAngle * Math.PI / 180.0);
+ prevAngleMargin = labelBox.x - margin;
+ }
+ return prevLabelMargin = labelBox.x - _this.options.xLabelMargin;
+ } else {
+ return label.remove();
+ }
+ };
+ if (this.options.parseTime) {
+ if (this.data.length === 1 && this.options.xLabels === 'auto') {
+ labels = [[this.data[0].label, this.data[0].x]];
+ } else {
+ labels = Morris.labelSeries(this.xmin, this.xmax, this.width, this.options.xLabels, this.options.xLabelFormat);
+ }
+ } else {
+ labels = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.data;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ row = _ref[_i];
+ _results.push([row.label, row.x]);
+ }
+ return _results;
+ }).call(this);
+ }
+ labels.reverse();
+ _results = [];
+ for (_i = 0, _len = labels.length; _i < _len; _i++) {
+ l = labels[_i];
+ _results.push(drawLabel(l[0], l[1]));
+ }
+ return _results;
+ };
+
+ Line.prototype.drawSeries = function() {
+ var i, _i, _j, _ref, _ref1, _results;
+ this.seriesPoints = [];
+ for (i = _i = _ref = this.options.ykeys.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) {
+ this._drawLineFor(i);
+ }
+ _results = [];
+ for (i = _j = _ref1 = this.options.ykeys.length - 1; _ref1 <= 0 ? _j <= 0 : _j >= 0; i = _ref1 <= 0 ? ++_j : --_j) {
+ _results.push(this._drawPointFor(i));
+ }
+ return _results;
+ };
+
+ Line.prototype._drawPointFor = function(index) {
+ var circle, row, _i, _len, _ref, _results;
+ this.seriesPoints[index] = [];
+ _ref = this.data;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ row = _ref[_i];
+ circle = null;
+ if (row._y[index] != null) {
+ circle = this.drawLinePoint(row._x, row._y[index], this.colorFor(row, index, 'point'), index);
+ }
+ _results.push(this.seriesPoints[index].push(circle));
+ }
+ return _results;
+ };
+
+ Line.prototype._drawLineFor = function(index) {
+ var path;
+ path = this.paths[index];
+ if (path !== null) {
+ return this.drawLinePath(path, this.colorFor(null, index, 'line'), index);
+ }
+ };
+
+ Line.createPath = function(coords, smooth, bottom) {
+ var coord, g, grads, i, ix, lg, path, prevCoord, x1, x2, y1, y2, _i, _len;
+ path = "";
+ if (smooth) {
+ grads = Morris.Line.gradients(coords);
+ }
+ prevCoord = {
+ y: null
+ };
+ for (i = _i = 0, _len = coords.length; _i < _len; i = ++_i) {
+ coord = coords[i];
+ if (coord.y != null) {
+ if (prevCoord.y != null) {
+ if (smooth) {
+ g = grads[i];
+ lg = grads[i - 1];
+ ix = (coord.x - prevCoord.x) / 4;
+ x1 = prevCoord.x + ix;
+ y1 = Math.min(bottom, prevCoord.y + ix * lg);
+ x2 = coord.x - ix;
+ y2 = Math.min(bottom, coord.y - ix * g);
+ path += "C" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + coord.x + "," + coord.y;
+ } else {
+ path += "L" + coord.x + "," + coord.y;
+ }
+ } else {
+ if (!smooth || (grads[i] != null)) {
+ path += "M" + coord.x + "," + coord.y;
+ }
+ }
+ }
+ prevCoord = coord;
+ }
+ return path;
+ };
+
+ Line.gradients = function(coords) {
+ var coord, grad, i, nextCoord, prevCoord, _i, _len, _results;
+ grad = function(a, b) {
+ return (a.y - b.y) / (a.x - b.x);
+ };
+ _results = [];
+ for (i = _i = 0, _len = coords.length; _i < _len; i = ++_i) {
+ coord = coords[i];
+ if (coord.y != null) {
+ nextCoord = coords[i + 1] || {
+ y: null
+ };
+ prevCoord = coords[i - 1] || {
+ y: null
+ };
+ if ((prevCoord.y != null) && (nextCoord.y != null)) {
+ _results.push(grad(prevCoord, nextCoord));
+ } else if (prevCoord.y != null) {
+ _results.push(grad(prevCoord, coord));
+ } else if (nextCoord.y != null) {
+ _results.push(grad(coord, nextCoord));
+ } else {
+ _results.push(null);
+ }
+ } else {
+ _results.push(null);
+ }
+ }
+ return _results;
+ };
+
+ Line.prototype.hilight = function(index) {
+ var i, _i, _j, _ref, _ref1;
+ if (this.prevHilight !== null && this.prevHilight !== index) {
+ for (i = _i = 0, _ref = this.seriesPoints.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
+ if (this.seriesPoints[i][this.prevHilight]) {
+ this.seriesPoints[i][this.prevHilight].animate(this.pointShrinkSeries(i));
+ }
+ }
+ }
+ if (index !== null && this.prevHilight !== index) {
+ for (i = _j = 0, _ref1 = this.seriesPoints.length - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
+ if (this.seriesPoints[i][index]) {
+ this.seriesPoints[i][index].animate(this.pointGrowSeries(i));
+ }
+ }
+ }
+ return this.prevHilight = index;
+ };
+
+ Line.prototype.colorFor = function(row, sidx, type) {
+ if (typeof this.options.lineColors === 'function') {
+ return this.options.lineColors.call(this, row, sidx, type);
+ } else if (type === 'point') {
+ return this.options.pointFillColors[sidx % this.options.pointFillColors.length] || this.options.lineColors[sidx % this.options.lineColors.length];
+ } else {
+ return this.options.lineColors[sidx % this.options.lineColors.length];
+ }
+ };
+
+ Line.prototype.drawXAxisLabel = function(xPos, yPos, text) {
+ return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor);
+ };
+
+ Line.prototype.drawLinePath = function(path, lineColor, lineIndex) {
+ return this.raphael.path(path).attr('stroke', lineColor).attr('stroke-width', this.lineWidthForSeries(lineIndex));
+ };
+
+ Line.prototype.drawLinePoint = function(xPos, yPos, pointColor, lineIndex) {
+ return this.raphael.circle(xPos, yPos, this.pointSizeForSeries(lineIndex)).attr('fill', pointColor).attr('stroke-width', this.pointStrokeWidthForSeries(lineIndex)).attr('stroke', this.pointStrokeColorForSeries(lineIndex));
+ };
+
+ Line.prototype.pointStrokeWidthForSeries = function(index) {
+ return this.options.pointStrokeWidths[index % this.options.pointStrokeWidths.length];
+ };
+
+ Line.prototype.pointStrokeColorForSeries = function(index) {
+ return this.options.pointStrokeColors[index % this.options.pointStrokeColors.length];
+ };
+
+ Line.prototype.lineWidthForSeries = function(index) {
+ if (this.options.lineWidth instanceof Array) {
+ return this.options.lineWidth[index % this.options.lineWidth.length];
+ } else {
+ return this.options.lineWidth;
+ }
+ };
+
+ Line.prototype.pointSizeForSeries = function(index) {
+ if (this.options.pointSize instanceof Array) {
+ return this.options.pointSize[index % this.options.pointSize.length];
+ } else {
+ return this.options.pointSize;
+ }
+ };
+
+ Line.prototype.pointGrowSeries = function(index) {
+ return Raphael.animation({
+ r: this.pointSizeForSeries(index) + 3
+ }, 25, 'linear');
+ };
+
+ Line.prototype.pointShrinkSeries = function(index) {
+ return Raphael.animation({
+ r: this.pointSizeForSeries(index)
+ }, 25, 'linear');
+ };
+
+ return Line;
+
+ })(Morris.Grid);
+
+ Morris.labelSeries = function(dmin, dmax, pxwidth, specName, xLabelFormat) {
+ var d, d0, ddensity, name, ret, s, spec, t, _i, _len, _ref;
+ ddensity = 200 * (dmax - dmin) / pxwidth;
+ d0 = new Date(dmin);
+ spec = Morris.LABEL_SPECS[specName];
+ if (spec === void 0) {
+ _ref = Morris.AUTO_LABEL_ORDER;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ name = _ref[_i];
+ s = Morris.LABEL_SPECS[name];
+ if (ddensity >= s.span) {
+ spec = s;
+ break;
+ }
+ }
+ }
+ if (spec === void 0) {
+ spec = Morris.LABEL_SPECS["second"];
+ }
+ if (xLabelFormat) {
+ spec = $.extend({}, spec, {
+ fmt: xLabelFormat
+ });
+ }
+ d = spec.start(d0);
+ ret = [];
+ while ((t = d.getTime()) <= dmax) {
+ if (t >= dmin) {
+ ret.push([spec.fmt(d), t]);
+ }
+ spec.incr(d);
+ }
+ return ret;
+ };
+
+ minutesSpecHelper = function(interval) {
+ return {
+ span: interval * 60 * 1000,
+ start: function(d) {
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
+ },
+ fmt: function(d) {
+ return "" + (Morris.pad2(d.getHours())) + ":" + (Morris.pad2(d.getMinutes()));
+ },
+ incr: function(d) {
+ return d.setUTCMinutes(d.getUTCMinutes() + interval);
+ }
+ };
+ };
+
+ secondsSpecHelper = function(interval) {
+ return {
+ span: interval * 1000,
+ start: function(d) {
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes());
+ },
+ fmt: function(d) {
+ return "" + (Morris.pad2(d.getHours())) + ":" + (Morris.pad2(d.getMinutes())) + ":" + (Morris.pad2(d.getSeconds()));
+ },
+ incr: function(d) {
+ return d.setUTCSeconds(d.getUTCSeconds() + interval);
+ }
+ };
+ };
+
+ Morris.LABEL_SPECS = {
+ "decade": {
+ span: 172800000000,
+ start: function(d) {
+ return new Date(d.getFullYear() - d.getFullYear() % 10, 0, 1);
+ },
+ fmt: function(d) {
+ return "" + (d.getFullYear());
+ },
+ incr: function(d) {
+ return d.setFullYear(d.getFullYear() + 10);
+ }
+ },
+ "year": {
+ span: 17280000000,
+ start: function(d) {
+ return new Date(d.getFullYear(), 0, 1);
+ },
+ fmt: function(d) {
+ return "" + (d.getFullYear());
+ },
+ incr: function(d) {
+ return d.setFullYear(d.getFullYear() + 1);
+ }
+ },
+ "month": {
+ span: 2419200000,
+ start: function(d) {
+ return new Date(d.getFullYear(), d.getMonth(), 1);
+ },
+ fmt: function(d) {
+ return "" + (d.getFullYear()) + "-" + (Morris.pad2(d.getMonth() + 1));
+ },
+ incr: function(d) {
+ return d.setMonth(d.getMonth() + 1);
+ }
+ },
+ "week": {
+ span: 604800000,
+ start: function(d) {
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
+ },
+ fmt: function(d) {
+ return "" + (d.getFullYear()) + "-" + (Morris.pad2(d.getMonth() + 1)) + "-" + (Morris.pad2(d.getDate()));
+ },
+ incr: function(d) {
+ return d.setDate(d.getDate() + 7);
+ }
+ },
+ "day": {
+ span: 86400000,
+ start: function(d) {
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
+ },
+ fmt: function(d) {
+ return "" + (d.getFullYear()) + "-" + (Morris.pad2(d.getMonth() + 1)) + "-" + (Morris.pad2(d.getDate()));
+ },
+ incr: function(d) {
+ return d.setDate(d.getDate() + 1);
+ }
+ },
+ "hour": minutesSpecHelper(60),
+ "30min": minutesSpecHelper(30),
+ "15min": minutesSpecHelper(15),
+ "10min": minutesSpecHelper(10),
+ "5min": minutesSpecHelper(5),
+ "minute": minutesSpecHelper(1),
+ "30sec": secondsSpecHelper(30),
+ "15sec": secondsSpecHelper(15),
+ "10sec": secondsSpecHelper(10),
+ "5sec": secondsSpecHelper(5),
+ "second": secondsSpecHelper(1)
+ };
+
+ Morris.AUTO_LABEL_ORDER = ["decade", "year", "month", "week", "day", "hour", "30min", "15min", "10min", "5min", "minute", "30sec", "15sec", "10sec", "5sec", "second"];
+
+ Morris.Area = (function(_super) {
+ var areaDefaults;
+
+ __extends(Area, _super);
+
+ areaDefaults = {
+ fillOpacity: 'auto',
+ behaveLikeLine: false
+ };
+
+ function Area(options) {
+ var areaOptions;
+ if (!(this instanceof Morris.Area)) {
+ return new Morris.Area(options);
+ }
+ areaOptions = $.extend({}, areaDefaults, options);
+ this.cumulative = !areaOptions.behaveLikeLine;
+ if (areaOptions.fillOpacity === 'auto') {
+ areaOptions.fillOpacity = areaOptions.behaveLikeLine ? .8 : 1;
+ }
+ Area.__super__.constructor.call(this, areaOptions);
+ }
+
+ Area.prototype.calcPoints = function() {
+ var row, total, y, _i, _len, _ref, _results;
+ _ref = this.data;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ row = _ref[_i];
+ row._x = this.transX(row.x);
+ total = 0;
+ row._y = (function() {
+ var _j, _len1, _ref1, _results1;
+ _ref1 = row.y;
+ _results1 = [];
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ y = _ref1[_j];
+ if (this.options.behaveLikeLine) {
+ _results1.push(this.transY(y));
+ } else {
+ total += y || 0;
+ _results1.push(this.transY(total));
+ }
+ }
+ return _results1;
+ }).call(this);
+ _results.push(row._ymax = Math.max.apply(Math, row._y));
+ }
+ return _results;
+ };
+
+ Area.prototype.drawSeries = function() {
+ var i, range, _i, _j, _k, _len, _ref, _ref1, _results, _results1, _results2;
+ this.seriesPoints = [];
+ if (this.options.behaveLikeLine) {
+ range = (function() {
+ _results = [];
+ for (var _i = 0, _ref = this.options.ykeys.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; 0 <= _ref ? _i++ : _i--){ _results.push(_i); }
+ return _results;
+ }).apply(this);
+ } else {
+ range = (function() {
+ _results1 = [];
+ for (var _j = _ref1 = this.options.ykeys.length - 1; _ref1 <= 0 ? _j <= 0 : _j >= 0; _ref1 <= 0 ? _j++ : _j--){ _results1.push(_j); }
+ return _results1;
+ }).apply(this);
+ }
+ _results2 = [];
+ for (_k = 0, _len = range.length; _k < _len; _k++) {
+ i = range[_k];
+ this._drawFillFor(i);
+ this._drawLineFor(i);
+ _results2.push(this._drawPointFor(i));
+ }
+ return _results2;
+ };
+
+ Area.prototype._drawFillFor = function(index) {
+ var path;
+ path = this.paths[index];
+ if (path !== null) {
+ path = path + ("L" + (this.transX(this.xmax)) + "," + this.bottom + "L" + (this.transX(this.xmin)) + "," + this.bottom + "Z");
+ return this.drawFilledPath(path, this.fillForSeries(index));
+ }
+ };
+
+ Area.prototype.fillForSeries = function(i) {
+ var color;
+ color = Raphael.rgb2hsl(this.colorFor(this.data[i], i, 'line'));
+ return Raphael.hsl(color.h, this.options.behaveLikeLine ? color.s * 0.9 : color.s * 0.75, Math.min(0.98, this.options.behaveLikeLine ? color.l * 1.2 : color.l * 1.25));
+ };
+
+ Area.prototype.drawFilledPath = function(path, fill) {
+ return this.raphael.path(path).attr('fill', fill).attr('fill-opacity', this.options.fillOpacity).attr('stroke', 'none');
+ };
+
+ return Area;
+
+ })(Morris.Line);
+
+ Morris.Bar = (function(_super) {
+ __extends(Bar, _super);
+
+ function Bar(options) {
+ this.onHoverOut = __bind(this.onHoverOut, this);
+ this.onHoverMove = __bind(this.onHoverMove, this);
+ this.onGridClick = __bind(this.onGridClick, this);
+ if (!(this instanceof Morris.Bar)) {
+ return new Morris.Bar(options);
+ }
+ Bar.__super__.constructor.call(this, $.extend({}, options, {
+ parseTime: false
+ }));
+ }
+
+ Bar.prototype.init = function() {
+ this.cumulative = this.options.stacked;
+ if (this.options.hideHover !== 'always') {
+ this.hover = new Morris.Hover({
+ parent: this.el
+ });
+ this.on('hovermove', this.onHoverMove);
+ this.on('hoverout', this.onHoverOut);
+ return this.on('gridclick', this.onGridClick);
+ }
+ };
+
+ Bar.prototype.defaults = {
+ barSizeRatio: 0.75,
+ barGap: 3,
+ barColors: ['#0b62a4', '#7a92a3', '#4da74d', '#afd8f8', '#edc240', '#cb4b4b', '#9440ed'],
+ barOpacity: 1.0,
+ barRadius: [0, 0, 0, 0],
+ xLabelMargin: 50
+ };
+
+ Bar.prototype.calc = function() {
+ var _ref;
+ this.calcBars();
+ if (this.options.hideHover === false) {
+ return (_ref = this.hover).update.apply(_ref, this.hoverContentForRow(this.data.length - 1));
+ }
+ };
+
+ Bar.prototype.calcBars = function() {
+ var idx, row, y, _i, _len, _ref, _results;
+ _ref = this.data;
+ _results = [];
+ for (idx = _i = 0, _len = _ref.length; _i < _len; idx = ++_i) {
+ row = _ref[idx];
+ row._x = this.left + this.width * (idx + 0.5) / this.data.length;
+ _results.push(row._y = (function() {
+ var _j, _len1, _ref1, _results1;
+ _ref1 = row.y;
+ _results1 = [];
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ y = _ref1[_j];
+ if (y != null) {
+ _results1.push(this.transY(y));
+ } else {
+ _results1.push(null);
+ }
+ }
+ return _results1;
+ }).call(this));
+ }
+ return _results;
+ };
+
+ Bar.prototype.draw = function() {
+ var _ref;
+ if ((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'x') {
+ this.drawXAxis();
+ }
+ return this.drawSeries();
+ };
+
+ Bar.prototype.drawXAxis = function() {
+ var i, label, labelBox, margin, offset, prevAngleMargin, prevLabelMargin, row, textBox, ypos, _i, _ref, _results;
+ ypos = this.bottom + (this.options.xAxisLabelTopPadding || this.options.padding / 2);
+ prevLabelMargin = null;
+ prevAngleMargin = null;
+ _results = [];
+ for (i = _i = 0, _ref = this.data.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
+ row = this.data[this.data.length - 1 - i];
+ label = this.drawXAxisLabel(row._x, ypos, row.label);
+ textBox = label.getBBox();
+ label.transform("r" + (-this.options.xLabelAngle));
+ labelBox = label.getBBox();
+ label.transform("t0," + (labelBox.height / 2) + "...");
+ if (this.options.xLabelAngle !== 0) {
+ offset = -0.5 * textBox.width * Math.cos(this.options.xLabelAngle * Math.PI / 180.0);
+ label.transform("t" + offset + ",0...");
+ }
+ if (((prevLabelMargin == null) || prevLabelMargin >= labelBox.x + labelBox.width || (prevAngleMargin != null) && prevAngleMargin >= labelBox.x) && labelBox.x >= 0 && (labelBox.x + labelBox.width) < this.el.width()) {
+ if (this.options.xLabelAngle !== 0) {
+ margin = 1.25 * this.options.gridTextSize / Math.sin(this.options.xLabelAngle * Math.PI / 180.0);
+ prevAngleMargin = labelBox.x - margin;
+ }
+ _results.push(prevLabelMargin = labelBox.x - this.options.xLabelMargin);
+ } else {
+ _results.push(label.remove());
+ }
+ }
+ return _results;
+ };
+
+ Bar.prototype.drawSeries = function() {
+ var barWidth, bottom, groupWidth, idx, lastTop, left, leftPadding, numBars, row, sidx, size, spaceLeft, top, ypos, zeroPos;
+ groupWidth = this.width / this.options.data.length;
+ numBars = this.options.stacked ? 1 : this.options.ykeys.length;
+ barWidth = (groupWidth * this.options.barSizeRatio - this.options.barGap * (numBars - 1)) / numBars;
+ if (this.options.barSize) {
+ barWidth = Math.min(barWidth, this.options.barSize);
+ }
+ spaceLeft = groupWidth - barWidth * numBars - this.options.barGap * (numBars - 1);
+ leftPadding = spaceLeft / 2;
+ zeroPos = this.ymin <= 0 && this.ymax >= 0 ? this.transY(0) : null;
+ return this.bars = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.data;
+ _results = [];
+ for (idx = _i = 0, _len = _ref.length; _i < _len; idx = ++_i) {
+ row = _ref[idx];
+ lastTop = 0;
+ _results.push((function() {
+ var _j, _len1, _ref1, _results1;
+ _ref1 = row._y;
+ _results1 = [];
+ for (sidx = _j = 0, _len1 = _ref1.length; _j < _len1; sidx = ++_j) {
+ ypos = _ref1[sidx];
+ if (ypos !== null) {
+ if (zeroPos) {
+ top = Math.min(ypos, zeroPos);
+ bottom = Math.max(ypos, zeroPos);
+ } else {
+ top = ypos;
+ bottom = this.bottom;
+ }
+ left = this.left + idx * groupWidth + leftPadding;
+ if (!this.options.stacked) {
+ left += sidx * (barWidth + this.options.barGap);
+ }
+ size = bottom - top;
+ if (this.options.verticalGridCondition && this.options.verticalGridCondition(row.x)) {
+ this.drawBar(this.left + idx * groupWidth, this.top, groupWidth, Math.abs(this.top - this.bottom), this.options.verticalGridColor, this.options.verticalGridOpacity, this.options.barRadius);
+ }
+ if (this.options.stacked) {
+ top -= lastTop;
+ }
+ this.drawBar(left, top, barWidth, size, this.colorFor(row, sidx, 'bar'), this.options.barOpacity, this.options.barRadius);
+ _results1.push(lastTop += size);
+ } else {
+ _results1.push(null);
+ }
+ }
+ return _results1;
+ }).call(this));
+ }
+ return _results;
+ }).call(this);
+ };
+
+ Bar.prototype.colorFor = function(row, sidx, type) {
+ var r, s;
+ if (typeof this.options.barColors === 'function') {
+ r = {
+ x: row.x,
+ y: row.y[sidx],
+ label: row.label
+ };
+ s = {
+ index: sidx,
+ key: this.options.ykeys[sidx],
+ label: this.options.labels[sidx]
+ };
+ return this.options.barColors.call(this, r, s, type);
+ } else {
+ return this.options.barColors[sidx % this.options.barColors.length];
+ }
+ };
+
+ Bar.prototype.hitTest = function(x) {
+ if (this.data.length === 0) {
+ return null;
+ }
+ x = Math.max(Math.min(x, this.right), this.left);
+ return Math.min(this.data.length - 1, Math.floor((x - this.left) / (this.width / this.data.length)));
+ };
+
+ Bar.prototype.onGridClick = function(x, y) {
+ var index;
+ index = this.hitTest(x);
+ return this.fire('click', index, this.data[index].src, x, y);
+ };
+
+ Bar.prototype.onHoverMove = function(x, y) {
+ var index, _ref;
+ index = this.hitTest(x);
+ return (_ref = this.hover).update.apply(_ref, this.hoverContentForRow(index));
+ };
+
+ Bar.prototype.onHoverOut = function() {
+ if (this.options.hideHover !== false) {
+ return this.hover.hide();
+ }
+ };
+
+ Bar.prototype.hoverContentForRow = function(index) {
+ var content, j, row, x, y, _i, _len, _ref;
+ row = this.data[index];
+ content = "" + row.label + "
";
+ _ref = row.y;
+ for (j = _i = 0, _len = _ref.length; _i < _len; j = ++_i) {
+ y = _ref[j];
+ content += "\n " + this.options.labels[j] + ":\n " + (this.yLabelFormat(y)) + "\n
";
+ }
+ if (typeof this.options.hoverCallback === 'function') {
+ content = this.options.hoverCallback(index, this.options, content, row.src);
+ }
+ x = this.left + (index + 0.5) * this.width / this.data.length;
+ return [content, x];
+ };
+
+ Bar.prototype.drawXAxisLabel = function(xPos, yPos, text) {
+ var label;
+ return label = this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor);
+ };
+
+ Bar.prototype.drawBar = function(xPos, yPos, width, height, barColor, opacity, radiusArray) {
+ var maxRadius, path;
+ maxRadius = Math.max.apply(Math, radiusArray);
+ if (maxRadius === 0 || maxRadius > height) {
+ path = this.raphael.rect(xPos, yPos, width, height);
+ } else {
+ path = this.raphael.path(this.roundedRect(xPos, yPos, width, height, radiusArray));
+ }
+ return path.attr('fill', barColor).attr('fill-opacity', opacity).attr('stroke', 'none');
+ };
+
+ Bar.prototype.roundedRect = function(x, y, w, h, r) {
+ if (r == null) {
+ r = [0, 0, 0, 0];
+ }
+ return ["M", x, r[0] + y, "Q", x, y, x + r[0], y, "L", x + w - r[1], y, "Q", x + w, y, x + w, y + r[1], "L", x + w, y + h - r[2], "Q", x + w, y + h, x + w - r[2], y + h, "L", x + r[3], y + h, "Q", x, y + h, x, y + h - r[3], "Z"];
+ };
+
+ return Bar;
+
+ })(Morris.Grid);
+
+ Morris.Donut = (function(_super) {
+ __extends(Donut, _super);
+
+ Donut.prototype.defaults = {
+ colors: ['#0B62A4', '#3980B5', '#679DC6', '#95BBD7', '#B0CCE1', '#095791', '#095085', '#083E67', '#052C48', '#042135'],
+ backgroundColor: '#FFFFFF',
+ labelColor: '#000000',
+ formatter: Morris.commas,
+ resize: false
+ };
+
+ function Donut(options) {
+ this.resizeHandler = __bind(this.resizeHandler, this);
+ this.select = __bind(this.select, this);
+ this.click = __bind(this.click, this);
+ var _this = this;
+ if (!(this instanceof Morris.Donut)) {
+ return new Morris.Donut(options);
+ }
+ this.options = $.extend({}, this.defaults, options);
+ if (typeof options.element === 'string') {
+ this.el = $(document.getElementById(options.element));
+ } else {
+ this.el = $(options.element);
+ }
+ if (this.el === null || this.el.length === 0) {
+ throw new Error("Graph placeholder not found.");
+ }
+ if (options.data === void 0 || options.data.length === 0) {
+ return;
+ }
+ this.raphael = new Raphael(this.el[0]);
+ if (this.options.resize) {
+ $(window).bind('resize', function(evt) {
+ if (_this.timeoutId != null) {
+ window.clearTimeout(_this.timeoutId);
+ }
+ return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100);
+ });
+ }
+ this.setData(options.data);
+ }
+
+ Donut.prototype.redraw = function() {
+ var C, cx, cy, i, idx, last, max_value, min, next, seg, total, value, w, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
+ this.raphael.clear();
+ cx = this.el.width() / 2;
+ cy = this.el.height() / 2;
+ w = (Math.min(cx, cy) - 10) / 3;
+ total = 0;
+ _ref = this.values;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ value = _ref[_i];
+ total += value;
+ }
+ min = 5 / (2 * w);
+ C = 1.9999 * Math.PI - min * this.data.length;
+ last = 0;
+ idx = 0;
+ this.segments = [];
+ _ref1 = this.values;
+ for (i = _j = 0, _len1 = _ref1.length; _j < _len1; i = ++_j) {
+ value = _ref1[i];
+ next = last + min + C * (value / total);
+ seg = new Morris.DonutSegment(cx, cy, w * 2, w, last, next, this.data[i].color || this.options.colors[idx % this.options.colors.length], this.options.backgroundColor, idx, this.raphael);
+ seg.render();
+ this.segments.push(seg);
+ seg.on('hover', this.select);
+ seg.on('click', this.click);
+ last = next;
+ idx += 1;
+ }
+ this.text1 = this.drawEmptyDonutLabel(cx, cy - 10, this.options.labelColor, 15, 800);
+ this.text2 = this.drawEmptyDonutLabel(cx, cy + 10, this.options.labelColor, 14);
+ max_value = Math.max.apply(Math, this.values);
+ idx = 0;
+ _ref2 = this.values;
+ _results = [];
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+ value = _ref2[_k];
+ if (value === max_value) {
+ this.select(idx);
+ break;
+ }
+ _results.push(idx += 1);
+ }
+ return _results;
+ };
+
+ Donut.prototype.setData = function(data) {
+ var row;
+ this.data = data;
+ this.values = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.data;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ row = _ref[_i];
+ _results.push(parseFloat(row.value));
+ }
+ return _results;
+ }).call(this);
+ return this.redraw();
+ };
+
+ Donut.prototype.click = function(idx) {
+ return this.fire('click', idx, this.data[idx]);
+ };
+
+ Donut.prototype.select = function(idx) {
+ var row, s, segment, _i, _len, _ref;
+ _ref = this.segments;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ s = _ref[_i];
+ s.deselect();
+ }
+ segment = this.segments[idx];
+ segment.select();
+ row = this.data[idx];
+ return this.setLabels(row.label, this.options.formatter(row.value, row));
+ };
+
+ Donut.prototype.setLabels = function(label1, label2) {
+ var inner, maxHeightBottom, maxHeightTop, maxWidth, text1bbox, text1scale, text2bbox, text2scale;
+ inner = (Math.min(this.el.width() / 2, this.el.height() / 2) - 10) * 2 / 3;
+ maxWidth = 1.8 * inner;
+ maxHeightTop = inner / 2;
+ maxHeightBottom = inner / 3;
+ this.text1.attr({
+ text: label1,
+ transform: ''
+ });
+ text1bbox = this.text1.getBBox();
+ text1scale = Math.min(maxWidth / text1bbox.width, maxHeightTop / text1bbox.height);
+ this.text1.attr({
+ transform: "S" + text1scale + "," + text1scale + "," + (text1bbox.x + text1bbox.width / 2) + "," + (text1bbox.y + text1bbox.height)
+ });
+ this.text2.attr({
+ text: label2,
+ transform: ''
+ });
+ text2bbox = this.text2.getBBox();
+ text2scale = Math.min(maxWidth / text2bbox.width, maxHeightBottom / text2bbox.height);
+ return this.text2.attr({
+ transform: "S" + text2scale + "," + text2scale + "," + (text2bbox.x + text2bbox.width / 2) + "," + text2bbox.y
+ });
+ };
+
+ Donut.prototype.drawEmptyDonutLabel = function(xPos, yPos, color, fontSize, fontWeight) {
+ var text;
+ text = this.raphael.text(xPos, yPos, '').attr('font-size', fontSize).attr('fill', color);
+ if (fontWeight != null) {
+ text.attr('font-weight', fontWeight);
+ }
+ return text;
+ };
+
+ Donut.prototype.resizeHandler = function() {
+ this.timeoutId = null;
+ this.raphael.setSize(this.el.width(), this.el.height());
+ return this.redraw();
+ };
+
+ return Donut;
+
+ })(Morris.EventEmitter);
+
+ Morris.DonutSegment = (function(_super) {
+ __extends(DonutSegment, _super);
+
+ function DonutSegment(cx, cy, inner, outer, p0, p1, color, backgroundColor, index, raphael) {
+ this.cx = cx;
+ this.cy = cy;
+ this.inner = inner;
+ this.outer = outer;
+ this.color = color;
+ this.backgroundColor = backgroundColor;
+ this.index = index;
+ this.raphael = raphael;
+ this.deselect = __bind(this.deselect, this);
+ this.select = __bind(this.select, this);
+ this.sin_p0 = Math.sin(p0);
+ this.cos_p0 = Math.cos(p0);
+ this.sin_p1 = Math.sin(p1);
+ this.cos_p1 = Math.cos(p1);
+ this.is_long = (p1 - p0) > Math.PI ? 1 : 0;
+ this.path = this.calcSegment(this.inner + 3, this.inner + this.outer - 5);
+ this.selectedPath = this.calcSegment(this.inner + 3, this.inner + this.outer);
+ this.hilight = this.calcArc(this.inner);
+ }
+
+ DonutSegment.prototype.calcArcPoints = function(r) {
+ return [this.cx + r * this.sin_p0, this.cy + r * this.cos_p0, this.cx + r * this.sin_p1, this.cy + r * this.cos_p1];
+ };
+
+ DonutSegment.prototype.calcSegment = function(r1, r2) {
+ var ix0, ix1, iy0, iy1, ox0, ox1, oy0, oy1, _ref, _ref1;
+ _ref = this.calcArcPoints(r1), ix0 = _ref[0], iy0 = _ref[1], ix1 = _ref[2], iy1 = _ref[3];
+ _ref1 = this.calcArcPoints(r2), ox0 = _ref1[0], oy0 = _ref1[1], ox1 = _ref1[2], oy1 = _ref1[3];
+ return ("M" + ix0 + "," + iy0) + ("A" + r1 + "," + r1 + ",0," + this.is_long + ",0," + ix1 + "," + iy1) + ("L" + ox1 + "," + oy1) + ("A" + r2 + "," + r2 + ",0," + this.is_long + ",1," + ox0 + "," + oy0) + "Z";
+ };
+
+ DonutSegment.prototype.calcArc = function(r) {
+ var ix0, ix1, iy0, iy1, _ref;
+ _ref = this.calcArcPoints(r), ix0 = _ref[0], iy0 = _ref[1], ix1 = _ref[2], iy1 = _ref[3];
+ return ("M" + ix0 + "," + iy0) + ("A" + r + "," + r + ",0," + this.is_long + ",0," + ix1 + "," + iy1);
+ };
+
+ DonutSegment.prototype.render = function() {
+ var _this = this;
+ this.arc = this.drawDonutArc(this.hilight, this.color);
+ return this.seg = this.drawDonutSegment(this.path, this.color, this.backgroundColor, function() {
+ return _this.fire('hover', _this.index);
+ }, function() {
+ return _this.fire('click', _this.index);
+ });
+ };
+
+ DonutSegment.prototype.drawDonutArc = function(path, color) {
+ return this.raphael.path(path).attr({
+ stroke: color,
+ 'stroke-width': 2,
+ opacity: 0
+ });
+ };
+
+ DonutSegment.prototype.drawDonutSegment = function(path, fillColor, strokeColor, hoverFunction, clickFunction) {
+ return this.raphael.path(path).attr({
+ fill: fillColor,
+ stroke: strokeColor,
+ 'stroke-width': 3
+ }).hover(hoverFunction).click(clickFunction);
+ };
+
+ DonutSegment.prototype.select = function() {
+ if (!this.selected) {
+ this.seg.animate({
+ path: this.selectedPath
+ }, 150, '<>');
+ this.arc.animate({
+ opacity: 1
+ }, 150, '<>');
+ return this.selected = true;
+ }
+ };
+
+ DonutSegment.prototype.deselect = function() {
+ if (this.selected) {
+ this.seg.animate({
+ path: this.path
+ }, 150, '<>');
+ this.arc.animate({
+ opacity: 0
+ }, 150, '<>');
+ return this.selected = false;
+ }
+ };
+
+ return DonutSegment;
+
+ })(Morris.EventEmitter);
+
+}).call(this);
diff --git a/code/haitiwater/static-common/vendor/morris/morris.min.js b/code/haitiwater/static-common/vendor/morris/morris.min.js
new file mode 100644
index 0000000..c3bda2f
--- /dev/null
+++ b/code/haitiwater/static-common/vendor/morris/morris.min.js
@@ -0,0 +1,7 @@
+/* @license
+morris.js v0.5.0
+Copyright 2014 Olly Smith All rights reserved.
+Licensed under the BSD-2-Clause License.
+*/
+(function(){var a,b,c,d,e=[].slice,f=function(a,b){return function(){return a.apply(b,arguments)}},g={}.hasOwnProperty,h=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},i=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b=window.Morris={},a=jQuery,b.EventEmitter=function(){function a(){}return a.prototype.on=function(a,b){return null==this.handlers&&(this.handlers={}),null==this.handlers[a]&&(this.handlers[a]=[]),this.handlers[a].push(b),this},a.prototype.fire=function(){var a,b,c,d,f,g,h;if(c=arguments[0],a=2<=arguments.length?e.call(arguments,1):[],null!=this.handlers&&null!=this.handlers[c]){for(g=this.handlers[c],h=[],d=0,f=g.length;f>d;d++)b=g[d],h.push(b.apply(null,a));return h}},a}(),b.commas=function(a){var b,c,d,e;return null!=a?(d=0>a?"-":"",b=Math.abs(a),c=Math.floor(b).toFixed(0),d+=c.replace(/(?=(?:\d{3})+$)(?!^)/g,","),e=b.toString(),e.length>c.length&&(d+=e.slice(c.length)),d):"-"},b.pad2=function(a){return(10>a?"0":"")+a},b.Grid=function(c){function d(b){this.resizeHandler=f(this.resizeHandler,this);var c=this;if(this.el="string"==typeof b.element?a(document.getElementById(b.element)):a(b.element),null==this.el||0===this.el.length)throw new Error("Graph container element not found");"static"===this.el.css("position")&&this.el.css("position","relative"),this.options=a.extend({},this.gridDefaults,this.defaults||{},b),"string"==typeof this.options.units&&(this.options.postUnits=b.units),this.raphael=new Raphael(this.el[0]),this.elementWidth=null,this.elementHeight=null,this.dirty=!1,this.selectFrom=null,this.init&&this.init(),this.setData(this.options.data),this.el.bind("mousemove",function(a){var b,d,e,f,g;return d=c.el.offset(),g=a.pageX-d.left,c.selectFrom?(b=c.data[c.hitTest(Math.min(g,c.selectFrom))]._x,e=c.data[c.hitTest(Math.max(g,c.selectFrom))]._x,f=e-b,c.selectionRect.attr({x:b,width:f})):c.fire("hovermove",g,a.pageY-d.top)}),this.el.bind("mouseleave",function(){return c.selectFrom&&(c.selectionRect.hide(),c.selectFrom=null),c.fire("hoverout")}),this.el.bind("touchstart touchmove touchend",function(a){var b,d;return d=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0],b=c.el.offset(),c.fire("hovermove",d.pageX-b.left,d.pageY-b.top)}),this.el.bind("click",function(a){var b;return b=c.el.offset(),c.fire("gridclick",a.pageX-b.left,a.pageY-b.top)}),this.options.rangeSelect&&(this.selectionRect=this.raphael.rect(0,0,0,this.el.innerHeight()).attr({fill:this.options.rangeSelectColor,stroke:!1}).toBack().hide(),this.el.bind("mousedown",function(a){var b;return b=c.el.offset(),c.startRange(a.pageX-b.left)}),this.el.bind("mouseup",function(a){var b;return b=c.el.offset(),c.endRange(a.pageX-b.left),c.fire("hovermove",a.pageX-b.left,a.pageY-b.top)})),this.options.resize&&a(window).bind("resize",function(){return null!=c.timeoutId&&window.clearTimeout(c.timeoutId),c.timeoutId=window.setTimeout(c.resizeHandler,100)}),this.el.css("-webkit-tap-highlight-color","rgba(0,0,0,0)"),this.postInit&&this.postInit()}return h(d,c),d.prototype.gridDefaults={dateFormat:null,axes:!0,grid:!0,gridLineColor:"#aaa",gridStrokeWidth:.5,gridTextColor:"#888",gridTextSize:12,gridTextFamily:"sans-serif",gridTextWeight:"normal",hideHover:!1,yLabelFormat:null,xLabelAngle:0,numLines:5,padding:25,parseTime:!0,postUnits:"",preUnits:"",ymax:"auto",ymin:"auto 0",goals:[],goalStrokeWidth:1,goalLineColors:["#666633","#999966","#cc6666","#663333"],events:[],eventStrokeWidth:1,eventLineColors:["#005a04","#ccffbb","#3a5f0b","#005502"],rangeSelect:null,rangeSelectColor:"#eef",resize:!1},d.prototype.setData=function(a,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;return null==c&&(c=!0),this.options.data=a,null==a||0===a.length?(this.data=[],this.raphael.clear(),null!=this.hover&&this.hover.hide(),void 0):(o=this.cumulative?0:null,p=this.cumulative?0:null,this.options.goals.length>0&&(h=Math.min.apply(Math,this.options.goals),g=Math.max.apply(Math,this.options.goals),p=null!=p?Math.min(p,h):h,o=null!=o?Math.max(o,g):g),this.data=function(){var c,d,g;for(g=[],f=c=0,d=a.length;d>c;f=++c)j=a[f],i={src:j},i.label=j[this.options.xkey],this.options.parseTime?(i.x=b.parseDate(i.label),this.options.dateFormat?i.label=this.options.dateFormat(i.x):"number"==typeof i.label&&(i.label=new Date(i.label).toString())):(i.x=f,this.options.xLabelFormat&&(i.label=this.options.xLabelFormat(i))),l=0,i.y=function(){var a,b,c,d;for(c=this.options.ykeys,d=[],e=a=0,b=c.length;b>a;e=++a)n=c[e],q=j[n],"string"==typeof q&&(q=parseFloat(q)),null!=q&&"number"!=typeof q&&(q=null),null!=q&&(this.cumulative?l+=q:null!=o?(o=Math.max(q,o),p=Math.min(q,p)):o=p=q),this.cumulative&&null!=l&&(o=Math.max(l,o),p=Math.min(l,p)),d.push(q);return d}.call(this),g.push(i);return g}.call(this),this.options.parseTime&&(this.data=this.data.sort(function(a,b){return(a.x>b.x)-(b.x>a.x)})),this.xmin=this.data[0].x,this.xmax=this.data[this.data.length-1].x,this.events=[],this.options.events.length>0&&(this.events=this.options.parseTime?function(){var a,c,e,f;for(e=this.options.events,f=[],a=0,c=e.length;c>a;a++)d=e[a],f.push(b.parseDate(d));return f}.call(this):this.options.events,this.xmax=Math.max(this.xmax,Math.max.apply(Math,this.events)),this.xmin=Math.min(this.xmin,Math.min.apply(Math,this.events))),this.xmin===this.xmax&&(this.xmin-=1,this.xmax+=1),this.ymin=this.yboundary("min",p),this.ymax=this.yboundary("max",o),this.ymin===this.ymax&&(p&&(this.ymin-=1),this.ymax+=1),((r=this.options.axes)===!0||"both"===r||"y"===r||this.options.grid===!0)&&(this.options.ymax===this.gridDefaults.ymax&&this.options.ymin===this.gridDefaults.ymin?(this.grid=this.autoGridLines(this.ymin,this.ymax,this.options.numLines),this.ymin=Math.min(this.ymin,this.grid[0]),this.ymax=Math.max(this.ymax,this.grid[this.grid.length-1])):(k=(this.ymax-this.ymin)/(this.options.numLines-1),this.grid=function(){var a,b,c,d;for(d=[],m=a=b=this.ymin,c=this.ymax;k>0?c>=a:a>=c;m=a+=k)d.push(m);return d}.call(this))),this.dirty=!0,c?this.redraw():void 0)},d.prototype.yboundary=function(a,b){var c,d;return c=this.options["y"+a],"string"==typeof c?"auto"===c.slice(0,4)?c.length>5?(d=parseInt(c.slice(5),10),null==b?d:Math[a](b,d)):null!=b?b:0:parseInt(c,10):c},d.prototype.autoGridLines=function(a,b,c){var d,e,f,g,h,i,j,k,l;return h=b-a,l=Math.floor(Math.log(h)/Math.log(10)),j=Math.pow(10,l),e=Math.floor(a/j)*j,d=Math.ceil(b/j)*j,i=(d-e)/(c-1),1===j&&i>1&&Math.ceil(i)!==i&&(i=Math.ceil(i),d=e+i*(c-1)),0>e&&d>0&&(e=Math.floor(a/i)*i,d=Math.ceil(b/i)*i),1>i?(g=Math.floor(Math.log(i)/Math.log(10)),f=function(){var a,b;for(b=[],k=a=e;i>0?d>=a:a>=d;k=a+=i)b.push(parseFloat(k.toFixed(1-g)));return b}()):f=function(){var a,b;for(b=[],k=a=e;i>0?d>=a:a>=d;k=a+=i)b.push(k);return b}(),f},d.prototype._calc=function(){var a,b,c,d,e,f,g,h;return e=this.el.width(),c=this.el.height(),(this.elementWidth!==e||this.elementHeight!==c||this.dirty)&&(this.elementWidth=e,this.elementHeight=c,this.dirty=!1,this.left=this.options.padding,this.right=this.elementWidth-this.options.padding,this.top=this.options.padding,this.bottom=this.elementHeight-this.options.padding,((g=this.options.axes)===!0||"both"===g||"y"===g)&&(f=function(){var a,c,d,e;for(d=this.grid,e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(this.measureText(this.yAxisFormat(b)).width);return e}.call(this),this.left+=Math.max.apply(Math,f)),((h=this.options.axes)===!0||"both"===h||"x"===h)&&(a=function(){var a,b,c;for(c=[],d=a=0,b=this.data.length;b>=0?b>a:a>b;d=b>=0?++a:--a)c.push(this.measureText(this.data[d].text,-this.options.xLabelAngle).height);return c}.call(this),this.bottom-=Math.max.apply(Math,a)),this.width=Math.max(1,this.right-this.left),this.height=Math.max(1,this.bottom-this.top),this.dx=this.width/(this.xmax-this.xmin),this.dy=this.height/(this.ymax-this.ymin),this.calc)?this.calc():void 0},d.prototype.transY=function(a){return this.bottom-(a-this.ymin)*this.dy},d.prototype.transX=function(a){return 1===this.data.length?(this.left+this.right)/2:this.left+(a-this.xmin)*this.dx},d.prototype.redraw=function(){return this.raphael.clear(),this._calc(),this.drawGrid(),this.drawGoals(),this.drawEvents(),this.draw?this.draw():void 0},d.prototype.measureText=function(a,b){var c,d;return null==b&&(b=0),d=this.raphael.text(100,100,a).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).rotate(b),c=d.getBBox(),d.remove(),c},d.prototype.yAxisFormat=function(a){return this.yLabelFormat(a)},d.prototype.yLabelFormat=function(a){return"function"==typeof this.options.yLabelFormat?this.options.yLabelFormat(a):""+this.options.preUnits+b.commas(a)+this.options.postUnits},d.prototype.drawGrid=function(){var a,b,c,d,e,f,g,h;if(this.options.grid!==!1||(e=this.options.axes)===!0||"both"===e||"y"===e){for(f=this.grid,h=[],c=0,d=f.length;d>c;c++)a=f[c],b=this.transY(a),((g=this.options.axes)===!0||"both"===g||"y"===g)&&this.drawYAxisLabel(this.left-this.options.padding/2,b,this.yAxisFormat(a)),this.options.grid?h.push(this.drawGridLine("M"+this.left+","+b+"H"+(this.left+this.width))):h.push(void 0);return h}},d.prototype.drawGoals=function(){var a,b,c,d,e,f,g;for(f=this.options.goals,g=[],c=d=0,e=f.length;e>d;c=++d)b=f[c],a=this.options.goalLineColors[c%this.options.goalLineColors.length],g.push(this.drawGoal(b,a));return g},d.prototype.drawEvents=function(){var a,b,c,d,e,f,g;for(f=this.events,g=[],c=d=0,e=f.length;e>d;c=++d)b=f[c],a=this.options.eventLineColors[c%this.options.eventLineColors.length],g.push(this.drawEvent(b,a));return g},d.prototype.drawGoal=function(a,b){return this.raphael.path("M"+this.left+","+this.transY(a)+"H"+this.right).attr("stroke",b).attr("stroke-width",this.options.goalStrokeWidth)},d.prototype.drawEvent=function(a,b){return this.raphael.path("M"+this.transX(a)+","+this.bottom+"V"+this.top).attr("stroke",b).attr("stroke-width",this.options.eventStrokeWidth)},d.prototype.drawYAxisLabel=function(a,b,c){return this.raphael.text(a,b,c).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor).attr("text-anchor","end")},d.prototype.drawGridLine=function(a){return this.raphael.path(a).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth)},d.prototype.startRange=function(a){return this.hover.hide(),this.selectFrom=a,this.selectionRect.attr({x:a,width:0}).show()},d.prototype.endRange=function(a){var b,c;return this.selectFrom?(c=Math.min(this.selectFrom,a),b=Math.max(this.selectFrom,a),this.options.rangeSelect.call(this.el,{start:this.data[this.hitTest(c)].x,end:this.data[this.hitTest(b)].x}),this.selectFrom=null):void 0},d.prototype.resizeHandler=function(){return this.timeoutId=null,this.raphael.setSize(this.el.width(),this.el.height()),this.redraw()},d}(b.EventEmitter),b.parseDate=function(a){var b,c,d,e,f,g,h,i,j,k,l;return"number"==typeof a?a:(c=a.match(/^(\d+) Q(\d)$/),e=a.match(/^(\d+)-(\d+)$/),f=a.match(/^(\d+)-(\d+)-(\d+)$/),h=a.match(/^(\d+) W(\d+)$/),i=a.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/),j=a.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/),c?new Date(parseInt(c[1],10),3*parseInt(c[2],10)-1,1).getTime():e?new Date(parseInt(e[1],10),parseInt(e[2],10)-1,1).getTime():f?new Date(parseInt(f[1],10),parseInt(f[2],10)-1,parseInt(f[3],10)).getTime():h?(k=new Date(parseInt(h[1],10),0,1),4!==k.getDay()&&k.setMonth(0,1+(4-k.getDay()+7)%7),k.getTime()+6048e5*parseInt(h[2],10)):i?i[6]?(g=0,"Z"!==i[6]&&(g=60*parseInt(i[8],10)+parseInt(i[9],10),"+"===i[7]&&(g=0-g)),Date.UTC(parseInt(i[1],10),parseInt(i[2],10)-1,parseInt(i[3],10),parseInt(i[4],10),parseInt(i[5],10)+g)):new Date(parseInt(i[1],10),parseInt(i[2],10)-1,parseInt(i[3],10),parseInt(i[4],10),parseInt(i[5],10)).getTime():j?(l=parseFloat(j[6]),b=Math.floor(l),d=Math.round(1e3*(l-b)),j[8]?(g=0,"Z"!==j[8]&&(g=60*parseInt(j[10],10)+parseInt(j[11],10),"+"===j[9]&&(g=0-g)),Date.UTC(parseInt(j[1],10),parseInt(j[2],10)-1,parseInt(j[3],10),parseInt(j[4],10),parseInt(j[5],10)+g,b,d)):new Date(parseInt(j[1],10),parseInt(j[2],10)-1,parseInt(j[3],10),parseInt(j[4],10),parseInt(j[5],10),b,d).getTime()):new Date(parseInt(a,10),0,1).getTime())},b.Hover=function(){function c(c){null==c&&(c={}),this.options=a.extend({},b.Hover.defaults,c),this.el=a(""),this.el.hide(),this.options.parent.append(this.el)}return c.defaults={"class":"morris-hover morris-default-style"},c.prototype.update=function(a,b,c){return a?(this.html(a),this.show(),this.moveTo(b,c)):this.hide()},c.prototype.html=function(a){return this.el.html(a)},c.prototype.moveTo=function(a,b){var c,d,e,f,g,h;return g=this.options.parent.innerWidth(),f=this.options.parent.innerHeight(),d=this.el.outerWidth(),c=this.el.outerHeight(),e=Math.min(Math.max(0,a-d/2),g-d),null!=b?(h=b-c-10,0>h&&(h=b+10,h+c>f&&(h=f/2-c/2))):h=f/2-c/2,this.el.css({left:e+"px",top:parseInt(h)+"px"})},c.prototype.show=function(){return this.el.show()},c.prototype.hide=function(){return this.el.hide()},c}(),b.Line=function(a){function c(a){return this.hilight=f(this.hilight,this),this.onHoverOut=f(this.onHoverOut,this),this.onHoverMove=f(this.onHoverMove,this),this.onGridClick=f(this.onGridClick,this),this instanceof b.Line?(c.__super__.constructor.call(this,a),void 0):new b.Line(a)}return h(c,a),c.prototype.init=function(){return"always"!==this.options.hideHover?(this.hover=new b.Hover({parent:this.el}),this.on("hovermove",this.onHoverMove),this.on("hoverout",this.onHoverOut),this.on("gridclick",this.onGridClick)):void 0},c.prototype.defaults={lineWidth:3,pointSize:4,lineColors:["#0b62a4","#7A92A3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],pointStrokeWidths:[1],pointStrokeColors:["#ffffff"],pointFillColors:[],smooth:!0,xLabels:"auto",xLabelFormat:null,xLabelMargin:24,hideHover:!1},c.prototype.calc=function(){return this.calcPoints(),this.generatePaths()},c.prototype.calcPoints=function(){var a,b,c,d,e,f;for(e=this.data,f=[],c=0,d=e.length;d>c;c++)a=e[c],a._x=this.transX(a.x),a._y=function(){var c,d,e,f;for(e=a.y,f=[],c=0,d=e.length;d>c;c++)b=e[c],null!=b?f.push(this.transY(b)):f.push(b);return f}.call(this),f.push(a._ymax=Math.min.apply(Math,[this.bottom].concat(function(){var c,d,e,f;for(e=a._y,f=[],c=0,d=e.length;d>c;c++)b=e[c],null!=b&&f.push(b);return f}())));return f},c.prototype.hitTest=function(a){var b,c,d,e,f;if(0===this.data.length)return null;for(f=this.data.slice(1),b=d=0,e=f.length;e>d&&(c=f[b],!(a<(c._x+this.data[b]._x)/2));b=++d);return b},c.prototype.onGridClick=function(a,b){var c;return c=this.hitTest(a),this.fire("click",c,this.data[c].src,a,b)},c.prototype.onHoverMove=function(a){var b;return b=this.hitTest(a),this.displayHoverForRow(b)},c.prototype.onHoverOut=function(){return this.options.hideHover!==!1?this.displayHoverForRow(null):void 0},c.prototype.displayHoverForRow=function(a){var b;return null!=a?((b=this.hover).update.apply(b,this.hoverContentForRow(a)),this.hilight(a)):(this.hover.hide(),this.hilight())},c.prototype.hoverContentForRow=function(a){var b,c,d,e,f,g,h;for(d=this.data[a],b=""+d.label+"
",h=d.y,c=f=0,g=h.length;g>f;c=++f)e=h[c],b+="\n "+this.options.labels[c]+":\n "+this.yLabelFormat(e)+"\n
";return"function"==typeof this.options.hoverCallback&&(b=this.options.hoverCallback(a,this.options,b,d.src)),[b,d._x,d._ymax]},c.prototype.generatePaths=function(){var a,c,d,e;return this.paths=function(){var f,g,h,j;for(j=[],c=f=0,g=this.options.ykeys.length;g>=0?g>f:f>g;c=g>=0?++f:--f)e="boolean"==typeof this.options.smooth?this.options.smooth:(h=this.options.ykeys[c],i.call(this.options.smooth,h)>=0),a=function(){var a,b,e,f;for(e=this.data,f=[],a=0,b=e.length;b>a;a++)d=e[a],void 0!==d._y[c]&&f.push({x:d._x,y:d._y[c]});return f}.call(this),a.length>1?j.push(b.Line.createPath(a,e,this.bottom)):j.push(null);return j}.call(this)},c.prototype.draw=function(){var a;return((a=this.options.axes)===!0||"both"===a||"x"===a)&&this.drawXAxis(),this.drawSeries(),this.options.hideHover===!1?this.displayHoverForRow(this.data.length-1):void 0},c.prototype.drawXAxis=function(){var a,c,d,e,f,g,h,i,j,k,l=this;for(h=this.bottom+this.options.padding/2,f=null,e=null,a=function(a,b){var c,d,g,i,j;return c=l.drawXAxisLabel(l.transX(b),h,a),j=c.getBBox(),c.transform("r"+-l.options.xLabelAngle),d=c.getBBox(),c.transform("t0,"+d.height/2+"..."),0!==l.options.xLabelAngle&&(i=-.5*j.width*Math.cos(l.options.xLabelAngle*Math.PI/180),c.transform("t"+i+",0...")),d=c.getBBox(),(null==f||f>=d.x+d.width||null!=e&&e>=d.x)&&d.x>=0&&d.x+d.widtha;a++)g=c[a],d.push([g.label,g.x]);return d}.call(this),d.reverse(),k=[],i=0,j=d.length;j>i;i++)c=d[i],k.push(a(c[0],c[1]));return k},c.prototype.drawSeries=function(){var a,b,c,d,e,f;for(this.seriesPoints=[],a=b=d=this.options.ykeys.length-1;0>=d?0>=b:b>=0;a=0>=d?++b:--b)this._drawLineFor(a);for(f=[],a=c=e=this.options.ykeys.length-1;0>=e?0>=c:c>=0;a=0>=e?++c:--c)f.push(this._drawPointFor(a));return f},c.prototype._drawPointFor=function(a){var b,c,d,e,f,g;for(this.seriesPoints[a]=[],f=this.data,g=[],d=0,e=f.length;e>d;d++)c=f[d],b=null,null!=c._y[a]&&(b=this.drawLinePoint(c._x,c._y[a],this.colorFor(c,a,"point"),a)),g.push(this.seriesPoints[a].push(b));return g},c.prototype._drawLineFor=function(a){var b;return b=this.paths[a],null!==b?this.drawLinePath(b,this.colorFor(null,a,"line"),a):void 0},c.createPath=function(a,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r;for(k="",c&&(g=b.Line.gradients(a)),l={y:null},h=q=0,r=a.length;r>q;h=++q)e=a[h],null!=e.y&&(null!=l.y?c?(f=g[h],j=g[h-1],i=(e.x-l.x)/4,m=l.x+i,o=Math.min(d,l.y+i*j),n=e.x-i,p=Math.min(d,e.y-i*f),k+="C"+m+","+o+","+n+","+p+","+e.x+","+e.y):k+="L"+e.x+","+e.y:c&&null==g[h]||(k+="M"+e.x+","+e.y)),l=e;return k},c.gradients=function(a){var b,c,d,e,f,g,h,i;for(c=function(a,b){return(a.y-b.y)/(a.x-b.x)},i=[],d=g=0,h=a.length;h>g;d=++g)b=a[d],null!=b.y?(e=a[d+1]||{y:null},f=a[d-1]||{y:null},null!=f.y&&null!=e.y?i.push(c(f,e)):null!=f.y?i.push(c(f,b)):null!=e.y?i.push(c(b,e)):i.push(null)):i.push(null);return i},c.prototype.hilight=function(a){var b,c,d,e,f;if(null!==this.prevHilight&&this.prevHilight!==a)for(b=c=0,e=this.seriesPoints.length-1;e>=0?e>=c:c>=e;b=e>=0?++c:--c)this.seriesPoints[b][this.prevHilight]&&this.seriesPoints[b][this.prevHilight].animate(this.pointShrinkSeries(b));if(null!==a&&this.prevHilight!==a)for(b=d=0,f=this.seriesPoints.length-1;f>=0?f>=d:d>=f;b=f>=0?++d:--d)this.seriesPoints[b][a]&&this.seriesPoints[b][a].animate(this.pointGrowSeries(b));return this.prevHilight=a},c.prototype.colorFor=function(a,b,c){return"function"==typeof this.options.lineColors?this.options.lineColors.call(this,a,b,c):"point"===c?this.options.pointFillColors[b%this.options.pointFillColors.length]||this.options.lineColors[b%this.options.lineColors.length]:this.options.lineColors[b%this.options.lineColors.length]},c.prototype.drawXAxisLabel=function(a,b,c){return this.raphael.text(a,b,c).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)},c.prototype.drawLinePath=function(a,b,c){return this.raphael.path(a).attr("stroke",b).attr("stroke-width",this.lineWidthForSeries(c))},c.prototype.drawLinePoint=function(a,b,c,d){return this.raphael.circle(a,b,this.pointSizeForSeries(d)).attr("fill",c).attr("stroke-width",this.pointStrokeWidthForSeries(d)).attr("stroke",this.pointStrokeColorForSeries(d))},c.prototype.pointStrokeWidthForSeries=function(a){return this.options.pointStrokeWidths[a%this.options.pointStrokeWidths.length]},c.prototype.pointStrokeColorForSeries=function(a){return this.options.pointStrokeColors[a%this.options.pointStrokeColors.length]},c.prototype.lineWidthForSeries=function(a){return this.options.lineWidth instanceof Array?this.options.lineWidth[a%this.options.lineWidth.length]:this.options.lineWidth},c.prototype.pointSizeForSeries=function(a){return this.options.pointSize instanceof Array?this.options.pointSize[a%this.options.pointSize.length]:this.options.pointSize},c.prototype.pointGrowSeries=function(a){return Raphael.animation({r:this.pointSizeForSeries(a)+3},25,"linear")},c.prototype.pointShrinkSeries=function(a){return Raphael.animation({r:this.pointSizeForSeries(a)},25,"linear")},c}(b.Grid),b.labelSeries=function(c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r;if(j=200*(d-c)/e,i=new Date(c),n=b.LABEL_SPECS[f],void 0===n)for(r=b.AUTO_LABEL_ORDER,p=0,q=r.length;q>p;p++)if(k=r[p],m=b.LABEL_SPECS[k],j>=m.span){n=m;break}for(void 0===n&&(n=b.LABEL_SPECS.second),g&&(n=a.extend({},n,{fmt:g})),h=n.start(i),l=[];(o=h.getTime())<=d;)o>=c&&l.push([n.fmt(h),o]),n.incr(h);return l},c=function(a){return{span:60*a*1e3,start:function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours())},fmt:function(a){return""+b.pad2(a.getHours())+":"+b.pad2(a.getMinutes())},incr:function(b){return b.setUTCMinutes(b.getUTCMinutes()+a)}}},d=function(a){return{span:1e3*a,start:function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes())},fmt:function(a){return""+b.pad2(a.getHours())+":"+b.pad2(a.getMinutes())+":"+b.pad2(a.getSeconds())},incr:function(b){return b.setUTCSeconds(b.getUTCSeconds()+a)}}},b.LABEL_SPECS={decade:{span:1728e8,start:function(a){return new Date(a.getFullYear()-a.getFullYear()%10,0,1)},fmt:function(a){return""+a.getFullYear()},incr:function(a){return a.setFullYear(a.getFullYear()+10)}},year:{span:1728e7,start:function(a){return new Date(a.getFullYear(),0,1)},fmt:function(a){return""+a.getFullYear()},incr:function(a){return a.setFullYear(a.getFullYear()+1)}},month:{span:24192e5,start:function(a){return new Date(a.getFullYear(),a.getMonth(),1)},fmt:function(a){return""+a.getFullYear()+"-"+b.pad2(a.getMonth()+1)},incr:function(a){return a.setMonth(a.getMonth()+1)}},week:{span:6048e5,start:function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())},fmt:function(a){return""+a.getFullYear()+"-"+b.pad2(a.getMonth()+1)+"-"+b.pad2(a.getDate())},incr:function(a){return a.setDate(a.getDate()+7)}},day:{span:864e5,start:function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())},fmt:function(a){return""+a.getFullYear()+"-"+b.pad2(a.getMonth()+1)+"-"+b.pad2(a.getDate())},incr:function(a){return a.setDate(a.getDate()+1)}},hour:c(60),"30min":c(30),"15min":c(15),"10min":c(10),"5min":c(5),minute:c(1),"30sec":d(30),"15sec":d(15),"10sec":d(10),"5sec":d(5),second:d(1)},b.AUTO_LABEL_ORDER=["decade","year","month","week","day","hour","30min","15min","10min","5min","minute","30sec","15sec","10sec","5sec","second"],b.Area=function(c){function d(c){var f;return this instanceof b.Area?(f=a.extend({},e,c),this.cumulative=!f.behaveLikeLine,"auto"===f.fillOpacity&&(f.fillOpacity=f.behaveLikeLine?.8:1),d.__super__.constructor.call(this,f),void 0):new b.Area(c)}var e;return h(d,c),e={fillOpacity:"auto",behaveLikeLine:!1},d.prototype.calcPoints=function(){var a,b,c,d,e,f,g;for(f=this.data,g=[],d=0,e=f.length;e>d;d++)a=f[d],a._x=this.transX(a.x),b=0,a._y=function(){var d,e,f,g;for(f=a.y,g=[],d=0,e=f.length;e>d;d++)c=f[d],this.options.behaveLikeLine?g.push(this.transY(c)):(b+=c||0,g.push(this.transY(b)));return g}.call(this),g.push(a._ymax=Math.max.apply(Math,a._y));return g},d.prototype.drawSeries=function(){var a,b,c,d,e,f,g,h;for(this.seriesPoints=[],b=this.options.behaveLikeLine?function(){f=[];for(var a=0,b=this.options.ykeys.length-1;b>=0?b>=a:a>=b;b>=0?a++:a--)f.push(a);return f}.apply(this):function(){g=[];for(var a=e=this.options.ykeys.length-1;0>=e?0>=a:a>=0;0>=e?a++:a--)g.push(a);return g}.apply(this),h=[],c=0,d=b.length;d>c;c++)a=b[c],this._drawFillFor(a),this._drawLineFor(a),h.push(this._drawPointFor(a));return h},d.prototype._drawFillFor=function(a){var b;return b=this.paths[a],null!==b?(b+="L"+this.transX(this.xmax)+","+this.bottom+"L"+this.transX(this.xmin)+","+this.bottom+"Z",this.drawFilledPath(b,this.fillForSeries(a))):void 0},d.prototype.fillForSeries=function(a){var b;return b=Raphael.rgb2hsl(this.colorFor(this.data[a],a,"line")),Raphael.hsl(b.h,this.options.behaveLikeLine?.9*b.s:.75*b.s,Math.min(.98,this.options.behaveLikeLine?1.2*b.l:1.25*b.l))},d.prototype.drawFilledPath=function(a,b){return this.raphael.path(a).attr("fill",b).attr("fill-opacity",this.options.fillOpacity).attr("stroke","none")},d}(b.Line),b.Bar=function(c){function d(c){return this.onHoverOut=f(this.onHoverOut,this),this.onHoverMove=f(this.onHoverMove,this),this.onGridClick=f(this.onGridClick,this),this instanceof b.Bar?(d.__super__.constructor.call(this,a.extend({},c,{parseTime:!1})),void 0):new b.Bar(c)}return h(d,c),d.prototype.init=function(){return this.cumulative=this.options.stacked,"always"!==this.options.hideHover?(this.hover=new b.Hover({parent:this.el}),this.on("hovermove",this.onHoverMove),this.on("hoverout",this.onHoverOut),this.on("gridclick",this.onGridClick)):void 0},d.prototype.defaults={barSizeRatio:.75,barGap:3,barColors:["#0b62a4","#7a92a3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],barOpacity:1,barRadius:[0,0,0,0],xLabelMargin:50},d.prototype.calc=function(){var a;return this.calcBars(),this.options.hideHover===!1?(a=this.hover).update.apply(a,this.hoverContentForRow(this.data.length-1)):void 0},d.prototype.calcBars=function(){var a,b,c,d,e,f,g;for(f=this.data,g=[],a=d=0,e=f.length;e>d;a=++d)b=f[a],b._x=this.left+this.width*(a+.5)/this.data.length,g.push(b._y=function(){var a,d,e,f;for(e=b.y,f=[],a=0,d=e.length;d>a;a++)c=e[a],null!=c?f.push(this.transY(c)):f.push(null);return f}.call(this));return g},d.prototype.draw=function(){var a;return((a=this.options.axes)===!0||"both"===a||"x"===a)&&this.drawXAxis(),this.drawSeries()},d.prototype.drawXAxis=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;for(j=this.bottom+(this.options.xAxisLabelTopPadding||this.options.padding/2),g=null,f=null,m=[],a=k=0,l=this.data.length;l>=0?l>k:k>l;a=l>=0?++k:--k)h=this.data[this.data.length-1-a],b=this.drawXAxisLabel(h._x,j,h.label),i=b.getBBox(),b.transform("r"+-this.options.xLabelAngle),c=b.getBBox(),b.transform("t0,"+c.height/2+"..."),0!==this.options.xLabelAngle&&(e=-.5*i.width*Math.cos(this.options.xLabelAngle*Math.PI/180),b.transform("t"+e+",0...")),(null==g||g>=c.x+c.width||null!=f&&f>=c.x)&&c.x>=0&&c.x+c.width=0?this.transY(0):null,this.bars=function(){var h,l,p,q;for(p=this.data,q=[],d=h=0,l=p.length;l>h;d=++h)i=p[d],e=0,q.push(function(){var h,l,p,q;for(p=i._y,q=[],j=h=0,l=p.length;l>h;j=++h)n=p[j],null!==n?(o?(m=Math.min(n,o),b=Math.max(n,o)):(m=n,b=this.bottom),f=this.left+d*c+g,this.options.stacked||(f+=j*(a+this.options.barGap)),k=b-m,this.options.verticalGridCondition&&this.options.verticalGridCondition(i.x)&&this.drawBar(this.left+d*c,this.top,c,Math.abs(this.top-this.bottom),this.options.verticalGridColor,this.options.verticalGridOpacity,this.options.barRadius),this.options.stacked&&(m-=e),this.drawBar(f,m,a,k,this.colorFor(i,j,"bar"),this.options.barOpacity,this.options.barRadius),q.push(e+=k)):q.push(null);return q}.call(this));return q}.call(this)},d.prototype.colorFor=function(a,b,c){var d,e;return"function"==typeof this.options.barColors?(d={x:a.x,y:a.y[b],label:a.label},e={index:b,key:this.options.ykeys[b],label:this.options.labels[b]},this.options.barColors.call(this,d,e,c)):this.options.barColors[b%this.options.barColors.length]},d.prototype.hitTest=function(a){return 0===this.data.length?null:(a=Math.max(Math.min(a,this.right),this.left),Math.min(this.data.length-1,Math.floor((a-this.left)/(this.width/this.data.length))))},d.prototype.onGridClick=function(a,b){var c;return c=this.hitTest(a),this.fire("click",c,this.data[c].src,a,b)},d.prototype.onHoverMove=function(a){var b,c;return b=this.hitTest(a),(c=this.hover).update.apply(c,this.hoverContentForRow(b))},d.prototype.onHoverOut=function(){return this.options.hideHover!==!1?this.hover.hide():void 0},d.prototype.hoverContentForRow=function(a){var b,c,d,e,f,g,h,i;for(d=this.data[a],b=""+d.label+"
",i=d.y,c=g=0,h=i.length;h>g;c=++g)f=i[c],b+="\n "+this.options.labels[c]+":\n "+this.yLabelFormat(f)+"\n
";return"function"==typeof this.options.hoverCallback&&(b=this.options.hoverCallback(a,this.options,b,d.src)),e=this.left+(a+.5)*this.width/this.data.length,[b,e]},d.prototype.drawXAxisLabel=function(a,b,c){var d;return d=this.raphael.text(a,b,c).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)},d.prototype.drawBar=function(a,b,c,d,e,f,g){var h,i;return h=Math.max.apply(Math,g),i=0===h||h>d?this.raphael.rect(a,b,c,d):this.raphael.path(this.roundedRect(a,b,c,d,g)),i.attr("fill",e).attr("fill-opacity",f).attr("stroke","none")},d.prototype.roundedRect=function(a,b,c,d,e){return null==e&&(e=[0,0,0,0]),["M",a,e[0]+b,"Q",a,b,a+e[0],b,"L",a+c-e[1],b,"Q",a+c,b,a+c,b+e[1],"L",a+c,b+d-e[2],"Q",a+c,b+d,a+c-e[2],b+d,"L",a+e[3],b+d,"Q",a,b+d,a,b+d-e[3],"Z"]},d}(b.Grid),b.Donut=function(c){function d(c){this.resizeHandler=f(this.resizeHandler,this),this.select=f(this.select,this),this.click=f(this.click,this);var d=this;if(!(this instanceof b.Donut))return new b.Donut(c);if(this.options=a.extend({},this.defaults,c),this.el="string"==typeof c.element?a(document.getElementById(c.element)):a(c.element),null===this.el||0===this.el.length)throw new Error("Graph placeholder not found.");void 0!==c.data&&0!==c.data.length&&(this.raphael=new Raphael(this.el[0]),this.options.resize&&a(window).bind("resize",function(){return null!=d.timeoutId&&window.clearTimeout(d.timeoutId),d.timeoutId=window.setTimeout(d.resizeHandler,100)}),this.setData(c.data))}return h(d,c),d.prototype.defaults={colors:["#0B62A4","#3980B5","#679DC6","#95BBD7","#B0CCE1","#095791","#095085","#083E67","#052C48","#042135"],backgroundColor:"#FFFFFF",labelColor:"#000000",formatter:b.commas,resize:!1},d.prototype.redraw=function(){var a,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x;for(this.raphael.clear(),c=this.el.width()/2,d=this.el.height()/2,n=(Math.min(c,d)-10)/3,l=0,u=this.values,o=0,r=u.length;r>o;o++)m=u[o],l+=m;for(i=5/(2*n),a=1.9999*Math.PI-i*this.data.length,g=0,f=0,this.segments=[],v=this.values,e=p=0,s=v.length;s>p;e=++p)m=v[e],j=g+i+a*(m/l),k=new b.DonutSegment(c,d,2*n,n,g,j,this.data[e].color||this.options.colors[f%this.options.colors.length],this.options.backgroundColor,f,this.raphael),k.render(),this.segments.push(k),k.on("hover",this.select),k.on("click",this.click),g=j,f+=1;for(this.text1=this.drawEmptyDonutLabel(c,d-10,this.options.labelColor,15,800),this.text2=this.drawEmptyDonutLabel(c,d+10,this.options.labelColor,14),h=Math.max.apply(Math,this.values),f=0,w=this.values,x=[],q=0,t=w.length;t>q;q++){if(m=w[q],m===h){this.select(f);
+break}x.push(f+=1)}return x},d.prototype.setData=function(a){var b;return this.data=a,this.values=function(){var a,c,d,e;for(d=this.data,e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(parseFloat(b.value));return e}.call(this),this.redraw()},d.prototype.click=function(a){return this.fire("click",a,this.data[a])},d.prototype.select=function(a){var b,c,d,e,f,g;for(g=this.segments,e=0,f=g.length;f>e;e++)c=g[e],c.deselect();return d=this.segments[a],d.select(),b=this.data[a],this.setLabels(b.label,this.options.formatter(b.value,b))},d.prototype.setLabels=function(a,b){var c,d,e,f,g,h,i,j;return c=2*(Math.min(this.el.width()/2,this.el.height()/2)-10)/3,f=1.8*c,e=c/2,d=c/3,this.text1.attr({text:a,transform:""}),g=this.text1.getBBox(),h=Math.min(f/g.width,e/g.height),this.text1.attr({transform:"S"+h+","+h+","+(g.x+g.width/2)+","+(g.y+g.height)}),this.text2.attr({text:b,transform:""}),i=this.text2.getBBox(),j=Math.min(f/i.width,d/i.height),this.text2.attr({transform:"S"+j+","+j+","+(i.x+i.width/2)+","+i.y})},d.prototype.drawEmptyDonutLabel=function(a,b,c,d,e){var f;return f=this.raphael.text(a,b,"").attr("font-size",d).attr("fill",c),null!=e&&f.attr("font-weight",e),f},d.prototype.resizeHandler=function(){return this.timeoutId=null,this.raphael.setSize(this.el.width(),this.el.height()),this.redraw()},d}(b.EventEmitter),b.DonutSegment=function(a){function b(a,b,c,d,e,g,h,i,j,k){this.cx=a,this.cy=b,this.inner=c,this.outer=d,this.color=h,this.backgroundColor=i,this.index=j,this.raphael=k,this.deselect=f(this.deselect,this),this.select=f(this.select,this),this.sin_p0=Math.sin(e),this.cos_p0=Math.cos(e),this.sin_p1=Math.sin(g),this.cos_p1=Math.cos(g),this.is_long=g-e>Math.PI?1:0,this.path=this.calcSegment(this.inner+3,this.inner+this.outer-5),this.selectedPath=this.calcSegment(this.inner+3,this.inner+this.outer),this.hilight=this.calcArc(this.inner)}return h(b,a),b.prototype.calcArcPoints=function(a){return[this.cx+a*this.sin_p0,this.cy+a*this.cos_p0,this.cx+a*this.sin_p1,this.cy+a*this.cos_p1]},b.prototype.calcSegment=function(a,b){var c,d,e,f,g,h,i,j,k,l;return k=this.calcArcPoints(a),c=k[0],e=k[1],d=k[2],f=k[3],l=this.calcArcPoints(b),g=l[0],i=l[1],h=l[2],j=l[3],"M"+c+","+e+("A"+a+","+a+",0,"+this.is_long+",0,"+d+","+f)+("L"+h+","+j)+("A"+b+","+b+",0,"+this.is_long+",1,"+g+","+i)+"Z"},b.prototype.calcArc=function(a){var b,c,d,e,f;return f=this.calcArcPoints(a),b=f[0],d=f[1],c=f[2],e=f[3],"M"+b+","+d+("A"+a+","+a+",0,"+this.is_long+",0,"+c+","+e)},b.prototype.render=function(){var a=this;return this.arc=this.drawDonutArc(this.hilight,this.color),this.seg=this.drawDonutSegment(this.path,this.color,this.backgroundColor,function(){return a.fire("hover",a.index)},function(){return a.fire("click",a.index)})},b.prototype.drawDonutArc=function(a,b){return this.raphael.path(a).attr({stroke:b,"stroke-width":2,opacity:0})},b.prototype.drawDonutSegment=function(a,b,c,d,e){return this.raphael.path(a).attr({fill:b,stroke:c,"stroke-width":3}).hover(d).click(e)},b.prototype.select=function(){return this.selected?void 0:(this.seg.animate({path:this.selectedPath},150,"<>"),this.arc.animate({opacity:1},150,"<>"),this.selected=!0)},b.prototype.deselect=function(){return this.selected?(this.seg.animate({path:this.path},150,"<>"),this.arc.animate({opacity:0},150,"<>"),this.selected=!1):void 0},b}(b.EventEmitter)}).call(this);
\ No newline at end of file
diff --git a/code/haitiwater/static-common/vendor/nanoscroller/nanoscroller.css b/code/haitiwater/static-common/vendor/nanoscroller/nanoscroller.css
new file mode 100644
index 0000000..29b278f
--- /dev/null
+++ b/code/haitiwater/static-common/vendor/nanoscroller/nanoscroller.css
@@ -0,0 +1,55 @@
+/** initial setup **/
+.nano {
+ position : relative;
+ width : 100%;
+ height : 100%;
+ overflow : hidden;
+}
+.nano > .nano-content {
+ position : absolute;
+ overflow : scroll;
+ overflow-x : hidden;
+ top : 0;
+ right : 0;
+ bottom : 0;
+ left : 0;
+}
+.nano > .nano-content:focus {
+ outline: thin dotted;
+}
+.nano > .nano-content::-webkit-scrollbar {
+ visibility: hidden;
+}
+.has-scrollbar > .nano-content::-webkit-scrollbar {
+ visibility: visible;
+}
+.nano > .nano-pane {
+ background : rgba(0,0,0,.25);
+ position : absolute;
+ width : 10px;
+ right : 0;
+ top : 0;
+ bottom : 0;
+ visibility : hidden\9; /* Target only IE7 and IE8 with this hack */
+ opacity : .01;
+ -webkit-transition : .2s;
+ -moz-transition : .2s;
+ -o-transition : .2s;
+ transition : .2s;
+ -moz-border-radius : 5px;
+ -webkit-border-radius : 5px;
+ border-radius : 5px;
+}
+.nano > .nano-pane > .nano-slider {
+ background: #444;
+ background: rgba(0,0,0,.5);
+ position : relative;
+ margin : 0 1px;
+ -moz-border-radius : 3px;
+ -webkit-border-radius : 3px;
+ border-radius : 3px;
+}
+.nano:hover > .nano-pane, .nano-pane.active, .nano-pane.flashed {
+ visibility : visible\9; /* Target only IE7 and IE8 with this hack */
+ opacity : 0.99;
+}
\ No newline at end of file
diff --git a/code/haitiwater/static-common/vendor/nanoscroller/nanoscroller.js b/code/haitiwater/static-common/vendor/nanoscroller/nanoscroller.js
new file mode 100644
index 0000000..15c03c7
--- /dev/null
+++ b/code/haitiwater/static-common/vendor/nanoscroller/nanoscroller.js
@@ -0,0 +1,930 @@
+/*! nanoScrollerJS - v0.8.0 - 2014
+* http://jamesflorentino.github.com/nanoScrollerJS/
+* Copyright (c) 2014 James Florentino; Licensed MIT */
+(function($, window, document) {
+ "use strict";
+ var BROWSER_IS_IE7, BROWSER_SCROLLBAR_WIDTH, DOMSCROLL, DOWN, DRAG, KEYDOWN, KEYUP, MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEWHEEL, NanoScroll, PANEDOWN, RESIZE, SCROLL, SCROLLBAR, TOUCHMOVE, UP, WHEEL, cAF, defaults, getBrowserScrollbarWidth, hasTransform, isFFWithBuggyScrollbar, rAF, transform, _elementStyle, _prefixStyle, _vendor;
+ defaults = {
+
+ /**
+ a classname for the pane element.
+ @property paneClass
+ @type String
+ @default 'nano-pane'
+ */
+ paneClass: 'nano-pane',
+
+ /**
+ a classname for the slider element.
+ @property sliderClass
+ @type String
+ @default 'nano-slider'
+ */
+ sliderClass: 'nano-slider',
+
+ /**
+ a classname for the content element.
+ @property contentClass
+ @type String
+ @default 'nano-content'
+ */
+ contentClass: 'nano-content',
+
+ /**
+ a setting to enable native scrolling in iOS devices.
+ @property iOSNativeScrolling
+ @type Boolean
+ @default false
+ */
+ iOSNativeScrolling: false,
+
+ /**
+ a setting to prevent the rest of the page being
+ scrolled when user scrolls the `.content` element.
+ @property preventPageScrolling
+ @type Boolean
+ @default false
+ */
+ preventPageScrolling: false,
+
+ /**
+ a setting to disable binding to the resize event.
+ @property disableResize
+ @type Boolean
+ @default false
+ */
+ disableResize: false,
+
+ /**
+ a setting to make the scrollbar always visible.
+ @property alwaysVisible
+ @type Boolean
+ @default false
+ */
+ alwaysVisible: false,
+
+ /**
+ a default timeout for the `flash()` method.
+ @property flashDelay
+ @type Number
+ @default 1500
+ */
+ flashDelay: 1500,
+
+ /**
+ a minimum height for the `.slider` element.
+ @property sliderMinHeight
+ @type Number
+ @default 20
+ */
+ sliderMinHeight: 20,
+
+ /**
+ a maximum height for the `.slider` element.
+ @property sliderMaxHeight
+ @type Number
+ @default null
+ */
+ sliderMaxHeight: null,
+
+ /**
+ an alternate document context.
+ @property documentContext
+ @type Document
+ @default null
+ */
+ documentContext: null,
+
+ /**
+ an alternate window context.
+ @property windowContext
+ @type Window
+ @default null
+ */
+ windowContext: null
+ };
+
+ /**
+ @property SCROLLBAR
+ @type String
+ @static
+ @final
+ @private
+ */
+ SCROLLBAR = 'scrollbar';
+
+ /**
+ @property SCROLL
+ @type String
+ @static
+ @final
+ @private
+ */
+ SCROLL = 'scroll';
+
+ /**
+ @property MOUSEDOWN
+ @type String
+ @final
+ @private
+ */
+ MOUSEDOWN = 'mousedown';
+
+ /**
+ @property MOUSEMOVE
+ @type String
+ @static
+ @final
+ @private
+ */
+ MOUSEMOVE = 'mousemove';
+
+ /**
+ @property MOUSEWHEEL
+ @type String
+ @final
+ @private
+ */
+ MOUSEWHEEL = 'mousewheel';
+
+ /**
+ @property MOUSEUP
+ @type String
+ @static
+ @final
+ @private
+ */
+ MOUSEUP = 'mouseup';
+
+ /**
+ @property RESIZE
+ @type String
+ @final
+ @private
+ */
+ RESIZE = 'resize';
+
+ /**
+ @property DRAG
+ @type String
+ @static
+ @final
+ @private
+ */
+ DRAG = 'drag';
+
+ /**
+ @property UP
+ @type String
+ @static
+ @final
+ @private
+ */
+ UP = 'up';
+
+ /**
+ @property PANEDOWN
+ @type String
+ @static
+ @final
+ @private
+ */
+ PANEDOWN = 'panedown';
+
+ /**
+ @property DOMSCROLL
+ @type String
+ @static
+ @final
+ @private
+ */
+ DOMSCROLL = 'DOMMouseScroll';
+
+ /**
+ @property DOWN
+ @type String
+ @static
+ @final
+ @private
+ */
+ DOWN = 'down';
+
+ /**
+ @property WHEEL
+ @type String
+ @static
+ @final
+ @private
+ */
+ WHEEL = 'wheel';
+
+ /**
+ @property KEYDOWN
+ @type String
+ @static
+ @final
+ @private
+ */
+ KEYDOWN = 'keydown';
+
+ /**
+ @property KEYUP
+ @type String
+ @static
+ @final
+ @private
+ */
+ KEYUP = 'keyup';
+
+ /**
+ @property TOUCHMOVE
+ @type String
+ @static
+ @final
+ @private
+ */
+ TOUCHMOVE = 'touchmove';
+
+ /**
+ @property BROWSER_IS_IE7
+ @type Boolean
+ @static
+ @final
+ @private
+ */
+ BROWSER_IS_IE7 = window.navigator.appName === 'Microsoft Internet Explorer' && /msie 7./i.test(window.navigator.appVersion) && window.ActiveXObject;
+
+ /**
+ @property BROWSER_SCROLLBAR_WIDTH
+ @type Number
+ @static
+ @default null
+ @private
+ */
+ BROWSER_SCROLLBAR_WIDTH = null;
+ rAF = window.requestAnimationFrame;
+ cAF = window.cancelAnimationFrame;
+ _elementStyle = document.createElement('div').style;
+ _vendor = (function() {
+ var i, transform, vendor, vendors, _i, _len;
+ vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'];
+ for (i = _i = 0, _len = vendors.length; _i < _len; i = ++_i) {
+ vendor = vendors[i];
+ transform = vendors[i] + 'ransform';
+ if (transform in _elementStyle) {
+ return vendors[i].substr(0, vendors[i].length - 1);
+ }
+ }
+ return false;
+ })();
+ _prefixStyle = function(style) {
+ if (_vendor === false) {
+ return false;
+ }
+ if (_vendor === '') {
+ return style;
+ }
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ };
+ transform = _prefixStyle('transform');
+ hasTransform = transform !== false;
+
+ /**
+ Returns browser's native scrollbar width
+ @method getBrowserScrollbarWidth
+ @return {Number} the scrollbar width in pixels
+ @static
+ @private
+ */
+ getBrowserScrollbarWidth = function() {
+ var outer, outerStyle, scrollbarWidth;
+ outer = document.createElement('div');
+ outerStyle = outer.style;
+ outerStyle.position = 'absolute';
+ outerStyle.width = '100px';
+ outerStyle.height = '100px';
+ outerStyle.overflow = SCROLL;
+ outerStyle.top = '-9999px';
+ document.body.appendChild(outer);
+ scrollbarWidth = outer.offsetWidth - outer.clientWidth;
+ document.body.removeChild(outer);
+ return scrollbarWidth;
+ };
+ isFFWithBuggyScrollbar = function() {
+ var isOSXFF, ua, version;
+ ua = window.navigator.userAgent;
+ isOSXFF = /(?=.+Mac OS X)(?=.+Firefox)/.test(ua);
+ if (!isOSXFF) {
+ return false;
+ }
+ version = /Firefox\/\d{2}\./.exec(ua);
+ if (version) {
+ version = version[0].replace(/\D+/g, '');
+ }
+ return isOSXFF && +version > 23;
+ };
+
+ /**
+ @class NanoScroll
+ @param element {HTMLElement|Node} the main element
+ @param options {Object} nanoScroller's options
+ @constructor
+ */
+ NanoScroll = (function() {
+ function NanoScroll(el, options) {
+ this.el = el;
+ this.options = options;
+ BROWSER_SCROLLBAR_WIDTH || (BROWSER_SCROLLBAR_WIDTH = getBrowserScrollbarWidth());
+ this.$el = $(this.el);
+ this.doc = $(this.options.documentContext || document);
+ this.win = $(this.options.windowContext || window);
+ this.$content = this.$el.children("." + options.contentClass);
+ this.$content.attr('tabindex', this.options.tabIndex || 0);
+ this.content = this.$content[0];
+ this.previousPosition = 0;
+ if (this.options.iOSNativeScrolling && (this.el.style.WebkitOverflowScrolling != null)) {
+ this.nativeScrolling();
+ } else {
+ this.generate();
+ }
+ this.createEvents();
+ this.addEvents();
+ this.reset();
+ }
+
+
+ /**
+ Prevents the rest of the page being scrolled
+ when user scrolls the `.nano-content` element.
+ @method preventScrolling
+ @param event {Event}
+ @param direction {String} Scroll direction (up or down)
+ @private
+ */
+
+ NanoScroll.prototype.preventScrolling = function(e, direction) {
+ if (!this.isActive) {
+ return;
+ }
+ if (e.type === DOMSCROLL) {
+ if (direction === DOWN && e.originalEvent.detail > 0 || direction === UP && e.originalEvent.detail < 0) {
+ e.preventDefault();
+ }
+ } else if (e.type === MOUSEWHEEL) {
+ if (!e.originalEvent || !e.originalEvent.wheelDelta) {
+ return;
+ }
+ if (direction === DOWN && e.originalEvent.wheelDelta < 0 || direction === UP && e.originalEvent.wheelDelta > 0) {
+ e.preventDefault();
+ }
+ }
+ };
+
+
+ /**
+ Enable iOS native scrolling
+ @method nativeScrolling
+ @private
+ */
+
+ NanoScroll.prototype.nativeScrolling = function() {
+ this.$content.css({
+ WebkitOverflowScrolling: 'touch'
+ });
+ this.iOSNativeScrolling = true;
+ this.isActive = true;
+ };
+
+
+ /**
+ Updates those nanoScroller properties that
+ are related to current scrollbar position.
+ @method updateScrollValues
+ @private
+ */
+
+ NanoScroll.prototype.updateScrollValues = function() {
+ var content, direction;
+ content = this.content;
+ this.maxScrollTop = content.scrollHeight - content.clientHeight;
+ this.prevScrollTop = this.contentScrollTop || 0;
+ this.contentScrollTop = content.scrollTop;
+ direction = this.contentScrollTop > this.previousPosition ? "down" : this.contentScrollTop < this.previousPosition ? "up" : "same";
+ this.previousPosition = this.contentScrollTop;
+ if (direction !== "same") {
+ this.$el.trigger('update', {
+ position: this.contentScrollTop,
+ maximum: this.maxScrollTop,
+ direction: direction
+ });
+ }
+ if (!this.iOSNativeScrolling) {
+ this.maxSliderTop = this.paneHeight - this.sliderHeight;
+ this.sliderTop = this.maxScrollTop === 0 ? 0 : this.contentScrollTop * this.maxSliderTop / this.maxScrollTop;
+ }
+ };
+
+
+ /**
+ Updates CSS styles for current scroll position.
+ Uses CSS 2d transfroms and `window.requestAnimationFrame` if available.
+ @method setOnScrollStyles
+ @private
+ */
+
+ NanoScroll.prototype.setOnScrollStyles = function() {
+ var cssValue;
+ if (hasTransform) {
+ cssValue = {};
+ cssValue[transform] = "translate(0, " + this.sliderTop + "px)";
+ } else {
+ cssValue = {
+ top: this.sliderTop
+ };
+ }
+ if (rAF) {
+ if (!this.scrollRAF) {
+ this.scrollRAF = rAF((function(_this) {
+ return function() {
+ _this.scrollRAF = null;
+ _this.slider.css(cssValue);
+ };
+ })(this));
+ }
+ } else {
+ this.slider.css(cssValue);
+ }
+ };
+
+
+ /**
+ Creates event related methods
+ @method createEvents
+ @private
+ */
+
+ NanoScroll.prototype.createEvents = function() {
+ this.events = {
+ down: (function(_this) {
+ return function(e) {
+ _this.isBeingDragged = true;
+ _this.offsetY = e.pageY - _this.slider.offset().top;
+ _this.pane.addClass('active');
+ _this.doc.bind(MOUSEMOVE, _this.events[DRAG]).bind(MOUSEUP, _this.events[UP]);
+ return false;
+ };
+ })(this),
+ drag: (function(_this) {
+ return function(e) {
+ _this.sliderY = e.pageY - _this.$el.offset().top - _this.offsetY;
+ _this.scroll();
+ if (_this.contentScrollTop >= _this.maxScrollTop && _this.prevScrollTop !== _this.maxScrollTop) {
+ _this.$el.trigger('scrollend');
+ } else if (_this.contentScrollTop === 0 && _this.prevScrollTop !== 0) {
+ _this.$el.trigger('scrolltop');
+ }
+ return false;
+ };
+ })(this),
+ up: (function(_this) {
+ return function(e) {
+ _this.isBeingDragged = false;
+ _this.pane.removeClass('active');
+ _this.doc.unbind(MOUSEMOVE, _this.events[DRAG]).unbind(MOUSEUP, _this.events[UP]);
+ return false;
+ };
+ })(this),
+ resize: (function(_this) {
+ return function(e) {
+ _this.reset();
+ };
+ })(this),
+ panedown: (function(_this) {
+ return function(e) {
+ _this.sliderY = (e.offsetY || e.originalEvent.layerY) - (_this.sliderHeight * 0.5);
+ _this.scroll();
+ _this.events.down(e);
+ return false;
+ };
+ })(this),
+ scroll: (function(_this) {
+ return function(e) {
+ _this.updateScrollValues();
+ if (_this.isBeingDragged) {
+ return;
+ }
+ if (!_this.iOSNativeScrolling) {
+ _this.sliderY = _this.sliderTop;
+ _this.setOnScrollStyles();
+ }
+ if (e == null) {
+ return;
+ }
+ if (_this.contentScrollTop >= _this.maxScrollTop) {
+ if (_this.options.preventPageScrolling) {
+ _this.preventScrolling(e, DOWN);
+ }
+ if (_this.prevScrollTop !== _this.maxScrollTop) {
+ _this.$el.trigger('scrollend');
+ }
+ } else if (_this.contentScrollTop === 0) {
+ if (_this.options.preventPageScrolling) {
+ _this.preventScrolling(e, UP);
+ }
+ if (_this.prevScrollTop !== 0) {
+ _this.$el.trigger('scrolltop');
+ }
+ }
+ };
+ })(this),
+ wheel: (function(_this) {
+ return function(e) {
+ var delta;
+ if (e == null) {
+ return;
+ }
+ delta = e.delta || e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail || (e.originalEvent && -e.originalEvent.detail);
+ if (delta) {
+ _this.sliderY += -delta / 3;
+ }
+ _this.scroll();
+ return false;
+ };
+ })(this)
+ };
+ };
+
+
+ /**
+ Adds event listeners with jQuery.
+ @method addEvents
+ @private
+ */
+
+ NanoScroll.prototype.addEvents = function() {
+ var events;
+ this.removeEvents();
+ events = this.events;
+ if (!this.options.disableResize) {
+ this.win.bind(RESIZE, events[RESIZE]);
+ }
+ if (!this.iOSNativeScrolling) {
+ this.slider.bind(MOUSEDOWN, events[DOWN]);
+ this.pane.bind(MOUSEDOWN, events[PANEDOWN]).bind("" + MOUSEWHEEL + " " + DOMSCROLL, events[WHEEL]);
+ }
+ this.$content.bind("" + SCROLL + " " + MOUSEWHEEL + " " + DOMSCROLL + " " + TOUCHMOVE, events[SCROLL]);
+ };
+
+
+ /**
+ Removes event listeners with jQuery.
+ @method removeEvents
+ @private
+ */
+
+ NanoScroll.prototype.removeEvents = function() {
+ var events;
+ events = this.events;
+ this.win.unbind(RESIZE, events[RESIZE]);
+ if (!this.iOSNativeScrolling) {
+ this.slider.unbind();
+ this.pane.unbind();
+ }
+ this.$content.unbind("" + SCROLL + " " + MOUSEWHEEL + " " + DOMSCROLL + " " + TOUCHMOVE, events[SCROLL]);
+ };
+
+
+ /**
+ Generates nanoScroller's scrollbar and elements for it.
+ @method generate
+ @chainable
+ @private
+ */
+
+ NanoScroll.prototype.generate = function() {
+ var contentClass, cssRule, currentPadding, options, pane, paneClass, sliderClass;
+ options = this.options;
+ paneClass = options.paneClass, sliderClass = options.sliderClass, contentClass = options.contentClass;
+ if (!(pane = this.$el.children("." + paneClass)).length && !pane.children("." + sliderClass).length) {
+ this.$el.append("");
+ }
+ this.pane = this.$el.children("." + paneClass);
+ this.slider = this.pane.find("." + sliderClass);
+ if (BROWSER_SCROLLBAR_WIDTH === 0 && isFFWithBuggyScrollbar()) {
+ currentPadding = window.getComputedStyle(this.content, null).getPropertyValue('padding-right').replace(/\D+/g, '');
+ cssRule = {
+ right: -14,
+ paddingRight: +currentPadding + 14
+ };
+ } else if (BROWSER_SCROLLBAR_WIDTH) {
+ cssRule = {
+ right: -BROWSER_SCROLLBAR_WIDTH
+ };
+ this.$el.addClass('has-scrollbar');
+ }
+ if (cssRule != null) {
+ this.$content.css(cssRule);
+ }
+ return this;
+ };
+
+
+ /**
+ @method restore
+ @private
+ */
+
+ NanoScroll.prototype.restore = function() {
+ this.stopped = false;
+ if (!this.iOSNativeScrolling) {
+ this.pane.show();
+ }
+ this.addEvents();
+ };
+
+
+ /**
+ Resets nanoScroller's scrollbar.
+ @method reset
+ @chainable
+ @example
+ $(".nano").nanoScroller();
+ */
+
+ NanoScroll.prototype.reset = function() {
+ var content, contentHeight, contentPosition, contentStyle, contentStyleOverflowY, paneBottom, paneHeight, paneOuterHeight, paneTop, parentMaxHeight, right, sliderHeight;
+ if (this.iOSNativeScrolling) {
+ this.contentHeight = this.content.scrollHeight;
+ return;
+ }
+ if (!this.$el.find("." + this.options.paneClass).length) {
+ this.generate().stop();
+ }
+ if (this.stopped) {
+ this.restore();
+ }
+ content = this.content;
+ contentStyle = content.style;
+ contentStyleOverflowY = contentStyle.overflowY;
+ if (BROWSER_IS_IE7) {
+ this.$content.css({
+ height: this.$content.height()
+ });
+ }
+ contentHeight = content.scrollHeight + BROWSER_SCROLLBAR_WIDTH;
+ parentMaxHeight = parseInt(this.$el.css("max-height"), 10);
+ if (parentMaxHeight > 0) {
+ this.$el.height("");
+ this.$el.height(content.scrollHeight > parentMaxHeight ? parentMaxHeight : content.scrollHeight);
+ }
+ paneHeight = this.pane.outerHeight(false);
+ paneTop = parseInt(this.pane.css('top'), 10);
+ paneBottom = parseInt(this.pane.css('bottom'), 10);
+ paneOuterHeight = paneHeight + paneTop + paneBottom;
+ sliderHeight = Math.round(paneOuterHeight / contentHeight * paneOuterHeight);
+ if (sliderHeight < this.options.sliderMinHeight) {
+ sliderHeight = this.options.sliderMinHeight;
+ } else if ((this.options.sliderMaxHeight != null) && sliderHeight > this.options.sliderMaxHeight) {
+ sliderHeight = this.options.sliderMaxHeight;
+ }
+ if (contentStyleOverflowY === SCROLL && contentStyle.overflowX !== SCROLL) {
+ sliderHeight += BROWSER_SCROLLBAR_WIDTH;
+ }
+ this.maxSliderTop = paneOuterHeight - sliderHeight;
+ this.contentHeight = contentHeight;
+ this.paneHeight = paneHeight;
+ this.paneOuterHeight = paneOuterHeight;
+ this.sliderHeight = sliderHeight;
+ this.slider.height(sliderHeight);
+ this.events.scroll();
+ this.pane.show();
+ this.isActive = true;
+ if ((content.scrollHeight === content.clientHeight) || (this.pane.outerHeight(true) >= content.scrollHeight && contentStyleOverflowY !== SCROLL)) {
+ this.pane.hide();
+ this.isActive = false;
+ } else if (this.el.clientHeight === content.scrollHeight && contentStyleOverflowY === SCROLL) {
+ this.slider.hide();
+ } else {
+ this.slider.show();
+ }
+ this.pane.css({
+ opacity: (this.options.alwaysVisible ? 1 : ''),
+ visibility: (this.options.alwaysVisible ? 'visible' : '')
+ });
+ contentPosition = this.$content.css('position');
+ if (contentPosition === 'static' || contentPosition === 'relative') {
+ right = parseInt(this.$content.css('right'), 10);
+ if (right) {
+ this.$content.css({
+ right: '',
+ marginRight: right
+ });
+ }
+ }
+ return this;
+ };
+
+
+ /**
+ @method scroll
+ @private
+ @example
+ $(".nano").nanoScroller({ scroll: 'top' });
+ */
+
+ NanoScroll.prototype.scroll = function() {
+ if (!this.isActive) {
+ return;
+ }
+ this.sliderY = Math.max(0, this.sliderY);
+ this.sliderY = Math.min(this.maxSliderTop, this.sliderY);
+ this.$content.scrollTop((this.paneHeight - this.contentHeight + BROWSER_SCROLLBAR_WIDTH) * this.sliderY / this.maxSliderTop * -1);
+ if (!this.iOSNativeScrolling) {
+ this.updateScrollValues();
+ this.setOnScrollStyles();
+ }
+ return this;
+ };
+
+
+ /**
+ Scroll at the bottom with an offset value
+ @method scrollBottom
+ @param offsetY {Number}
+ @chainable
+ @example
+ $(".nano").nanoScroller({ scrollBottom: value });
+ */
+
+ NanoScroll.prototype.scrollBottom = function(offsetY) {
+ if (!this.isActive) {
+ return;
+ }
+ this.$content.scrollTop(this.contentHeight - this.$content.height() - offsetY).trigger(MOUSEWHEEL);
+ this.stop().restore();
+ return this;
+ };
+
+
+ /**
+ Scroll at the top with an offset value
+ @method scrollTop
+ @param offsetY {Number}
+ @chainable
+ @example
+ $(".nano").nanoScroller({ scrollTop: value });
+ */
+
+ NanoScroll.prototype.scrollTop = function(offsetY) {
+ if (!this.isActive) {
+ return;
+ }
+ this.$content.scrollTop(+offsetY).trigger(MOUSEWHEEL);
+ this.stop().restore();
+ return this;
+ };
+
+
+ /**
+ Scroll to an element
+ @method scrollTo
+ @param node {Node} A node to scroll to.
+ @chainable
+ @example
+ $(".nano").nanoScroller({ scrollTo: $('#a_node') });
+ */
+
+ NanoScroll.prototype.scrollTo = function(node) {
+ if (!this.isActive) {
+ return;
+ }
+ this.scrollTop(this.$el.find(node).get(0).offsetTop);
+ return this;
+ };
+
+
+ /**
+ To stop the operation.
+ This option will tell the plugin to disable all event bindings and hide the gadget scrollbar from the UI.
+ @method stop
+ @chainable
+ @example
+ $(".nano").nanoScroller({ stop: true });
+ */
+
+ NanoScroll.prototype.stop = function() {
+ if (cAF && this.scrollRAF) {
+ cAF(this.scrollRAF);
+ this.scrollRAF = null;
+ }
+ this.stopped = true;
+ this.removeEvents();
+ if (!this.iOSNativeScrolling) {
+ this.pane.hide();
+ }
+ return this;
+ };
+
+
+ /**
+ Destroys nanoScroller and restores browser's native scrollbar.
+ @method destroy
+ @chainable
+ @example
+ $(".nano").nanoScroller({ destroy: true });
+ */
+
+ NanoScroll.prototype.destroy = function() {
+ if (!this.stopped) {
+ this.stop();
+ }
+ if (!this.iOSNativeScrolling && this.pane.length) {
+ this.pane.remove();
+ }
+ if (BROWSER_IS_IE7) {
+ this.$content.height('');
+ }
+ this.$content.removeAttr('tabindex');
+ if (this.$el.hasClass('has-scrollbar')) {
+ this.$el.removeClass('has-scrollbar');
+ this.$content.css({
+ right: ''
+ });
+ }
+ return this;
+ };
+
+
+ /**
+ To flash the scrollbar gadget for an amount of time defined in plugin settings (defaults to 1,5s).
+ Useful if you want to show the user (e.g. on pageload) that there is more content waiting for him.
+ @method flash
+ @chainable
+ @example
+ $(".nano").nanoScroller({ flash: true });
+ */
+
+ NanoScroll.prototype.flash = function() {
+ if (this.iOSNativeScrolling) {
+ return;
+ }
+ if (!this.isActive) {
+ return;
+ }
+ this.reset();
+ this.pane.addClass('flashed');
+ setTimeout((function(_this) {
+ return function() {
+ _this.pane.removeClass('flashed');
+ };
+ })(this), this.options.flashDelay);
+ return this;
+ };
+
+ return NanoScroll;
+
+ })();
+ $.fn.nanoScroller = function(settings) {
+ return this.each(function() {
+ var options, scrollbar;
+ if (!(scrollbar = this.nanoscroller)) {
+ options = $.extend({}, defaults, settings);
+ this.nanoscroller = scrollbar = new NanoScroll(this, options);
+ }
+ if (settings && typeof settings === "object") {
+ $.extend(scrollbar.options, settings);
+ if (settings.scrollBottom != null) {
+ return scrollbar.scrollBottom(settings.scrollBottom);
+ }
+ if (settings.scrollTop != null) {
+ return scrollbar.scrollTop(settings.scrollTop);
+ }
+ if (settings.scrollTo) {
+ return scrollbar.scrollTo(settings.scrollTo);
+ }
+ if (settings.scroll === 'bottom') {
+ return scrollbar.scrollBottom(0);
+ }
+ if (settings.scroll === 'top') {
+ return scrollbar.scrollTop(0);
+ }
+ if (settings.scroll && settings.scroll instanceof $) {
+ return scrollbar.scrollTo(settings.scroll);
+ }
+ if (settings.stop) {
+ return scrollbar.stop();
+ }
+ if (settings.destroy) {
+ return scrollbar.destroy();
+ }
+ if (settings.flash) {
+ return scrollbar.flash();
+ }
+ }
+ return scrollbar.reset();
+ });
+ };
+ $.fn.nanoScroller.Constructor = NanoScroll;
+})(jQuery, window, document);
+
+//# sourceMappingURL=jquery.nanoscroller.js.map
\ No newline at end of file