ultimate-base 0.3.3.0 → 0.3.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ultimate-base (0.3.3.0)
4
+ ultimate-base (0.3.4.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,18 +1,35 @@
1
1
  #= require ./base
2
2
 
3
- # TODO ready options
4
-
5
3
  class Ultimate.Backbone.Collection extends Backbone.Collection
6
4
 
7
- constructor: ->
5
+ readyDeferred: null
6
+ loaded: false
7
+ loadedTimeStamp: null
8
+ expireTime: Infinity
9
+
10
+ constructor: (models, options = {}) ->
8
11
  Ultimate.Backbone.debug ".Collection.constructor()", @
12
+ @expireTime = options.expireTime if options.expireTime?
9
13
  super
10
14
 
11
- ready: (callback, context = @) ->
12
- unless @length
13
- @readyDeferred ||= $.Deferred()
15
+ reset: (models, options) ->
16
+ @loadedTimeStamp = new Date()
17
+ @loaded = true
18
+ super
19
+
20
+ ready: (callback, fetchOptions) ->
21
+ lifeTime = if @loadedTimeStamp then (new Date() - @loadedTimeStamp) else 0
22
+ if expired = lifeTime > @expireTime
23
+ @readyDeferred = null
24
+ if not @loaded or expired
25
+ @readyDeferred ||= @fetch(fetchOptions)
14
26
  @readyDeferred.done =>
15
- callback.apply context, [@]
16
- @fetch success: (=> @readyDeferred.resolve()), silent: true
27
+ callback.apply @
17
28
  else
18
- callback.apply context, [@]
29
+ callback.apply @
30
+
31
+ abort: ->
32
+ if @readyDeferred?
33
+ if @readyDeferred.state() is 'pending'
34
+ @readyDeferred.abort()
35
+ @readyDeferred = null
@@ -4,18 +4,35 @@
4
4
 
5
5
  class Ultimate.Backbone.Model extends Backbone.Model
6
6
 
7
- constructor: ->
7
+ readyDeferred: null
8
+ loaded: false
9
+ loadedTimeStamp: null
10
+ expireTime: Infinity
11
+
12
+ constructor: (attributes, options = {}) ->
8
13
  Ultimate.Backbone.debug ".Model.constructor()", @
14
+ @expireTime = options.expireTime if options.expireTime?
15
+ @on 'sync', =>
16
+ @loadedTimeStamp = new Date()
17
+ @loaded = true
9
18
  super
10
19
 
11
- ready: (callback, context = @) ->
12
- if _.isEmpty(@attributes)
13
- @readyDeferred ||= $.Deferred()
20
+ ready: (callback, fetchOptions) ->
21
+ lifeTime = if @loadedTimeStamp then (new Date() - @loadedTimeStamp) else 0
22
+ if expired = lifeTime > @expireTime
23
+ @readyDeferred = null
24
+ if @id and (not @loaded or expired)
25
+ @readyDeferred ||= @fetch(fetchOptions)
14
26
  @readyDeferred.done =>
15
- callback.apply context, [@]
16
- @fetch success: (=> @readyDeferred.resolve()), silent: true
27
+ callback.apply @
17
28
  else
18
- callback.apply context, [@]
29
+ callback.apply @
30
+
31
+ abort: ->
32
+ if @readyDeferred?
33
+ if @readyDeferred.state() is 'pending'
34
+ @readyDeferred.abort()
35
+ @readyDeferred = null
19
36
 
20
37
  singular: ->
21
38
  modelName = @constructor.modelName or @modelName or @className or @constructor.name or 'Model'
@@ -89,19 +89,22 @@ class Ultimate.Backbone.View extends Backbone.View
89
89
  # Overloadable getter for jQuery-container that will be blocked.
90
90
  getJLoadingContainer: -> @$el
91
91
 
92
- loading: (state, text = "", circle = true) ->
92
+ loading: (state, text = "", circle = false) ->
93
93
  jLoadingContainer = @getJLoadingContainer()
94
- if jLoadingContainer and jLoadingContainer.length
94
+ if jLoadingContainer?.length
95
95
  jLoadingContainer.removeClass @loadingStateClass
96
96
  jLoadingContainer.children(".#{@loadingOverlayClass}").remove()
97
97
  if @loadingState = state
98
98
  jLoadingContainer.addClass @loadingStateClass
99
- width = jLoadingContainer[@loadingWidthMethodName]()
100
- height = jLoadingContainer[@loadingHeightMethodName]()
101
- text = "<span class=\"text\">#{text}</span>" if text
102
- circle = "<span class=\"circle\"></span>" if circle
103
- style = "width: #{width}px; height: #{height}px; line-height: #{height}px;"
104
- jLoadingContainer.append "<div class=\"#{@loadingOverlayClass}\" style=\"#{style}\">#{circle}#{text}</div>"
99
+ style = []
100
+ if @loadingWidthMethodName
101
+ style.push "width: #{jLoadingContainer[@loadingWidthMethodName]()}px;"
102
+ if @loadingHeightMethodName
103
+ height = jLoadingContainer[@loadingHeightMethodName]()
104
+ style.push "height: #{height}px; line-height: #{height}px;"
105
+ text = if text then "<span class=\"text\">#{text}</span>" else ''
106
+ circle = if circle then "<span class=\"circle\"></span>" else ''
107
+ jLoadingContainer.append "<div class=\"#{@loadingOverlayClass}\" style=\"#{style.join(' ')}\">#{circle}#{text}</div>"
105
108
 
106
109
 
107
110
 
@@ -1,10 +1,10 @@
1
- ( ( $ ) ->
1
+ do ( $ = jQuery ) ->
2
2
 
3
3
  # TODO try optimize, excepting Edge and search in siblings for next cycle
4
4
  $.fn.nearestFind = (selector, extremeEdgeSelector = 'form, body') ->
5
5
  jEdge = @
6
- jResult = jEdge.find selector
7
- until jResult.length or jEdge.is extremeEdgeSelector
6
+ jResult = jEdge.find(selector)
7
+ until jResult.length or jEdge.is(extremeEdgeSelector)
8
8
  jEdge = jEdge.parent()
9
9
  jResult = jEdge.find selector
10
10
  jResult
@@ -21,31 +21,30 @@
21
21
  # @param strongById: Boolean = false
22
22
  $.fn.closestLabel = ( strongById = false, passCache = false ) ->
23
23
  (if @is(':input') then @ else @find(':input')).filter(':not(input[type="hidden"])').map ->
24
- jInput = $ @
25
- jLabel = jInput.data 'closestLabel' unless passCache
24
+ jInput = $(@)
25
+ jLabel = jInput.data('closestLabel') unless passCache
26
26
  unless jLabel
27
27
  if jLabel is false
28
28
  return null
29
29
  else
30
30
  jLabel = {length: 0}
31
- jEdge = jInput.closestEdge() # TODO may be need params
32
- inputId = jInput.attr 'id'
31
+ inputId = jInput.attr('id')
33
32
  if inputId
34
33
  # try search label by id linkage
35
- labelSelectorByFor = "label[for=\"#{inputId}\"]"
36
- # at first search in the edge area
37
- jLabel = jEdge.find labelSelectorByFor
38
- unless jLabel.length
39
- # try search in the closest form
40
- jLabel = jInput.closest('form').find labelSelectorByFor
41
- # trust only unique label on the form
42
- jLabel = {length: 0} if jLabel.length > 1
34
+ jLabel = jInput.nearestFind("label[for=\"#{inputId}\"]:first")
43
35
  # try get first labet in the edge area
44
- jLabel = jEdge.find('label:first') unless jLabel.length
36
+ unless jLabel.length
37
+ jLabel = jInput.nearestFind('label')
38
+ if jLabel.length is 1
39
+ jReverseInput = jLabel.nearestFind(':input')
40
+ unless jReverseInput.length is 1 and jReverseInput[0] is jInput[0]
41
+ jLabel = {length: 0}
42
+ else if jLabel.length > 1
43
+ jLabel = {length: 0}
45
44
  # taken!
46
45
  if jLabel.length
47
46
  # oh, this label already linked
48
- if jLabel.data 'closestInput'
47
+ if jLabel.data('closestInput')
49
48
  jLabel = {length: 0}
50
49
  else
51
50
  jLabel.data 'closestInput', jInput
@@ -151,5 +150,3 @@
151
150
  @find("input:not([readonly])#{if onlyVisible then ':visible' else ''}").each ->
152
151
  $(@).attr 'tabindex', ++$.fillTabIndexesCounter
153
152
  @
154
-
155
- )( jQuery )
@@ -14,8 +14,23 @@
14
14
  @return $i > $l;
15
15
  }
16
16
 
17
+ @function list-rtrim($list, $count: 1) {
18
+ $r: ();
19
+ $l: length($list) - $count;
20
+ $i: 1;
21
+ @while $i <= $l {
22
+ $r: append($r, nth($list, $i));
23
+ $i: $i + 1;
24
+ }
25
+ @return $r;
26
+ }
27
+
17
28
  @function complex-list($params) {
18
29
  $l: length($params);
30
+ @if $l > 1 and nth($params, $l) == !important {
31
+ $params: list-rtrim($params);
32
+ $l: $l - 1;
33
+ }
19
34
  @if $l < 4 {
20
35
  @if $l < 3 {
21
36
  $params: join($params, nth($params, 1));
@@ -50,10 +65,6 @@
50
65
  }
51
66
  }
52
67
 
53
- @function max($a, $b) {
54
- @return if($a > $b, $a, $b);
55
- }
56
-
57
68
  @function strip-px($v) {
58
69
  @return if(unit($v) == "px", $v / 1px, $v);
59
70
  }
@@ -93,3 +104,8 @@
93
104
  @function hack-ie8($params) {
94
105
  @return unquote("#{$params}\0/");
95
106
  }
107
+
108
+ @function contains($list, $var) {
109
+ @each $item in $list { @if $item == $var { @return true; } }
110
+ @return false;
111
+ }
@@ -256,12 +256,16 @@ $boxsizing-url: asset-url("polyfills/boxsizing.htc", '') !default;
256
256
  // @include ellipsis;
257
257
  // produce:
258
258
  // overflow: hidden; // need to work text-overflow
259
+ // white-space: nowrap; // need to work text-overflow
259
260
  // -o-text-overflow: ellipsis; // Opera Mini and Opera Mobile
260
261
  // text-overflow: ellipsis; // all
261
- @mixin ellipsis($overflow: hidden) {
262
+ @mixin ellipsis($overflow: hidden, $nowrap: true) {
262
263
  @if $overflow != false {
263
264
  overflow: $overflow;
264
265
  }
266
+ @if $nowrap {
267
+ white-space: nowrap;
268
+ }
265
269
  @include vendors(o, text-overflow, ellipsis);
266
270
  }
267
271
 
@@ -326,6 +330,11 @@ $boxsizing-url: asset-url("polyfills/boxsizing.htc", '') !default;
326
330
  }
327
331
  }
328
332
 
333
+ @mixin rotate($angle) {
334
+ @include transform(rotate($angle));
335
+ //filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); === -90deg
336
+ }
337
+
329
338
  // Style the html5 input placeholder in browsers that support it.
330
339
  // The styles for the input placeholder are passed as mixin content.
331
340
  // Mostly supported properties: color, font-*, letter-spacing.
@@ -28,7 +28,6 @@ $support-ie: true !default;
28
28
  // padding-left: 20px;
29
29
  // margin: 0 auto;
30
30
  // width: 360px;
31
- // TODO border as 2px solid black
32
31
  @mixin box($width,
33
32
  $height : false,
34
33
  $padding : false,
@@ -37,10 +36,14 @@ $support-ie: true !default;
37
36
  $include-padding : true,
38
37
  $include-margin : false,
39
38
  $include-border : true) {
40
- $properties: $padding $margin $border;
39
+ @if length($width) == 2 {
40
+ $height: nth($width, 2);
41
+ $width: nth($width, 1);
42
+ }
43
+ $properties: $padding $margin nth($border, 1);
41
44
  $include-properties: $include-padding $include-margin $include-border;
42
45
  $i: 0;
43
- @each $property-name in padding, margin, border {
46
+ @each $property-name in padding, margin, border-width {
44
47
  $i: $i + 1;
45
48
  $property: nth($properties, $i);
46
49
  @if $property {
@@ -54,7 +57,15 @@ $support-ie: true !default;
54
57
  $height: $height - nth($complex, 1) - nth($complex, 3);
55
58
  }
56
59
  }
57
- @include complex-property($property-name, $property, $complex);
60
+ @if $property-name == border-width and length($property) == 1 {
61
+ border: $border;
62
+ } @else {
63
+ @include complex-property($property-name, $property, $complex);
64
+ @if $property-name == border-width {
65
+ border-style: nth($border, 2);
66
+ border-color: nth($border, 3);
67
+ }
68
+ }
58
69
  }
59
70
  }
60
71
  @if isset($width) {
@@ -71,12 +82,11 @@ $support-ie: true !default;
71
82
  $bottom : nth($top, 3);
72
83
  $right : nth($top, 2);
73
84
  $top : nth($top, 1);
74
- @if isset($right) { $position: $right; }
75
85
  }
76
86
  @if isset($position) { position: $position; }
77
87
  @if isset($top) { top: $top; }
78
88
  @if isset($right) { right: $right; }
79
- @if isset($bottom) { botttom: $bottom; }
89
+ @if isset($bottom) { bottom: $bottom; }
80
90
  @if isset($left) { left: $left; }
81
91
  }
82
92
 
@@ -1,5 +1,5 @@
1
1
  module Ultimate
2
2
  module Base
3
- VERSION = "0.3.3.0"
3
+ VERSION = "0.3.4.0"
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@
3
3
  %head
4
4
  %meta{charset: "UTF-8"}
5
5
  %title Ultimate Base — #{@page_title ? @page_title.gsub("\n", "") : "Testing App"}
6
- = favicon_link_tag "/favicon.png", type: "image/png"
6
+ =# favicon_link_tag "/favicon.png", type: "image/png"
7
7
  - if Rails.env.development?
8
8
  :javascript
9
9
  var DEBUG_MODE = true;
@@ -0,0 +1,6 @@
1
+ - @page_title = "Styles test"
2
+ - content_for :head do
3
+ = stylesheet_link_tag "styles-test"
4
+
5
+ .box
6
+ This is amazing box!
@@ -0,0 +1,6 @@
1
+ @import "ultimate/mixins/microstructures";
2
+ @import "ultimate/mixins/css3";
3
+
4
+ .box {
5
+ @include box(400px, none, 10px 20px none, 0 auto, (2px 4px none) solid blue);
6
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultimate-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3.0
4
+ version: 0.3.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-17 00:00:00.000000000 Z
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &21675360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 3.2.8
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *21675360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.8
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: sqlite3
27
- requirement: &21672200 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *21672200
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: coffee-rails
38
- requirement: &21669100 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: 3.2.1
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *21669100
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.1
47
62
  description: Ultimate UI core, base helpers and improves for Ruby on Rails Front-end
48
63
  email:
49
64
  - koderfunk@gmail.com
@@ -142,6 +157,7 @@ files:
142
157
  - test/dummy/app/views/layouts/application.html.haml
143
158
  - test/dummy/app/views/main/index.html.haml
144
159
  - test/dummy/app/views/main/qunit.html.haml
160
+ - test/dummy/app/views/main/styles.html.haml
145
161
  - test/dummy/config.ru
146
162
  - test/dummy/config/application.rb
147
163
  - test/dummy/config/boot.rb
@@ -181,6 +197,7 @@ files:
181
197
  - test/javascripts/tests/jquery-plugin-adapter_test.js.coffee
182
198
  - test/javascripts/tests/jquery-plugin-class_test.js.coffee
183
199
  - test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee
200
+ - test/stylesheets/styles_test.css.scss
184
201
  - test/stylesheets/test_helper.css
185
202
  - ultimate-base.gemspec
186
203
  homepage: http://github.com/KODerFunk/ultimate-base
@@ -203,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
220
  version: '0'
204
221
  requirements: []
205
222
  rubyforge_project: ultimate-base
206
- rubygems_version: 1.8.10
223
+ rubygems_version: 1.8.24
207
224
  signing_key:
208
225
  specification_version: 3
209
226
  summary: Ultimate UI core, base helpers and improves for Ruby on Rails Front-end