anjlab-widgets 1.0.10 → 3.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e86ff18469e15a9480df188078c94e2d11f2a18
4
- data.tar.gz: d20e9cf5f19176ada909548a569f921b11f10c03
3
+ metadata.gz: aefb208eb0bc67c608fa241a6dccfc938e7e4624
4
+ data.tar.gz: 17089bf6506785e0d33bc5e45d913f0211203c09
5
5
  SHA512:
6
- metadata.gz: dc97f393f07f711aa2a84bff401e1a37b038f8759808d96fd7bc1928ade112c95b9baa1b543838ccbc02e7cfb2985f05db5d3faad53bc395e72d7a69ea46aac1
7
- data.tar.gz: 8b2b108ab9973329a43e0cc9ed0a25730be5178d7b84726885cdf68f653ec7ea52a8cb1be5812a1a16b27f617a5c7706c5ff4b4b66ae0fa697454a48edf50f5c
6
+ metadata.gz: 35bfc9b32dd0629a2761ca83225cb2a37ed0ef93a050573e96d86f2c98c3c58a5309305510d7ddd848504fb70205ae96924d0e8c92f0b1526d75dbe4e64fe948
7
+ data.tar.gz: 11d6c6651b977c8c6fbd0bba27afe2106ee0ff0143fa487e7c6f89b5f8432558506a2654200c5111f965ab35a2472e77559d4ff698c2c471e3fd4bc86a0dae3b
@@ -1,4 +1,4 @@
1
- Locales =
1
+ Locales =
2
2
  en:
3
3
  dates:
4
4
  format: 'mm/dd/yyyy'
@@ -17,7 +17,16 @@ 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
+ pt:
21
+ dates:
22
+ format: 'dd/mm/yyyy'
23
+ weekStart: 1
24
+ days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sabado", "Domingo"]
25
+ daysShort: ["Dom", "Seg", "Ter", "Quar", "Qui", "Sex", "Sab", "Dom"]
26
+ daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sa", "Do"]
27
+ months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]
28
+ monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"]
29
+ ru:
21
30
  dates:
22
31
  format: 'dd.mm.yyyy'
23
32
  weekStart: 1
@@ -26,15 +35,6 @@ Locales =
26
35
  daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"]
27
36
  months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"]
28
37
  monthsShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"]
29
- 'zh-TW':
30
- dates:
31
- format: 'yyyy-mm-dd'
32
- weekStart: 0
33
- days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
34
- daysShort: ["日", "一", "二", "三", "四", "五", "六", "日"]
35
- daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"]
36
- months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
37
- monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
38
38
 
39
39
  DateTools =
40
40
  modes: [
@@ -56,7 +56,7 @@ DateTools =
56
56
  ]
57
57
  isLeapYear: (year) ->
58
58
  (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
59
-
59
+
60
60
  getDaysInMonth: (year, month) ->
61
61
  [31, (if DateTools.isLeapYear(year) then 29 else 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
62
62
 
@@ -64,8 +64,8 @@ DateTools =
64
64
  separator = format.match(/[.\/-].*?/)
65
65
  parts = format.split(/\W+/)
66
66
  if !separator || !parts || parts.length == 0
67
- throw new Error("Invalid date format.")
68
-
67
+ throw new Error("Invalid date format.")
68
+
69
69
  {
70
70
  separator: separator
71
71
  parts: parts
@@ -89,7 +89,7 @@ DateTools =
89
89
  when 'yyyy'
90
90
  y = val
91
91
  new Date(y, m, d)
92
-
92
+
93
93
  formatDate: (date, format) ->
94
94
  return "" if date == null
95
95
  val = {
@@ -114,9 +114,9 @@ DateTools =
114
114
 
115
115
  headTemplate: '<thead>'+
116
116
  '<tr>'+
117
- '<th class="prev"><span class="icon-left"/></th>'+
117
+ '<th class="prev"><i class="icon-arrow-left"/></th>'+
118
118
  '<th colspan="5" class="switch"></th>'+
119
- '<th class="next"><span class="icon-right"/></th>'+
119
+ '<th class="next"><i class="icon-arrow-right"/></th>'+
120
120
  '</tr>'+
121
121
  '</thead>'
122
122
 
@@ -143,19 +143,6 @@ DateTools.template = '<div class="datepicker dropdown-menu">'+
143
143
  '</div>'+
144
144
  '</div>'
145
145
 
146
- convertToNative = ($input, options)->
147
- value = $input.attr('value')
148
- $input.prop("type", "date")
149
- if value && value.length > 0
150
- locale = options.locale || $input.data('date-locale') || DateTools.getLocale()
151
- format = DateTools.parseFormat(options.format || $input.data('date-format') || Locales[locale].dates.format)
152
- date = DateTools.parseDate(value, format)
153
- value = DateTools.formatDate(date, {
154
- separator: '-'
155
- parts: ["yyyy", "mm", "dd"]
156
- })
157
- $input.prop('value', value)
158
-
159
146
  class NativeRailsDatepicker
160
147
  constructor: (element, options)->
161
148
  @element = $(element)
@@ -174,9 +161,6 @@ class NativeRailsDatepicker
174
161
 
175
162
  @updateRails()
176
163
 
177
- getISOString: ->
178
- @element.val()
179
-
180
164
  updateRails: ->
181
165
  return if !@rails
182
166
 
@@ -186,14 +170,14 @@ class NativeRailsDatepicker
186
170
  else
187
171
  parent.find('.js-aw-1i').val(@date.getFullYear())
188
172
  parent.find('.js-aw-2i').val(@date.getMonth() + 1)
189
- parent.find('.js-aw-3i').val(@date.getDate())
173
+ parent.find('.js-aw-3i').val(@date.getDate())
190
174
 
191
175
 
192
176
  class Datepicker extends NativeRailsDatepicker
193
177
 
194
178
  constructor: (element, options)->
195
179
  super(element, options)
196
- @locale = options.locale || @element.data('date-locale') || DateTools.getLocale()
180
+ @locale = options.locale || @element.data('date-locale') || DateTools.getLocale()
197
181
  @format = DateTools.parseFormat(options.format || @element.data('date-format') || Locales[@locale].dates.format);
198
182
  @allowBlank = options.allowBlank ? @element.data('date-allow-blank') ? true
199
183
  @picker = $(DateTools.template).appendTo('body').on {
@@ -202,13 +186,13 @@ class Datepicker extends NativeRailsDatepicker
202
186
  }
203
187
 
204
188
  @isInput = @element.is('input');
205
- @component = if !@isInput && @element.is('.date') then @element.find('.add-on') else false;
189
+ @component = if @element.is('.date') then @element.find('.add-on') else false;
206
190
 
207
191
  if @isInput
208
192
  @element.on {
209
193
  focus: $.proxy(@show, this)
210
194
  click: $.proxy(@show, this)
211
- blur: $.proxy(@hide, this)
195
+ blur: $.proxy(@hide, this)
212
196
  keyup: $.proxy(@update, this)
213
197
  }
214
198
  else
@@ -233,9 +217,9 @@ class Datepicker extends NativeRailsDatepicker
233
217
  if e
234
218
  e.stopPropagation()
235
219
  e.preventDefault()
236
-
220
+
237
221
  $(document).on('mousedown', $.proxy(@hide, this)) if !@isInput
238
-
222
+
239
223
  @element.trigger
240
224
  type: 'show'
241
225
  date: @date
@@ -247,6 +231,7 @@ class Datepicker extends NativeRailsDatepicker
247
231
  @showMode()
248
232
  $(document).off('mousedown', @hide) if !@isInput
249
233
 
234
+ @setValue()
250
235
  @element.trigger
251
236
  type: 'hide'
252
237
  date: @date
@@ -255,10 +240,10 @@ class Datepicker extends NativeRailsDatepicker
255
240
  formated = DateTools.formatDate(@date, @format)
256
241
  if !@isInput
257
242
  if @component
258
- @element.find('input').val(formated).change()
243
+ @element.find('input').prop('value', formated)
259
244
  @element.data('date', formated)
260
245
  else
261
- @element.val(formated).change()
246
+ @element.prop('value', formated)
262
247
 
263
248
  place: ->
264
249
  offset = if @component then @component.offset() else @element.offset()
@@ -266,12 +251,6 @@ class Datepicker extends NativeRailsDatepicker
266
251
  top: offset.top + @height
267
252
  left: offset.left
268
253
 
269
- getISOString: ->
270
- DateTools.formatDate(@date, {
271
- separator: '-'
272
- parts: ["yyyy", "mm", "dd"]
273
- })
274
-
275
254
  update: ->
276
255
  @date = DateTools.parseDate(
277
256
  if @isInput then this.element.prop('value') else @element.data('date'),
@@ -282,10 +261,9 @@ class Datepicker extends NativeRailsDatepicker
282
261
  @date = DateTools.today()
283
262
 
284
263
  if @date != null
285
- @viewDate = new Date(@date)
264
+ @viewDate = @date
286
265
  else
287
266
  @viewDate = DateTools.today()
288
-
289
267
  @fill()
290
268
 
291
269
  fillDow: ->
@@ -306,14 +284,13 @@ class Datepicker extends NativeRailsDatepicker
306
284
  html.push '<span class="month">'
307
285
  html.push Locales[@locale].dates.monthsShort[i++]
308
286
  html.push '</span>'
309
-
287
+
310
288
  @picker.find('.datepicker-months td').append(html.join(''))
311
289
 
312
290
  fill: ->
313
291
  d = new Date(@viewDate)
314
292
  year = d.getFullYear()
315
293
  month = d.getMonth()
316
- today = DateTools.today().valueOf()
317
294
 
318
295
  @updateRails()
319
296
  date = if @date != null then @date else DateTools.today()
@@ -331,27 +308,25 @@ class Datepicker extends NativeRailsDatepicker
331
308
 
332
309
  while prevMonth.valueOf() < nextMonth
333
310
  html.push '<tr>' if prevMonth.getDay() == @weekStart
334
-
311
+
335
312
  clsName = '';
336
313
  if prevMonth.getMonth() < month
337
- clsName += ' old'
314
+ clsName += ' old'
338
315
  else if prevMonth.getMonth() > month
339
316
  clsName += ' new'
340
-
341
- if prevMonth.valueOf() == today
342
- clsName += ' today'
343
-
317
+
344
318
  if prevMonth.valueOf() == currentDate
345
319
  clsName += ' active'
346
-
320
+
347
321
  html.push "<td class='day#{clsName}'>#{prevMonth.getDate()}</td>"
348
322
  html.push '</tr>' if prevMonth.getDay() == @weekEnd
349
-
323
+
350
324
  prevMonth.setDate(prevMonth.getDate()+1)
325
+
351
326
 
352
327
  @picker.find('.datepicker-days tbody').empty().append(html.join(''))
353
328
  currentYear = date.getFullYear()
354
-
329
+
355
330
  months = @picker.find('.datepicker-months').find('th:eq(1)').text(year).end().find('span').removeClass('active')
356
331
  months.eq(date.getMonth()).addClass('active') if currentYear == year
357
332
 
@@ -377,7 +352,7 @@ class Datepicker extends NativeRailsDatepicker
377
352
  when 'prev', 'next'
378
353
  @viewDate['set'+DateTools.modes[this.viewMode].navFnc].call(
379
354
  @viewDate,
380
- @viewDate['get'+DateTools.modes[this.viewMode].navFnc].call(@viewDate) +
355
+ @viewDate['get'+DateTools.modes[this.viewMode].navFnc].call(@viewDate) +
381
356
  DateTools.modes[this.viewMode].navStep * (if target[0].className == 'prev' then -1 else 1))
382
357
  @fill()
383
358
  when 'span'
@@ -397,6 +372,7 @@ class Datepicker extends NativeRailsDatepicker
397
372
  month -= 1
398
373
  else if target.is('.new')
399
374
  month += 1
375
+
400
376
  year = @viewDate.getFullYear()
401
377
  @date = new Date(year, month, day,0,0,0,0);
402
378
  @viewDate = new Date(year, month, day,0,0,0,0);
@@ -418,6 +394,20 @@ class Datepicker extends NativeRailsDatepicker
418
394
 
419
395
  nativePicker = false
420
396
 
397
+ convertToNative = ($input, options)->
398
+ value = $input.attr('value')
399
+ $input.prop("type", "date")
400
+ if value && value.length > 0
401
+ locale = options.locale || $input.data('date-locale') || DateTools.getLocale()
402
+ format = DateTools.parseFormat(options.format || $input.data('date-format') || Locales[locale].dates.format);
403
+ date = DateTools.parseDate(value, format)
404
+ value = DateTools.formatDate(date, {
405
+ separator: '-'
406
+ parts: ["yyyy", "mm", "dd"]
407
+ })
408
+ $input.prop('value', value)
409
+
410
+
421
411
  $.fn.datepicker = (option) ->
422
412
  @each ->
423
413
  $this = $(this)
@@ -38,7 +38,6 @@
38
38
  }
39
39
  &.active,
40
40
  &.active:hover {
41
- @include btn-pseudo-states($btn-primary-color, $btn-primary-bg, $btn-primary-border);
42
41
  color: #fff;
43
42
  text-shadow: 0 -1px 0 rgba(0,0,0,.25);
44
43
  }
@@ -55,7 +54,6 @@
55
54
  background: $gray-lighter;
56
55
  }
57
56
  &.active {
58
- @include btn-pseudo-states($btn-primary-color, $btn-primary-bg, $btn-primary-border);
59
57
  color: #fff;
60
58
  text-shadow: 0 -1px 0 rgba(0,0,0,.25);
61
59
  }
@@ -88,6 +86,9 @@
88
86
  }
89
87
  }
90
88
  }
89
+
90
+ @include button-variant(".datepicker td.active,.datepicker td.active:hover, .datepicker span.active", $btn-primary-color, $btn-primary-bg, $btn-primary-border);
91
+
91
92
  .input-append,
92
93
  .input-prepend {
93
94
  &.date {
@@ -27,10 +27,10 @@
27
27
  }
28
28
  &.active,
29
29
  &.active:hover {
30
- @include btn-pseudo-states($btn-primary-color, $btn-primary-bg, $btn-primary-border);
31
30
  color: #fff;
32
31
  text-shadow: 0 -1px 0 rgba(0,0,0,.25);
33
32
  }
34
33
  }
34
+ }
35
35
 
36
- }
36
+ @include button-variant(".timepicker a.active,.timepicker a.active:hover", $btn-primary-color, $btn-primary-bg, $btn-primary-border);
@@ -1,5 +1,5 @@
1
1
  module Anjlab
2
2
  module Widgets
3
- VERSION = "1.0.10"
3
+ VERSION = "3.0.0"
4
4
  end
5
5
  end
@@ -3,14 +3,16 @@ require "anjlab-widgets/engine"
3
3
 
4
4
  module Anjlab
5
5
  module Widgets
6
- def self.date_format
7
- case ::I18n.default_locale
6
+ def self.date_format date_format_locale = ::I18n.default_locale
7
+ case date_format_locale
8
8
  when :ru
9
9
  "%d.%m.%Y"
10
10
  when :en
11
11
  "%m/%d/%Y"
12
12
  when :es
13
13
  "%d/%m/%Y"
14
+ when :pt
15
+ "%d/%m/%Y"
14
16
  when :'zh-TW'
15
17
  "%Y-%m-%d"
16
18
  else
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.10
4
+ version: 3.0.0
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-08-02 00:00:00.000000000 Z
11
+ date: 2013-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anjlab-bootstrap-rails