|
1 | 1 | # MetaLamp four task |
2 | 2 | fourth test task from MetaLamp. |
| 3 | + |
| 4 | +Range Slider Fox is an easy and simple range slider written in TypeScript as JQUERY plugin |
| 5 | + |
| 6 | +*** |
| 7 | + |
| 8 | +* Version: 1.0 |
| 9 | +* <a href="https://plugins.su/">Demo page</a> |
| 10 | +* <a href="https://plugins.su/RangeSliderFox.zip">Download ZIP</a> |
| 11 | + |
| 12 | +You can configure range slider as you need in the demonstration Panel and copy the configuration code from the column "Config code" by clicking "Copy code" button. |
| 13 | +Just don't forget to change the value inside еру parenthesis $(...). |
| 14 | + |
| 15 | + |
| 16 | +## Description: |
| 17 | + |
| 18 | +* Adaptive and accessible design. |
| 19 | +* Possibility of keyboard and touch control. |
| 20 | +* Skin support (you can fully change appearance of the slider using css). |
| 21 | +* Has 4 built-in themes. |
| 22 | +* High performance because of thoughtful architecture. |
| 23 | +* Cross-browser. |
| 24 | +* Vertical view is supported. |
| 25 | + |
| 26 | +## Key features: |
| 27 | + |
| 28 | +* Any amount of the sliders in the same page without conflicts and significant performance issues. |
| 29 | +* Negative and fractional values are supported. |
| 30 | +* Possibility to set custom step or jump from value to value of the grid. |
| 31 | +* Possibility to switch off the elements of user interface. |
| 32 | +* Postfixes and prefixes for you values. |
| 33 | +* Dot sets its value in the value property if the slider is initialized on an input element. |
| 34 | +* Configuration and manipulation via data-attributes is supported. |
| 35 | +* You can block work of the slider. |
| 36 | +* You can subscribe and unsubscribe events of the slider using its API (onStart, onChange, onReset, onUpdate). |
| 37 | +* The slider supports external methods (renew, reset, destroy). |
| 38 | +* The grid view is adapted on change of the slider width, which makes it fully adaptive. |
| 39 | +* You can change the view of the slider any time: vertical or horizontal. |
| 40 | +* Code of the plugin is compatible with ES5. |
| 41 | + |
| 42 | +## Dependencies: |
| 43 | +* <a href="http://jquery.com/" target="_blank">jQuery 1.2.x+</a> |
| 44 | + |
| 45 | + |
| 46 | +## Usage: |
| 47 | + |
| 48 | +Add the following libraries to the page: |
| 49 | +* jQuery |
| 50 | +* rangeSliderFox.js |
| 51 | + |
| 52 | +Add the following stylesheets to the page: |
| 53 | +* rangeSliderFox.css |
| 54 | + |
| 55 | + |
| 56 | +## Initialisation: |
| 57 | + |
| 58 | +```html |
| 59 | +<input class="rslider__fox" value=""> |
| 60 | +``` |
| 61 | + |
| 62 | +```javascript |
| 63 | +$('.rslider__fox').RangeSliderFox({ |
| 64 | + type: 'double', |
| 65 | + theme: 'fox', |
| 66 | + min: -120, |
| 67 | + max: 800, |
| 68 | + to: 500, |
| 69 | + from: 200, |
| 70 | + bar: true, |
| 71 | + tipMinMax: true, |
| 72 | + tipFromTo: true, |
| 73 | + grid: true, |
| 74 | + gridSnap: false, |
| 75 | + gridNum: 40, |
| 76 | +}) |
| 77 | +``` |
| 78 | + |
| 79 | +## Usage API: |
| 80 | + |
| 81 | +```javascript |
| 82 | +const obj = $(dom).RangeSliderFox({}).data('RangeSliderFox'); |
| 83 | + |
| 84 | +obj.update({ |
| 85 | +min:0, |
| 86 | +max:600, |
| 87 | +from:350 |
| 88 | +}) |
| 89 | + |
| 90 | +// This piece of code will change range values and set the dot on position 350. |
| 91 | + |
| 92 | +obj.reset() |
| 93 | + |
| 94 | +// reset - will reset all the setup to the values which were |
| 95 | +// passed on initialization or will take default values |
| 96 | + |
| 97 | +obj.destroy() |
| 98 | + |
| 99 | +// destroy - will destroy slider instance, DOM-elements and all related events. |
| 100 | + |
| 101 | +``` |
| 102 | + |
| 103 | +## Settings: |
| 104 | + |
| 105 | +| Option | Data-Attr | Default value (possible values) | Type | Description | |
| 106 | +| --- | --- | --- | --- | --- | |
| 107 | +| type | data-type | 'single' ('double') | string | Dot type (single or double) | |
| 108 | +| orientation | data-orientation | 'horizontal' ('vertical') | string | slider orientation (vertical or horizontal) | |
| 109 | +| theme | data-theme | 'base' ('fox' , 'dark', 'classic') | string | Pass the name of the theme. CSS-selector should have name like .rs-[name] (e.g. .rs-base) | |
| 110 | +| min | data-min | 0 (-n, n.n..) | number | Minimal value of the range | |
| 111 | +| max | data-max | 10 (-n, n.n..) | number | Maximal value of the range | |
| 112 | +| to | data-to | 2 (-n, n.n..) | number | Second dot position | |
| 113 | +| from | data-from | 1 (-n, n.n..) | number | First dot position | |
| 114 | +| step | data-step | 0 (0-max) | number | Step of the dot mooving | |
| 115 | +| keyStepOne | data-key-step-one | 0(0-max) | number | Step of the dot mooving on keyboard key single pressing | |
| 116 | +| keyStepHold | data-key-step-hold | 0(0-max) | number | Step of the dot mooving on keyboard key holding | |
| 117 | +| bar | data-bar | false | boolean | Progrees-bar view (shown or hidden) | |
| 118 | +| tipPrefix | data-tip-prefix | '' (char…) | string | Prefix for hints (15 characters maximum) | |
| 119 | +| tipPostfix | data-tip-postfix | '' (char…) | string | Postfix for hints (15 characters maximum) | |
| 120 | +| tipMinMax | data-tip-min-max | true | boolean | MinMax hints view (on or off) | |
| 121 | +| tipFromTo | data-tip-from-to | true | boolean | FromTo hints view (on or off) | |
| 122 | +| grid | data-grid | false | boolean | Scale view (on or off) | |
| 123 | +| gridSnap | data-grid-snap | false | boolean | Dot can stop between scale marks (yes or no) | |
| 124 | +| gridNum | data-grid-num | 0 (n, n.n..) | number | Amount of intervals the scale is split into | |
| 125 | +| gridStep | data-grid-step | 0 (n, n.n..) | number | Amount of steps in the interval | |
| 126 | +| gridRound | data-grid-round | 0 (n) | number | Fractional rounding | |
| 127 | +| disabled | data-disabled | false | boolean | Slider enabled or disabled | |
| 128 | +| onStart | - | (data) => data | Function | Call a callback function after the first start of the plugin and pass an object of current configuration data as an argument | |
| 129 | +| onChange | - | (data) => data | Function | Call a callback function after each user’s interaction with the slider and pass an object of current configuration data as an argument | |
| 130 | +| onUpdate | - | (data) => data | Function | Call a callback function after “update” method calling and pass an object of current configuration data as an argument | |
| 131 | +| onReset | - | (data) => data | Function | Call a callback function after “reset” method calling and pass an object of current configuration data as an argument | |
| 132 | + |
| 133 | + |
| 134 | +## Setup and Scripts ( build the project, start, testing, production) |
| 135 | + |
| 136 | +* Install dependencies: |
| 137 | + ``` |
| 138 | + npm i |
| 139 | + ``` |
| 140 | +* Start dev server: |
| 141 | + ``` |
| 142 | + npm start |
| 143 | + go to http://localhost:8080/ |
| 144 | + ``` |
| 145 | + |
| 146 | +* On the production server create the bundle files |
| 147 | + ``` |
| 148 | + npm run build |
| 149 | + ``` |
| 150 | + |
| 151 | +* Building only the plugin |
| 152 | + ``` |
| 153 | + npm run plugin |
| 154 | + ``` |
| 155 | + |
| 156 | +* Plugin testing: |
| 157 | + ``` |
| 158 | + npm run test |
| 159 | + ``` |
| 160 | + |
| 161 | + |
| 162 | +## Plugin Architecture: |
| 163 | + |
| 164 | +* Architecture is based on MVC using Observer pattern. |
| 165 | + |
| 166 | +* UML class diagram: |
| 167 | + |
| 168 | +* <a href="https://plugins.su/UML.png">UML full-size image view </a> |
| 169 | +* <a href="https://github.com/coder1x/readme/blob/master/_tmp/UML.drawio">UML class diagram (drawio)</a> |
0 commit comments