anjlab-widgets 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 355005b0d7975a1382bd50728ee148a5128c7c33
4
- data.tar.gz: 01b84b9b1d72741a3955469b0ce43bce8f94a3c0
3
+ metadata.gz: 5b69f47abeaf7b61bdb221c7a3509fddafabf892
4
+ data.tar.gz: 34888ccf4d7d1e5e869e622acbc6d900acb2c889
5
5
  SHA512:
6
- metadata.gz: a73a35f819343d8e5865a9706d4a4a18dffccd74d7d8cb8912e8182a39a223713ce6947f44491311b1ed2d48fad9c5abc4ea367c04d9fb4de99ab6e3204611f2
7
- data.tar.gz: 590d24fd3e0e15e69b551eaee6fc5a8240beb8ba9e33e5ea7a1e42f98c9566ec82c22eea469756f6a38fe3ac5d37e16c6bb0b2ce1dc17c771d0eda2f63d00a4b
6
+ metadata.gz: defcdfa8db289dc2cd10da3875426cff48d156aa61a7577bee5ea6470d6728e7af553e8dca356dacefff0494754042a2f55c46f5407276fd095e85024a58f07f
7
+ data.tar.gz: b02e31d532188c0423e6c09a3541933cf8b60b40c421dfedf77a05177e30879c2888aa7914a792c498ebce38b6774d25d9f2fa052da8696ce240cbe007887185
data/README.md CHANGED
@@ -4,7 +4,7 @@ Bootstrap date and time pickers for rails (ready for rails 4).
4
4
 
5
5
  Note: `simple_form` gem is supported.
6
6
 
7
- Currently `en`, `es` and `ru` locales are supported.
7
+ Currently `en`, `es`, `zh-TW` and `ru` locales are supported.
8
8
 
9
9
  Note: please use it with [bootstrap-rails](https://github.com/anjlab/bootstrap-rails)
10
10
 
@@ -1,4 +1,4 @@
1
- Locales =
1
+ Locales =
2
2
  en:
3
3
  dates:
4
4
  format: 'mm/dd/yyyy'
@@ -17,7 +17,7 @@ Locales =
17
17
  daysMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"]
18
18
  months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"]
19
19
  monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"]
20
- ru:
20
+ ru:
21
21
  dates:
22
22
  format: 'dd.mm.yyyy'
23
23
  weekStart: 1
@@ -26,6 +26,15 @@ Locales =
26
26
  daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"]
27
27
  months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"]
28
28
  monthsShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"]
29
+ 'zh-TW':
30
+ dates:
31
+ format: 'yyyy-mm-dd'
32
+ weekStart: 0
33
+ days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
34
+ daysShort: ["日", "一", "二", "三", "四", "五", "六", "日"]
35
+ daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"]
36
+ months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
37
+ monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
29
38
 
30
39
  DateTools =
31
40
  modes: [
@@ -47,7 +56,7 @@ DateTools =
47
56
  ]
48
57
  isLeapYear: (year) ->
49
58
  (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
50
-
59
+
51
60
  getDaysInMonth: (year, month) ->
52
61
  [31, (if DateTools.isLeapYear(year) then 29 else 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
53
62
 
@@ -55,8 +64,8 @@ DateTools =
55
64
  separator = format.match(/[.\/-].*?/)
56
65
  parts = format.split(/\W+/)
57
66
  if !separator || !parts || parts.length == 0
58
- throw new Error("Invalid date format.")
59
-
67
+ throw new Error("Invalid date format.")
68
+
60
69
  {
61
70
  separator: separator
62
71
  parts: parts
@@ -80,7 +89,7 @@ DateTools =
80
89
  when 'yyyy'
81
90
  y = val
82
91
  new Date(y, m, d)
83
-
92
+
84
93
  formatDate: (date, format) ->
85
94
  return "" if date == null
86
95
  val = {
@@ -161,14 +170,14 @@ class NativeRailsDatepicker
161
170
  else
162
171
  parent.find('.js-aw-1i').val(@date.getFullYear())
163
172
  parent.find('.js-aw-2i').val(@date.getMonth() + 1)
164
- parent.find('.js-aw-3i').val(@date.getDate())
173
+ parent.find('.js-aw-3i').val(@date.getDate())
165
174
 
166
175
 
167
176
  class Datepicker extends NativeRailsDatepicker
168
177
 
169
178
  constructor: (element, options)->
170
179
  super(element, options)
171
- @locale = options.locale || @element.data('date-locale') || DateTools.getLocale()
180
+ @locale = options.locale || @element.data('date-locale') || DateTools.getLocale()
172
181
  @format = DateTools.parseFormat(options.format || @element.data('date-format') || Locales[@locale].dates.format);
173
182
  @allowBlank = options.allowBlank ? @element.data('date-allow-blank') ? true
174
183
  @picker = $(DateTools.template).appendTo('body').on {
@@ -208,9 +217,9 @@ class Datepicker extends NativeRailsDatepicker
208
217
  if e
209
218
  e.stopPropagation()
210
219
  e.preventDefault()
211
-
220
+
212
221
  $(document).on('mousedown', $.proxy(@hide, this)) if !@isInput
213
-
222
+
214
223
  @element.trigger
215
224
  type: 'show'
216
225
  date: @date
@@ -275,7 +284,7 @@ class Datepicker extends NativeRailsDatepicker
275
284
  html.push '<span class="month">'
276
285
  html.push Locales[@locale].dates.monthsShort[i++]
277
286
  html.push '</span>'
278
-
287
+
279
288
  @picker.find('.datepicker-months td').append(html.join(''))
280
289
 
281
290
  fill: ->
@@ -299,25 +308,24 @@ class Datepicker extends NativeRailsDatepicker
299
308
 
300
309
  while prevMonth.valueOf() < nextMonth
301
310
  html.push '<tr>' if prevMonth.getDay() == @weekStart
302
-
311
+
303
312
  clsName = '';
304
313
  if prevMonth.getMonth() < month
305
- clsName += ' old'
314
+ clsName += ' old'
306
315
  else if prevMonth.getMonth() > month
307
316
  clsName += ' new'
308
-
317
+
309
318
  if prevMonth.valueOf() == currentDate
310
319
  clsName += ' active'
311
-
320
+
312
321
  html.push "<td class='day#{clsName}'>#{prevMonth.getDate()}</td>"
313
322
  html.push '</tr>' if prevMonth.getDay() == @weekEnd
314
-
323
+
315
324
  prevMonth.setDate(prevMonth.getDate()+1)
316
-
317
325
 
318
326
  @picker.find('.datepicker-days tbody').empty().append(html.join(''))
319
327
  currentYear = date.getFullYear()
320
-
328
+
321
329
  months = @picker.find('.datepicker-months').find('th:eq(1)').text(year).end().find('span').removeClass('active')
322
330
  months.eq(date.getMonth()).addClass('active') if currentYear == year
323
331
 
@@ -343,7 +351,7 @@ class Datepicker extends NativeRailsDatepicker
343
351
  when 'prev', 'next'
344
352
  @viewDate['set'+DateTools.modes[this.viewMode].navFnc].call(
345
353
  @viewDate,
346
- @viewDate['get'+DateTools.modes[this.viewMode].navFnc].call(@viewDate) +
354
+ @viewDate['get'+DateTools.modes[this.viewMode].navFnc].call(@viewDate) +
347
355
  DateTools.modes[this.viewMode].navStep * (if target[0].className == 'prev' then -1 else 1))
348
356
  @fill()
349
357
  when 'span'
@@ -363,7 +371,7 @@ class Datepicker extends NativeRailsDatepicker
363
371
  month -= 1
364
372
  else if target.is('.new')
365
373
  month += 1
366
-
374
+
367
375
  year = @viewDate.getFullYear()
368
376
  @date = new Date(year, month, day,0,0,0,0);
369
377
  @viewDate = new Date(year, month, day,0,0,0,0);
@@ -397,7 +405,6 @@ convertToNative = ($input, options)->
397
405
  parts: ["yyyy", "mm", "dd"]
398
406
  })
399
407
  $input.prop('value', value)
400
-
401
408
 
402
409
  $.fn.datepicker = (option) ->
403
410
  @each ->
@@ -40,13 +40,11 @@ class Timepicker extends NativeRailsTimepicker
40
40
  focus: $.proxy(@show, this)
41
41
  click: $.proxy(@show, this)
42
42
  blur: $.proxy(@hide, this)
43
-
44
43
  }
45
44
 
46
45
  @step = options.step || @element.data('date-time-step') || 30
47
46
  @minTime = options.minTime || @element.data('date-time-min') || 9 * 60
48
47
  @maxTime = options.maxTime || @element.data('date-time-max') || 20 * 60
49
-
50
48
 
51
49
  @fillTimes()
52
50
  @update()
@@ -64,7 +62,7 @@ class Timepicker extends NativeRailsTimepicker
64
62
  e.preventDefault()
65
63
  target = $(e.target)
66
64
 
67
- if target.is 'a'
65
+ if target.is 'a'
68
66
  @time = target.data('time')
69
67
  @setValue()
70
68
  @update()
@@ -113,7 +111,7 @@ class Timepicker extends NativeRailsTimepicker
113
111
  if e
114
112
  e.stopPropagation()
115
113
  e.preventDefault()
116
-
114
+
117
115
  @element.trigger {
118
116
  type: 'show'
119
117
  date: @time
@@ -3,7 +3,7 @@
3
3
  left: 0;
4
4
  padding: 4px;
5
5
  margin-top: 1px;
6
- @include border-radius(4px);
6
+ @include border-radius(4px);
7
7
 
8
8
  >div {
9
9
  display: none;
@@ -13,7 +13,7 @@
13
13
  .datepicker-years {
14
14
  display: block;
15
15
  }
16
-
16
+
17
17
  table{
18
18
  width: 100%;
19
19
  margin: 0;
@@ -61,11 +61,11 @@
61
61
  }
62
62
  }
63
63
  }
64
-
64
+
65
65
  th.switch {
66
66
  width: 145px;
67
67
  }
68
-
68
+
69
69
  thead tr:first-child th {
70
70
  cursor: pointer;
71
71
  &:hover {
@@ -3,7 +3,7 @@ require "anjlab-widgets/engine"
3
3
 
4
4
  module Anjlab
5
5
  module Widgets
6
- def self.date_format
6
+ def self.date_format
7
7
  case ::I18n.default_locale
8
8
  when :ru
9
9
  "%d.%m.%Y"
@@ -11,6 +11,8 @@ module Anjlab
11
11
  "%m/%d/%Y"
12
12
  when :es
13
13
  "%d/%m/%Y"
14
+ when :'zh-TW'
15
+ "%Y-%m-%d"
14
16
  else
15
17
  "%Y-%m-%d"
16
18
  end
@@ -27,7 +27,7 @@ module Anjlab
27
27
  "data-rails" => true,
28
28
  :value => Widgets::format_time(time),
29
29
  :required => input_html_options[:required],
30
- :class => "#{input_html_options[:time_class] || 'input-small'}"
30
+ :class => "#{input_html_options[:time_class] || 'input-small'}"
31
31
  }
32
32
 
33
33
  case input_type
@@ -1,5 +1,5 @@
1
1
  module Anjlab
2
2
  module Widgets
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anjlab-widgets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Korolev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-10 00:00:00.000000000 Z
11
+ date: 2013-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anjlab-bootstrap-rails