flagstrap 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5471201f39e30efa466c6022f5e8ba7386fe85bc
4
+ data.tar.gz: 280b5dcd5e60cc50a19938c32665441d201cf9f2
5
+ SHA512:
6
+ metadata.gz: 0b43cd8a028431b7a771bee0800aa48ec65b06878757d35a4db4e1b44123856fc83854eff25558c632457c85bbe82fc20c445ea345c25f65b067217a680663a0
7
+ data.tar.gz: fd17173e8ebc9a067ad810b5ece86f7c7077baf4858fa8075336e950741f551f8adc7bb8a3dc4ee83032392ba8db6b8c3e4852c2bbf1310a836b3b647942ff27
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .idea
2
+ .DS_Store
3
+ node_modules
4
+ pkg
data/.jshintrc ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "boss": true,
3
+ "curly": true,
4
+ "eqeqeq": true,
5
+ "eqnull": true,
6
+ "expr": true,
7
+ "immed": true,
8
+ "noarg": true,
9
+ "onevar": true,
10
+ "quotmark": "double",
11
+ "unused": true,
12
+ "node": true
13
+ }
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flagstrap.gemspec
4
+ gemspec
data/Gruntfile.js ADDED
@@ -0,0 +1,67 @@
1
+ module.exports = function(grunt) {
2
+
3
+ grunt.initConfig({
4
+
5
+ // Import package manifest
6
+ pkg: grunt.file.readJSON("flagstrap.jquery.json"),
7
+
8
+ // Banner definitions
9
+ meta: {
10
+ banner: "/*\n" +
11
+ " * <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n" +
12
+ " * <%= pkg.description %>\n" +
13
+ " * <%= pkg.homepage %>\n" +
14
+ " *\n" +
15
+ " * Made by <%= pkg.author.name %>\n" +
16
+ " * Under <%= pkg.licenses[0].type %> License\n" +
17
+ " */\n"
18
+ },
19
+
20
+ // Concat definitions
21
+ concat: {
22
+ dist: {
23
+ src: ["src/jquery.flagstrap.js"],
24
+ dest: "dist/js/jquery.flagstrap.js"
25
+ },
26
+ options: {
27
+ banner: "<%= meta.banner %>"
28
+ }
29
+ },
30
+
31
+ // Lint definitions
32
+ jshint: {
33
+ files: ["src/jquery.boilerplate.js"],
34
+ options: {
35
+ jshintrc: ".jshintrc"
36
+ }
37
+ },
38
+
39
+ // Minify definitions
40
+ uglify: {
41
+ my_target: {
42
+ src: ["dist/js/jquery.flagstrap.js"],
43
+ dest: "dist/js/jquery.flagstrap.min.js"
44
+ },
45
+ options: {
46
+ banner: "<%= meta.banner %>"
47
+ }
48
+ },
49
+
50
+ // watch for changes to source
51
+ // Better than calling grunt a million times
52
+ // (call 'grunt watch')
53
+ watch: {
54
+ files: ['src/*'],
55
+ tasks: ['default']
56
+ }
57
+
58
+ });
59
+
60
+ grunt.loadNpmTasks("grunt-contrib-concat");
61
+ grunt.loadNpmTasks("grunt-contrib-jshint");
62
+ grunt.loadNpmTasks("grunt-contrib-uglify");
63
+ grunt.loadNpmTasks("grunt-contrib-watch");
64
+
65
+ grunt.registerTask("default", ["jshint", "concat", "uglify"]);
66
+
67
+ };
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ ##The MIT License (MIT)
2
+ ####Copyright © 2015 Alex Carter <alex@blazeworx.com>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the “Software”), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ **THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.**
data/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # Flagstrap
2
+
3
+ A lightwieght jQuery plugin for creating Bootstrap 3 compatible country select boxes with flags.
4
+
5
+ ![Flagstrap Demo](http://blazeworx.com/flagstrap.gif)
6
+
7
+ ###Demo
8
+ http://blazeworx.github.io/flagstrap
9
+
10
+ ###Usage
11
+
12
+ ####Basic
13
+
14
+ ```html
15
+ <form class="form-horizontal">
16
+ <div class="form-group">
17
+ <label>Select Country</label><br>
18
+ <div class="flagstrap" data-input-name="country"></div>
19
+ </div>
20
+ </form>
21
+ ```
22
+
23
+ ```html
24
+ <script>
25
+ $('.flagstrap').flagStrap();
26
+ </script>
27
+ ```
28
+
29
+ ####Options
30
+
31
+ #####Using Data Attributes
32
+ This example will create a Flagstrap Dropdown giving the input field the name of `country` with all countries available and `Germany` pre selected and in a `scrollable` dropdown with `max-height` of `250px`.
33
+
34
+ ```html
35
+ <form>
36
+ <div class="form-group">
37
+ <label>Select Country</label><br>
38
+ <div id="flagstrap2"
39
+ data-input-name="country2"
40
+ data-selected-country="DE"
41
+ data-button-size="btn-md"
42
+ data-button-type="btn-default"
43
+ data-scrollable-height="250px"
44
+ data-scrollable="true">
45
+ </div>
46
+ </div>
47
+ </form>
48
+ ```
49
+
50
+ ```html
51
+ <script>
52
+ $('#flagstrap2').flagStrap();
53
+ </script>
54
+ ```
55
+
56
+ #####Using Instance Options
57
+ This example will create a Flagstrap Dropdown giving the input field the name of `country` with only `Australia`, `USA` and `Canada` as available options and no pre selection.
58
+
59
+ ```html
60
+ <form class="form-horizontal">
61
+ <div class="form-group">
62
+ <label>Select Country</label><br>
63
+ <div id="flagstrap3"></div>
64
+ </div>
65
+ </form>
66
+ ```
67
+
68
+ ```html
69
+ <script>
70
+ $('#flagstrap3').flagStrap({
71
+ countries: {
72
+ "AU": "Australia",
73
+ "GB": "United Kingdom",
74
+ "US": "United States"
75
+ },
76
+ inputName: 'country',
77
+ buttonSize: "btn-lg",
78
+ buttonType: "btn-primary",
79
+ labelMargin: "20px",
80
+ scrollable: false,
81
+ scrollableHeight: "350px",
82
+ onSelect: function(value, element) {
83
+ //
84
+ },
85
+ placeholder: {
86
+ value: "",
87
+ text: "Please select a country"
88
+ }
89
+ });
90
+ </script>
91
+ ```
92
+
93
+ ### Options
94
+ <table class="table table-bordered table-striped">
95
+ <thead>
96
+ <tr>
97
+ <th style="width: 100px;">Name</th>
98
+ <th style="width: 100px;">Type</th>
99
+ <th style="width: 100px;">Default</th>
100
+ <th>Description</th>
101
+ </tr>
102
+ </thead>
103
+ <tbody>
104
+ <tr>
105
+ <td>inputName</td>
106
+ <td>string</td>
107
+ <td>uniquely generated</td>
108
+ <td>the `name` attribute for the actual `select` input</td>
109
+ </tr>
110
+ <tr>
111
+ <td>inputId</td>
112
+ <td>string</td>
113
+ <td>uniquely generated</td>
114
+ <td>the `id` attribute for the actual `select` input</td>
115
+ </tr>
116
+ <tr>
117
+ <td>buttonSize</td>
118
+ <td>string</td>
119
+ <td>"btn-md"</td>
120
+ <td>The bootstrap button size `class` for this drop down</td>
121
+ </tr>
122
+ <tr>
123
+ <td>buttonType</td>
124
+ <td>string</td>
125
+ <td>"btn-default"</td>
126
+ <td>The bootstrap button type `class` for this drop down</td>
127
+ </tr>
128
+ <tr>
129
+ <td>labelMargin</td>
130
+ <td>string</td>
131
+ <td>"20px"</td>
132
+ <td>The `margin` between `flag` and `text label`</td>
133
+ </tr>
134
+ <tr>
135
+ <td>scrollable</td>
136
+ <td>boolean</td>
137
+ <td>false</td>
138
+ <td>Scrollable or full height drop down</td>
139
+ </tr>
140
+ <tr>
141
+ <td>scrollableHeight</td>
142
+ <td>string</td>
143
+ <td>"250px"</td>
144
+ <td>`max-height` for the scrollable drop down</td>
145
+ </tr>
146
+ <tr>
147
+ <td>countries (optional)</td>
148
+ <td>object</td>
149
+ <td>(all)</td>
150
+ <td>Only show specific countries<br>Example:<br><br>{"GB": "United Kingdom", "US": "United States"}<br><br>will only show the USA and UK.</td>
151
+ </tr>
152
+ <tr>
153
+ <td>onSelect (optional)</td>
154
+ <td>function</td>
155
+ <td>null</td>
156
+ <td>This callback gets called each time the select is changed. It receives two parameters, the new value, and the select element.</td>
157
+ </tr>
158
+ <tr>
159
+ <td>placeholder</td>
160
+ <td>bool|object</td>
161
+ <td>{value: "", text: "Please select a country"}</td>
162
+ <td>Set the placeholder value and text. To disable the placeholder define as (boolean) false.</td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+
167
+ ### Contributors
168
+
169
+ This project was created by Alex Carter. I owe many thanks to the following people who have helped make flagstrap even better.
170
+
171
+ * [Matthew Machuga](https://github.com/machuga)
172
+ * [TJ Miller](https://github.com/sixlive)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "flagstrap"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bower.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "flagstrap",
3
+ "version": "0.3",
4
+ "homepage": "http://www.blazeworx.com/flagstrap",
5
+ "authors": [
6
+ "Alex Carter <alex@blazeworx.com>"
7
+ ],
8
+ "description": "A lightwieght jQuery plugin for creating Bootstrap 3 compatible country select boxes with flags.",
9
+ "main": "src/jquery.flagstrap.js",
10
+ "keywords": [
11
+ "jquery",
12
+ "bootstrap",
13
+ "country",
14
+ "flag",
15
+ "flagstrap",
16
+ "jquery-flagstrap"
17
+ ],
18
+ "license": "MIT"
19
+ }
data/demo/index.html ADDED
@@ -0,0 +1,340 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
+ <title>Flagstrap Demo</title>
6
+ <meta name="description" content="">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
9
+ <link href="../dist/css/flags.css" rel="stylesheet">
10
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script>
11
+ <style>
12
+ /* Tomorrow Theme */
13
+ /* Original theme - https://github.com/chriskempson/tomorrow-theme */
14
+ .prettyprint {
15
+ background: white;
16
+ font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace;
17
+ font-size: 12px;
18
+ line-height: 1.5;
19
+ border: 1px solid #ccc;
20
+ padding: 10px;
21
+ }
22
+
23
+ .pln {
24
+ color: #4d4d4c;
25
+ }
26
+
27
+ @media screen {
28
+ .str {
29
+ color: #718c00;
30
+ }
31
+
32
+ .kwd {
33
+ color: #8959a8;
34
+ }
35
+
36
+ .com {
37
+ color: #8e908c;
38
+ }
39
+
40
+ .typ {
41
+ color: #4271ae;
42
+ }
43
+
44
+ .lit {
45
+ color: #f5871f;
46
+ }
47
+
48
+ .pun {
49
+ color: #4d4d4c;
50
+ }
51
+
52
+ .opn {
53
+ color: #4d4d4c;
54
+ }
55
+
56
+ .clo {
57
+ color: #4d4d4c;
58
+ }
59
+
60
+ .tag {
61
+ color: #c82829;
62
+ }
63
+
64
+ .atn {
65
+ color: #f5871f;
66
+ }
67
+
68
+ .atv {
69
+ color: #3e999f;
70
+ }
71
+
72
+ .dec {
73
+ color: #f5871f;
74
+ }
75
+
76
+ .var {
77
+ color: #c82829;
78
+ }
79
+
80
+ .fun {
81
+ color: #4271ae;
82
+ }
83
+ }
84
+ @media print, projection {
85
+ .str {
86
+ color: #006600;
87
+ }
88
+
89
+ .kwd {
90
+ color: #006;
91
+ font-weight: bold;
92
+ }
93
+
94
+ .com {
95
+ color: #600;
96
+ font-style: italic;
97
+ }
98
+
99
+ .typ {
100
+ color: #404;
101
+ font-weight: bold;
102
+ }
103
+
104
+ .lit {
105
+ color: #004444;
106
+ }
107
+
108
+ .pun, .opn, .clo {
109
+ color: #444400;
110
+ }
111
+
112
+ .tag {
113
+ color: #006;
114
+ font-weight: bold;
115
+ }
116
+
117
+ .atn {
118
+ color: #440044;
119
+ }
120
+
121
+ .atv {
122
+ color: #006600;
123
+ }
124
+ }
125
+ /* Specify class=linenums on a pre to get line numbering */
126
+ ol.linenums {
127
+ margin-top: 0;
128
+ margin-bottom: 0;
129
+ }
130
+
131
+ /* IE indents via margin-left */
132
+ li.L0,
133
+ li.L1,
134
+ li.L2,
135
+ li.L3,
136
+ li.L4,
137
+ li.L5,
138
+ li.L6,
139
+ li.L7,
140
+ li.L8,
141
+ li.L9 {
142
+ /* */
143
+ }
144
+
145
+ /* Alternate shading for lines */
146
+ li.L1,
147
+ li.L3,
148
+ li.L5,
149
+ li.L7,
150
+ li.L9 {
151
+ /* */
152
+ }
153
+ </style>
154
+ </head>
155
+ <body onload="prettyPrint()">
156
+
157
+ <a href="https://github.com/blazeworx/flagstrap">
158
+ <img style="position: absolute; top: 0; left: 0; border: 0;"
159
+ src="https://camo.githubusercontent.com/567c3a48d796e2fc06ea80409cc9dd82bf714434/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f6461726b626c75655f3132313632312e706e67"
160
+ alt="Fork me on GitHub"
161
+ data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_darkblue_121621.png">
162
+ </a>
163
+
164
+ <div class="container" style="margin-top:50px;">
165
+ <h1>FlagStrap v1.1</h1><a href="https://github.com/blazeworx/flagstrap">View on Github</a>
166
+ <hr>
167
+
168
+ <div class="row">
169
+ <div class="col-xs-12 col-md-6">
170
+ <h3>Default
171
+ <small>No options or data attributes</small>
172
+ </h3>
173
+ <pre class="prettyprint lang-js">
174
+ $('#basic').flagStrap();
175
+ </pre>
176
+ </div>
177
+ <div class="col-xs-12 col-md-6">
178
+ <h3>Result</h3>
179
+
180
+ <form>
181
+ <div class="form-group">
182
+ <label>Select Country</label><br>
183
+
184
+ <div id="basic" data-input-name="country"></div>
185
+ </div>
186
+ </form>
187
+ </div>
188
+ </div>
189
+
190
+ <hr>
191
+
192
+ <div class="row">
193
+ <div class="col-xs-12 col-md-6">
194
+ <h3>Example
195
+ <small>Customer default value</small>
196
+ </h3>
197
+ <pre class="prettyprint lang-js">
198
+ $('#origin').flagStrap({
199
+ placeholder: {
200
+ value: "",
201
+ text: "Country of origin"
202
+ }
203
+ });
204
+ </pre>
205
+ </div>
206
+ <div class="col-xs-12 col-md-6">
207
+ <h3>Result</h3>
208
+
209
+ <form>
210
+ <div class="form-group">
211
+ <label>Where did these items originate from?</label><br>
212
+ <div id="origin" data-input-name="origin"></div>
213
+ </div>
214
+ </form>
215
+ </div>
216
+ </div>
217
+
218
+ <hr>
219
+
220
+ <div class="row">
221
+ <div class="col-xs-12 col-md-6">
222
+ <h3>Example
223
+ <small>Using data attributes to pre-select a country</small>
224
+ </h3>
225
+ <pre class="prettyprint lang-js">
226
+ $('#options').flagStrap({
227
+ countries: {
228
+ "AU": "Australia",
229
+ "GB": "United Kingdom",
230
+ "US": "United States"
231
+ },
232
+ buttonSize: "btn-sm",
233
+ buttonType: "btn-info",
234
+ labelMargin: "10px",
235
+ scrollable: false,
236
+ scrollableHeight: "350px"
237
+ });
238
+ </pre>
239
+ </div>
240
+ <div class="col-xs-12 col-md-6">
241
+ <h3>Result</h3>
242
+
243
+ <form>
244
+ <div class="form-group">
245
+ <label>Select Country</label><br>
246
+
247
+ <div id="options"
248
+ data-input-name="country2"
249
+ data-selected-country="GB">
250
+ </div>
251
+ </div>
252
+ </form>
253
+ </div>
254
+ </div>
255
+
256
+ <hr>
257
+
258
+ <div class="row">
259
+ <div class="col-xs-12 col-md-6">
260
+ <h3>Example
261
+ <small>Custom onChange event</small>
262
+ </h3>
263
+ <pre class="prettyprint lang-js">
264
+ $('#advanced').flagStrap({
265
+ buttonSize: "btn-lg",
266
+ buttonType: "btn-primary",
267
+ labelMargin: "20px",
268
+ scrollable: false,
269
+ scrollableHeight: "350px",
270
+ onSelect: function (value, element) {
271
+ alert(value);
272
+ console.log(element);
273
+ }
274
+ });
275
+ </pre>
276
+ </div>
277
+ <div class="col-xs-12 col-md-6">
278
+ <h3>Result</h3>
279
+
280
+ <form>
281
+ <div class="form-group">
282
+ <label>Select Country</label>
283
+
284
+ <div id="advanced"
285
+ data-input-name="country3"
286
+ data-selected-country="CA"
287
+ data-button-size="btn-lg"
288
+ data-button-type="btn-warning"
289
+ data-scrollable="true"
290
+ data-scrollable-height="250px"
291
+ data-countries='{"US": "United States","CA": "Canada"}'>
292
+ </div>
293
+ </div>
294
+ </form>
295
+ </div>
296
+ </div>
297
+ </div>
298
+
299
+ <script src="https://code.jquery.com/jquery-1.11.2.js"></script>
300
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
301
+ <script src="../dist/js/jquery.flagstrap.js"></script>
302
+
303
+ <script>
304
+ $('#basic').flagStrap();
305
+
306
+ $('#origin').flagStrap({
307
+ placeholder: {
308
+ value: "",
309
+ text: "Country of origin"
310
+ }
311
+ });
312
+
313
+ $('#options').flagStrap({
314
+ countries: {
315
+ "AU": "Australia",
316
+ "GB": "United Kingdom",
317
+ "US": "United States"
318
+ },
319
+ buttonSize: "btn-sm",
320
+ buttonType: "btn-info",
321
+ labelMargin: "10px",
322
+ scrollable: false,
323
+ scrollableHeight: "350px"
324
+ });
325
+
326
+ $('#advanced').flagStrap({
327
+ buttonSize: "btn-lg",
328
+ buttonType: "btn-primary",
329
+ labelMargin: "20px",
330
+ scrollable: false,
331
+ scrollableHeight: "350px",
332
+ onSelect: function (value, element) {
333
+ alert(value);
334
+ console.log(element);
335
+ }
336
+ });
337
+
338
+ </script>
339
+
340
+ </body>