Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
module.exports = function(grunt) {
2
 
3
  // timestamp in asset URLs for cache busting
4
  var time = (new Date()).getTime();
5
 
6
  return {
7
 
8
    // this is the first step in generating the actual plugin main JS file
9
    jsAddVersion: {
10
      src: 'src/js/intlTelInput.js',
11
      dest: 'tmp/versioned.js',
12
      options: {
13
        data: (function(version) {
14
          return {
15
            version: version,
16
          };
17
        })('<%= package.version %>')
18
      }
19
    },
20
 
21
    // generate the JS scripts for the examples (and cache-bust the utils.js URL)
22
    nationalModeJs: {
23
      src: 'examples/js/nationalMode.js.ejs',
24
      dest: 'examples/gen/js/nationalMode.js',
25
      options: {
26
        data: function() {
27
          return { time: time };
28
        }
29
      }
30
    },
31
    defaultCountryIpJs: {
32
      src: 'examples/js/defaultCountryIp.js.ejs',
33
      dest: 'examples/gen/js/defaultCountryIp.js',
34
      options: {
35
        data: function() {
36
          return { time: time };
37
        }
38
      }
39
    },
40
    modifyCountryDataJs: {
41
      src: 'examples/js/modifyCountryData.js.ejs',
42
      dest: 'examples/gen/js/modifyCountryData.js',
43
      options: {
44
        data: function() {
45
          return { time: time };
46
        }
47
      }
48
    },
49
    onlyCountriesEuropeJs: {
50
      src: 'examples/js/onlyCountriesEurope.js.ejs',
51
      dest: 'examples/gen/js/onlyCountriesEurope.js',
52
      options: {
53
        data: function() {
54
          return { time: time };
55
        }
56
      }
57
    },
58
    countrySyncJs: {
59
      src: 'examples/js/countrySync.js.ejs',
60
      dest: 'examples/gen/js/countrySync.js',
61
      options: {
62
        data: function() {
63
          return { time: time };
64
        }
65
      }
66
    },
67
    isValidNumberJs: {
68
      src: 'examples/js/isValidNumber.js.ejs',
69
      dest: 'examples/gen/js/isValidNumber.js',
70
      options: {
71
        data: function() {
72
          return { time: time };
73
        }
74
      }
75
    },
76
    hiddenInputJs: {
77
      src: 'examples/js/hiddenInput.js.ejs',
78
      dest: 'examples/gen/js/hiddenInput.js',
79
      options: {
80
        data: function() {
81
          return { time: time };
82
        }
83
      }
84
    },
85
    initPromiseJs: {
86
      src: 'examples/js/initPromise.js.ejs',
87
      dest: 'examples/gen/js/initPromise.js',
88
      options: {
89
        data: function() {
90
          return { time: time };
91
        }
92
      }
93
    },
94
    multipleInstancesJs: {
95
      src: 'examples/js/multipleInstances.js.ejs',
96
      dest: 'examples/gen/js/multipleInstances.js',
97
      options: {
98
        data: function() {
99
          return { time: time };
100
        }
101
      }
102
    },
103
    displayNumberJs: {
104
      src: 'examples/js/displayNumber.js.ejs',
105
      dest: 'examples/gen/js/displayNumber.js',
106
      options: {
107
        data: function() {
108
          return { time: time };
109
        }
110
      }
111
    },
112
 
113
    // generate the HTML example pages
114
    nationalMode: {
115
      src: 'examples/template.html.ejs',
116
      dest: 'examples/gen/national-mode.html',
117
      options: {
118
        data: function() {
119
          return {
120
            time: time,
121
            title: "National Mode",
122
            desc: "Allow users to enter their national number, and then convert it to international format using the public method getNumber.",
123
            stylesheet: "",
124
            markup: grunt.file.read('examples/partials/nationalMode.html'),
125
            code: grunt.file.read('examples/gen/js/nationalMode.js'),
126
            script: "nationalMode.js"
127
          };
128
        }
129
      }
130
    },
131
    defaultCountryIp: {
132
      src: 'examples/template.html.ejs',
133
      dest: 'examples/gen/default-country-ip.html',
134
      options: {
135
        data: function() {
136
          return {
137
            time: time,
138
            title: "Lookup user's country",
139
            desc: "Set initialCountry to 'auto' and pass in a function for geoIpLookup to perform a JSONP request to ipinfo.io, which returns the user's country based on their IP address.",
140
            stylesheet: "",
141
            markup: grunt.file.read('examples/partials/defaultCountryIp.html'),
142
            code: grunt.file.read('examples/gen/js/defaultCountryIp.js'),
143
            script: "defaultCountryIp.js"
144
          };
145
        }
146
      }
147
    },
148
    modifyCountryData: {
149
      src: 'examples/template.html.ejs',
150
      dest: 'examples/gen/modify-country-data.html',
151
      options: {
152
        data: function() {
153
          return {
154
            time: time,
155
            title: "Modify country data",
156
            desc: "Use static getCountryData method to update the data to only show localised country names.",
157
            stylesheet: "",
158
            markup: grunt.file.read('examples/partials/simpleInput.html'),
159
            code: grunt.file.read('examples/gen/js/modifyCountryData.js'),
160
            script: "modifyCountryData.js"
161
          };
162
        }
163
      }
164
    },
165
    onlyCountriesEurope: {
166
      src: 'examples/template.html.ejs',
167
      dest: 'examples/gen/only-countries-europe.html',
168
      options: {
169
        data: function() {
170
          return {
171
            time: time,
172
            title: "European countries",
173
            desc: "Set onlyCountries option to just European country codes.",
174
            stylesheet: "",
175
            markup: grunt.file.read('examples/partials/simpleInput.html'),
176
            code: grunt.file.read('examples/gen/js/onlyCountriesEurope.js'),
177
            script: "onlyCountriesEurope.js"
178
          };
179
        }
180
      }
181
    },
182
    countrySync: {
183
      src: 'examples/template.html.ejs',
184
      dest: 'examples/gen/country-sync.html',
185
      options: {
186
        data: function() {
187
          return {
188
            time: time,
189
            title: "Country sync",
190
            desc: "Use static getCountryData method to create a separate country dropdown for an address form, and then listen for change events to keep the two dropdowns in sync.",
191
            stylesheet: 'countrySync.css',
192
            markup: grunt.file.read('examples/partials/countrySync.html'),
193
            code: grunt.file.read('examples/gen/js/countrySync.js'),
194
            script: "countrySync.js"
195
          };
196
        }
197
      }
198
    },
199
    isValidNumber: {
200
      src: 'examples/template.html.ejs',
201
      dest: 'examples/gen/is-valid-number.html',
202
      options: {
203
        data: function() {
204
          return {
205
            time: time,
206
            title: "Validation",
207
            desc: "Use the isValidNumber method (which utilises Google's libphonenumber) to validate the telephone number on the blur event.",
208
            stylesheet: 'isValidNumber.css',
209
            markup: grunt.file.read('examples/partials/isValidNumber.html'),
210
            code: grunt.file.read('examples/gen/js/isValidNumber.js'),
211
            script: "isValidNumber.js"
212
          };
213
        }
214
      }
215
    },
216
    hiddenInput: {
217
      src: 'examples/template.html.ejs',
218
      dest: 'examples/gen/hidden-input.html',
219
      options: {
220
        data: function() {
221
          return {
222
            time: time,
223
            title: "Submitting the full international number using a hidden input",
224
            desc: "If you're submitting the form using Ajax, simply use getNumber to get the full international number before sending it. If you're using the standard form POST method, you can use the hiddenInput option to automatically create a hidden input that gets populated with the full international number on submit. Try submitting a valid number below, and then check the 'full_phone' parameter in the URL.",
225
            stylesheet: '',
226
            markup: grunt.file.read('examples/partials/hiddenInput.html'),
227
            code: grunt.file.read('examples/gen/js/hiddenInput.js'),
228
            script: "hiddenInput.js"
229
          };
230
        }
231
      }
232
    },
233
    initPromise: {
234
      src: 'examples/template.html.ejs',
235
      dest: 'examples/gen/init-promise.html',
236
      options: {
237
        data: function() {
238
          return {
239
            time: time,
240
            title: "Using the promise returned from initialisation",
241
            desc: "Use this promise to know when the plugin has completely finished initialising, including completing any asynchronous actions you might have enabled with the initialisation options e.g. fetching utils.js with the utilsScript option, and performing the ip lookup with the geoIpLookup option.",
242
            stylesheet: '',
243
            markup: grunt.file.read('examples/partials/initPromise.html'),
244
            code: grunt.file.read('examples/gen/js/initPromise.js'),
245
            script: "initPromise.js"
246
          };
247
        }
248
      }
249
    },
250
    multipleInstances: {
251
      src: 'examples/template.html.ejs',
252
      dest: 'examples/gen/multiple-instances.html',
253
      options: {
254
        data: function() {
255
          return {
256
            time: time,
257
            title: "Multiple Instances",
258
            desc: "Here you can see multiple instances of the plugin working alongside each other. I've set the placeholderNumberType differently for each instance to highlight that the instances are completely independent of each other.",
259
            stylesheet: '',
260
            markup: grunt.file.read('examples/partials/multipleInstances.html'),
261
            code: grunt.file.read('examples/gen/js/multipleInstances.js'),
262
            script: "multipleInstances.js"
263
          };
264
        }
265
      }
266
    },
267
    displayNumber: {
268
      src: 'examples/template.html.ejs',
269
      dest: 'examples/gen/display-number.html',
270
      options: {
271
        data: function() {
272
          return {
273
            time: time,
274
            title: "Display an existing number",
275
            desc: "We initialise the plugin on an input which already contains a full international number. The plugin will automatically select the relevant flag, and re-format the number to national format.",
276
            stylesheet: '',
277
            markup: grunt.file.read('examples/partials/displayNumber.html'),
278
            code: grunt.file.read('examples/gen/js/displayNumber.js'),
279
            script: "displayNumber.js"
280
          };
281
        }
282
      }
283
    },
284
  };
285
};