mirror of
https://github.com/AdrienHallet/HaitiWater.git
synced 2026-10-26 17:35:18 +00:00
New vendors to handle nav-bar
This commit is contained in:
1 parent
82e4ea2a5b
commit
f00a8d18e1
11 files changed
+9853
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
/* Add here all your JS customizations */
|
||||
@@ -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 ]);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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 = ['­','<style id="s', mod, '">', rule, '</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 = '<xyz></xyz>';
|
||||
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<style>' + cssText + '</style>';
|
||||
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<l;i++){
|
||||
clone.createElement(elems[i]);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
function shivMethods(ownerDocument, data) {
|
||||
if (!data.cache) {
|
||||
data.cache = {};
|
||||
data.createElem = ownerDocument.createElement;
|
||||
data.createFrag = ownerDocument.createDocumentFragment;
|
||||
data.frag = data.createFrag();
|
||||
}
|
||||
|
||||
|
||||
ownerDocument.createElement = function(nodeName) {
|
||||
if (!html5.shivMethods) {
|
||||
return data.createElem(nodeName);
|
||||
}
|
||||
return createElement(nodeName, ownerDocument, data);
|
||||
};
|
||||
|
||||
ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
|
||||
'var n=f.cloneNode(),c=n.createElement;' +
|
||||
'h.shivMethods&&(' +
|
||||
getElements().join().replace(/[\w\-]+/g, function(nodeName) {
|
||||
data.createElem(nodeName);
|
||||
data.frag.createElement(nodeName);
|
||||
return 'c("' + nodeName + '")';
|
||||
}) +
|
||||
');return n}'
|
||||
)(html5, data.frag);
|
||||
}
|
||||
|
||||
function shivDocument(ownerDocument) {
|
||||
if (!ownerDocument) {
|
||||
ownerDocument = document;
|
||||
}
|
||||
var data = getExpandoData(ownerDocument);
|
||||
|
||||
if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
|
||||
data.hasCSS = !!addStyleSheet(ownerDocument,
|
||||
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
|
||||
'mark{background:#FF0;color:#000}' +
|
||||
'template{display:none}'
|
||||
);
|
||||
}
|
||||
if (!supportsUnknownElements) {
|
||||
shivMethods(ownerDocument, data);
|
||||
}
|
||||
return ownerDocument;
|
||||
}
|
||||
|
||||
var html5 = {
|
||||
|
||||
'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video',
|
||||
|
||||
'version': version,
|
||||
|
||||
'shivCSS': (options.shivCSS !== false),
|
||||
|
||||
'supportsUnknownElements': supportsUnknownElements,
|
||||
|
||||
'shivMethods': (options.shivMethods !== false),
|
||||
|
||||
'type': 'default',
|
||||
|
||||
'shivDocument': shivDocument,
|
||||
|
||||
createElement: createElement,
|
||||
|
||||
createDocumentFragment: createDocumentFragment
|
||||
};
|
||||
|
||||
window.html5 = html5;
|
||||
|
||||
shivDocument(document);
|
||||
|
||||
}(this, document));
|
||||
|
||||
Modernizr._version = version;
|
||||
|
||||
Modernizr._prefixes = prefixes;
|
||||
Modernizr._domPrefixes = domPrefixes;
|
||||
Modernizr._cssomPrefixes = cssomPrefixes;
|
||||
|
||||
|
||||
|
||||
Modernizr.testProp = function(prop){
|
||||
return testProps([prop]);
|
||||
};
|
||||
|
||||
Modernizr.testAllProps = testPropsAll;
|
||||
|
||||
|
||||
Modernizr.testStyles = injectElementWithStyles; docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +
|
||||
|
||||
(enableClasses ? ' js ' + classes.join(' ') : '');
|
||||
|
||||
return Modernizr;
|
||||
|
||||
})(this, this.document);
|
||||
/*yepnope1.5.4|WTFPL*/
|
||||
(function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}})(this,document);
|
||||
Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0));};
|
||||
|
||||
// johanbrook.com/browsers/native-momentum-scrolling-ios-5/
|
||||
// introduced in iOS5b2. Possible API may change...
|
||||
|
||||
Modernizr.addTest("overflowscrolling",function(){
|
||||
return Modernizr.testAllProps("overflowScrolling");
|
||||
});
|
||||
|
||||
|
||||
;
|
||||
@@ -0,0 +1,234 @@
|
||||
# Morris.js - pretty time-series line graphs
|
||||
|
||||
[](http://travis-ci.org/morrisjs/morris.js)
|
||||
|
||||
Morris.js is the library that powers the graphs on http://howmanyleft.co.uk/.
|
||||
It's a very simple API for drawing line, bar, area and donut charts.
|
||||
|
||||
Cheers!
|
||||
|
||||
\- Olly (olly@oesmith.co.uk)
|
||||
|
||||
## Contributors wanted
|
||||
|
||||
I'm unfortunately not able to actively support Morris.js any more. I keep an eye
|
||||
on the issues, but I rarely have the time to fix bugs or review pull requests.
|
||||
|
||||
If you're interested in actively contributing to Morris.js, please contact me on
|
||||
the email address above.
|
||||
|
||||
## Requirements
|
||||
|
||||
- [jQuery](http://jquery.com/) (>= 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.
|
||||
@@ -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}
|
||||
+1892
File diff suppressed because it is too large.
Load diff
@@ -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.xLine truncated
|
||||
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);
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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("<div class=\"" + paneClass + "\"><div class=\"" + sliderClass + "\" /></div>");
|
||||
}
|
||||
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
|
||||
Reference in new issue
Block a user