iugu-ux 0.8.8 → 0.8.9

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.
Files changed (28) hide show
  1. data/lib/iugu-ux/version.rb +1 -1
  2. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-alert.jst.eco +7 -3
  3. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-popup-container.jst.eco +6 -0
  4. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-search-filter.jst.eco +9 -6
  5. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-alert.js.coffee +2 -2
  6. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-base.js.coffee +12 -7
  7. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-dataset.js.coffee +5 -2
  8. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-popup-container.js.coffee +42 -0
  9. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-responsive-box.js.coffee +5 -3
  10. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-scrollable-content.js.coffee +2 -2
  11. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee +6 -6
  12. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-view.js.coffee +47 -6
  13. data/vendor/assets/javascripts/iugu-ux/web-app.js +2 -0
  14. data/vendor/assets/javascripts/vendor.js +6 -0
  15. data/vendor/assets/javascripts/vendor/backbone.advanced-delegate.js +39 -0
  16. data/vendor/assets/javascripts/vendor/backbone.fetch-event.js +15 -0
  17. data/vendor/assets/javascripts/vendor/backbone.forms.default.js +91 -0
  18. data/vendor/assets/javascripts/vendor/backbone.forms.js +2355 -0
  19. data/vendor/assets/javascripts/vendor/backbone.forms.list.js +579 -0
  20. data/vendor/assets/javascripts/vendor/jquery.fileupload.js +1114 -0
  21. data/vendor/assets/javascripts/web-app/comm.coffee +1 -1
  22. data/vendor/assets/javascripts/web-app/environment.js.coffee +2 -0
  23. data/vendor/assets/javascripts/web-app/helpers.coffee +3 -1
  24. data/vendor/assets/javascripts/web-app/managed_request.coffee +54 -0
  25. data/vendor/assets/stylesheets/iugu-ux.css +1 -0
  26. data/vendor/assets/stylesheets/iugu-ux/backbone.forms.default.css +140 -0
  27. data/vendor/assets/stylesheets/iugu-ux/components.sass +6 -1
  28. metadata +40 -30
@@ -1,3 +1,3 @@
1
1
  module IuguUX
2
- VERSION = "0.8.8"
2
+ VERSION = "0.8.9"
3
3
  end
@@ -1,6 +1,10 @@
1
- <div class="notice notice-green">
1
+ <div class="notice <%= @alertClass %>">
2
2
  <a class="close" data-dismiss="notice" href="#">x</a>
3
3
  <h4 class="notice-heading"><%= @headerText %></h4>
4
- <p><%= @bodyText %></p><br/>
5
- <a class="button" data-dismiss="alert" href="#"><%= @buttonText %></a>
4
+ <% if @bodyText: %>
5
+ <p><%= @bodyText %></p><br/>
6
+ <% end %>
7
+ <% if @buttonText: %>
8
+ <a class="button" data-dismiss="alert" href="#"><%= @buttonText %></a>
9
+ <% end %>
6
10
  </div>
@@ -0,0 +1,6 @@
1
+ <div class="content popup-wrapper" style="position:absolute;top:0px;left:0px;right:0px;bottom:0px">
2
+ <div class="popup-modal" style="position:absolute;top:0px;left:0px;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:2"></div>
3
+ <div class="popup-window" style="z-index:5;position:absolute;width:<%= @width %>px;height:<%= @height %>px;margin-left:-<%= @width/2 %>px;margin-top:-<%= @height/2 %>px;top:50%;left:50%">
4
+ <div class="container" style="width:<%= @width %>px;height:<%= @height %>px"></div>
5
+ </div>
6
+ </div>
@@ -1,15 +1,18 @@
1
1
  <section style="background:#FFF;padding-top:5px;padding-bottom:5px">
2
- <% facets = _.pick(@collection.facets, @filterName) %>
2
+ <% if @collection.facets: %>
3
+ <% facets = _.pick(@collection.facets, @filterName) %>
4
+ <% end %>
5
+ <% facets = [] unless facets %>
3
6
  <% printed = [] %>
4
7
  <% for facet in _.pairs(facets): %>
5
8
  <% for term in facet[1].terms: %>
6
9
  <% printed.push(term.term.toString()) %>
7
- <a href="#" data-filter=<%= term.term %> class="button search-filter-button <%= "default" unless _.indexOf(@selected, term.term.toString()) == -1 %>"><%= term.term.toString() %>( <%= term.count %> )</a>
10
+ <a href="#" data-filter=<%= term.term %> data-action="search-filter-button" class="button <%= "default" unless _.indexOf(@selected, term.term.toString()) == -1 %>"><%= term.term.toString() %>( <%= term.count %> )</a>
8
11
  <% end %>
9
- <% for term in @fixedFilters: %>
10
- <% if _.indexOf(printed, term) == -1: %>
11
- <a href="#" data-filter=<%= term %> class="button search-filter-button <%= "default" unless _.indexOf(@selected, term) == -1 %>"><%= term %>( 0 )</a>
12
- <% end %>
12
+ <% end %>
13
+ <% for term in @fixedFilters: %>
14
+ <% if _.indexOf(printed, term) == -1: %>
15
+ <a href="#" data-filter=<%= term %> class="disabled button <%= "default" unless _.indexOf(@selected, term) == -1 %>"><%= term %>( 0 )</a>
13
16
  <% end %>
14
17
  <% end %>
15
18
  </section>
@@ -3,8 +3,7 @@ class IuguUI.Alert extends IuguUI.Base
3
3
 
4
4
  defaults:
5
5
  headerText: "HEADER TEXT"
6
- bodyText: "BODY TEXT"
7
- buttonText: "BUTTON TEXT"
6
+ alertClass: "notice-green"
8
7
 
9
8
  events:
10
9
  'click a.alertButton': 'handleDOMEvent'
@@ -13,5 +12,6 @@ class IuguUI.Alert extends IuguUI.Base
13
12
  headerText: @options.headerText
14
13
  bodyText: @options.bodyText
15
14
  buttonText: @options.buttonText
15
+ alertClass: @options.alertClass
16
16
 
17
17
  @IuguUI.Alert = IuguUI.Alert
@@ -4,13 +4,14 @@ class IuguUI.Base extends Backbone.View
4
4
  baseURL: ""
5
5
 
6
6
  initialize: ->
7
- _.bindAll @, 'render', 'root', 'identifier', 'delegateChild', 'mapDOMEvent', 'handleEvent', 'handleDOMEvent', 'unload', 'close'
7
+ _.bindAll @
8
8
 
9
9
  @options = _.extend {}, @defaults, @options
10
10
 
11
11
  @layout = @options.layout if @options.layout
12
12
  @parent = @options.parent if @options.parent
13
-
13
+ @context = @options.context if @options.context
14
+
14
15
  @identifier = ( -> @options.identifier + ':' ) if @options.identifier
15
16
 
16
17
  @handleEvent 'initialize'
@@ -25,10 +26,13 @@ class IuguUI.Base extends Backbone.View
25
26
 
26
27
  @
27
28
 
28
- getLayout: ->
29
- if JST[ "web-app/presenters/" + @layout ]
30
- return JST[ "web-app/presenters/" + @layout ]
31
- JST[ "iugu-ux/components/presenters/" + @layout ]
29
+ renderPartial: ( layout, target, context=@context ) ->
30
+ $(target).html @getLayout(target) context
31
+
32
+ getLayout: (layout_file=@layout) ->
33
+ if JST[ "web-app/presenters/" + layout_file ]
34
+ return JST[ "web-app/presenters/" + layout_file ]
35
+ JST[ "iugu-ux/components/presenters/" + layout_file ]
32
36
 
33
37
  context: ->
34
38
  return { }
@@ -69,7 +73,7 @@ class IuguUI.Base extends Backbone.View
69
73
  @handleEvent triggerType
70
74
 
71
75
  trigger: (events) ->
72
- if app.debug_events
76
+ if enable_debug_events
73
77
  debug 'Triggered Event: ' + arguments[0]
74
78
  super
75
79
 
@@ -85,4 +89,5 @@ class IuguUI.Base extends Backbone.View
85
89
  @unload()
86
90
  @remove()
87
91
 
92
+
88
93
  @IuguUI.Base = IuguUI.Base
@@ -1,5 +1,6 @@
1
- class IuguUI.Dataset extends IuguUI.Base
1
+ class IuguUI.Dataset extends IuguUI.View
2
2
  layout: "iugu-ui-dataset"
3
+ secondaryView: true
3
4
 
4
5
  defaults:
5
6
  itemLayout: "iugu-ui-dataset-record"
@@ -9,7 +10,9 @@ class IuguUI.Dataset extends IuguUI.Base
9
10
  initialize: ->
10
11
  super
11
12
  _.bindAll @, 'renderItems', 'addRecord'
12
- @collection.on('all', @render)
13
+
14
+ @collection.on 'fetch', @enableLoader, @
15
+ @collection.on 'reset', @load, @
13
16
 
14
17
  @
15
18
 
@@ -0,0 +1,42 @@
1
+ class IuguUI.PopupContainer extends IuguUI.View
2
+ layout: "iugu-ui-popup-container"
3
+ secondaryView: true
4
+
5
+ defaults:
6
+ content: null
7
+ width: 320
8
+ height: 480
9
+
10
+ context: ->
11
+ width: @options.width
12
+ height: @options.height
13
+
14
+ initialize: ->
15
+ _.bindAll @
16
+ super
17
+
18
+ @content = new IuguUI.View
19
+ layout: @content
20
+ secondaryView: true
21
+
22
+ @content_wrapper = null
23
+
24
+ getHandler: ->
25
+ @$('.content:first')
26
+
27
+ getContainer: ->
28
+ @$('.container:first')
29
+
30
+ render: ->
31
+ super
32
+ unless @content_wrapper
33
+ @content_wrapper = $(document.createElement('div'))
34
+
35
+ @content.setElement(@content_wrapper).render()
36
+
37
+ @getContainer().html @content_wrapper
38
+
39
+
40
+ @
41
+
42
+ @IuguUI.PopupContainer = IuguUI.PopupContainer
@@ -29,8 +29,7 @@ class IuguUI.ResponsiveBox extends IuguUI.Base
29
29
  getTitle: ->
30
30
  @$('.responsive-title').html()
31
31
 
32
- toggleSidebar: ( evt ) ->
33
- evt.preventDefault()
32
+ reallyToggleSidebar: ->
34
33
  uibox = @$('.ui-responsive-box')
35
34
 
36
35
  uisidebar = uibox.children('.sidebar')
@@ -52,7 +51,10 @@ class IuguUI.ResponsiveBox extends IuguUI.Base
52
51
  preventContainer.remove()
53
52
  , 500
54
53
  )
55
-
54
+
55
+ toggleSidebar: ( evt ) ->
56
+ evt.preventDefault()
57
+ @reallyToggleSidebar()
56
58
 
57
59
  render: ->
58
60
  super
@@ -2,10 +2,10 @@ class IuguUI.ScrollableContainer extends IuguUI.Base
2
2
  layout: "iugu-ui-scrollable-container"
3
3
 
4
4
  getHandler: ->
5
- @$('.content')
5
+ @$('.content:first')
6
6
 
7
7
  getContainer: ->
8
- @$('.handle-scrolling')
8
+ @$('.handle-scrolling:first')
9
9
 
10
10
  render: ->
11
11
  super
@@ -8,10 +8,11 @@ class IuguUI.SearchFilter extends IuguUI.Base
8
8
  multiSelection: false
9
9
 
10
10
  events:
11
- 'click .search-filter-button': 'searchCollection'
11
+ 'click [data-action=search-filter-button]': 'searchCollection'
12
12
 
13
13
  searchCollection: (e) ->
14
14
  e.preventDefault()
15
+ @handleEvent "facet:click"
15
16
  button = $(e.target)
16
17
  filter = button.data('filter')
17
18
 
@@ -27,13 +28,13 @@ class IuguUI.SearchFilter extends IuguUI.Base
27
28
  @collection.configureFilter @options.filterName + '_filter', @selected
28
29
  else
29
30
  @collection.removeFilter @options.filterName + '_filter'
30
-
31
- @collection.fetch()
31
+
32
+ @collection.goTo(1)
32
33
 
33
34
  initialize: ->
34
35
  @selected = []
35
36
  _.bindAll @, 'searchCollection', 'render'
36
- @collection.on 'all', @render, @
37
+ @collection.on 'reset', @render, @
37
38
  @collection.on "removed-filter:#{@options.filterName}_filter", @removedFilter, @
38
39
  super
39
40
  @
@@ -45,8 +46,7 @@ class IuguUI.SearchFilter extends IuguUI.Base
45
46
  fixedFilters: @options.fixedFilters
46
47
 
47
48
  render: ->
48
- if @collection.facets
49
- super
49
+ super
50
50
 
51
51
  removedFilter: ->
52
52
  @selected = []
@@ -1,7 +1,15 @@
1
1
  class IuguUI.View extends IuguUI.Base
2
2
  layout: "iugu-ui-view"
3
+ secondaryView: false
3
4
 
4
5
  initialize: ->
6
+ super
7
+
8
+ window.Events.on "fillSlots", @fillSlots
9
+ window.Events.on "resetSlots", @resetSlots
10
+
11
+ @secondaryView = @options.secondaryView if @options.secondaryView
12
+
5
13
  if @model
6
14
  Backbone.Validation.bind @,
7
15
  forceUpdate: true
@@ -14,6 +22,38 @@ class IuguUI.View extends IuguUI.Base
14
22
 
15
23
  @model.on 'error', @addErrors, @
16
24
 
25
+ fillSlots: ( context ) ->
26
+ _.each( _.keys(context)
27
+ ( key ) ->
28
+ renderContext = context[key]
29
+ if renderContext.el
30
+ context[key].$el.detach()
31
+ @$(key).empty().append context[key].el
32
+ else
33
+ @$(key).empty().append context[key]
34
+ )
35
+
36
+ resetSlots: ( slots ) ->
37
+ _.each( slots,
38
+ ( slot ) ->
39
+ @$(slot).empty()
40
+ )
41
+
42
+ enableLoader: ->
43
+ debug "ENABLED LOADER"
44
+ @viewLoader = $('<div style="position:absolute;top:0px;left:0px;width:100%;height:100%;"><div style="position:absolute;left:0px;top:0px;width:100%;height:100%;background:rgba(255,255,255,0.5);z-index:2"></div><div style="position:absolute;top:50%;left:50%;width:64px;height:64px;margin-left:-32px;margin-top:-32px;background:#fff;-moz-border-radius(5px);line-height:64px;text-align:center;color:#fff"><img src="http://preloaders.net/preloaders/3/Chasing%20arrows.gif" width="32" height="32" /></div></div>')
45
+ $(@el).append @viewLoader
46
+
47
+ disableLoader: ->
48
+ debug "DISABLED LOADER"
49
+ if @viewLoader
50
+ @viewLoader.remove()
51
+
52
+ load: ->
53
+ debug "ON LOAD"
54
+ @disableLoader()
55
+ @render()
56
+
17
57
  valid: (view, attr, selector) ->
18
58
  control = view.$ '[' + selector + '=\"' + attr + '\"]'
19
59
  group = control.parents ".form-group"
@@ -61,25 +101,26 @@ class IuguUI.View extends IuguUI.Base
61
101
  )
62
102
 
63
103
  render: ->
64
- super
65
104
  rivets.bind this.$el, {model: @model} if @model
66
105
 
67
- if app.activeView != @
106
+ if app.activeView != @ and @secondaryView == false
68
107
  app.activeView.close() if app.activeView
69
108
  app.activeView = @
70
109
 
71
- if window.Root.setTitle
72
- window.Root.setTitle @viewTitle
110
+ if window.app.rootWindow.setTitle
111
+ window.app.rootWindow.setTitle @title
112
+
113
+ super
73
114
 
74
115
  @
75
116
 
76
117
  unload: () ->
77
- super
78
- debug 'Called IuguUI.View:close'
118
+ debug 'Called IuguUI.View:unload'
79
119
  if @model
80
120
  Backbone.Validation.unbind @
81
121
  @model.off null, null, @
82
122
  if @collection
83
123
  @collection.off null, null, @
124
+ super
84
125
 
85
126
  @IuguUI.View = IuguUI.View
@@ -22,6 +22,8 @@
22
22
 
23
23
  //= require ./iugu-ui-helpers.js
24
24
  //= require ./components/iugu-ux-components.js
25
+ //
26
+ //= require web-app/managed_request
25
27
 
26
28
  //= require web-app/models
27
29
  //= require web-app/presenters
@@ -11,6 +11,7 @@
11
11
  //= require ./vendor/jquery.ui
12
12
  //= require ./vendor/jquery.ui.touch-punch
13
13
  //= require ./vendor/jquery.base64
14
+ //= require ./vendor/jquery.fileupload.js
14
15
  //= require ./vendor/mobiscroll.core-2.3.1
15
16
  //= require ./vendor/mobiscroll.datetime-2.3
16
17
  //= require ./vendor/mobiscroll.select-2.3.1
@@ -18,6 +19,11 @@
18
19
  //= require ./vendor/backbone
19
20
  //= require ./vendor/backbone.validation.js
20
21
  //= require ./vendor/backbone.paginator.js
22
+ //= require ./vendor/backbone.fetch-event.js
23
+ //= require ./vendor/backbone.advanced-delegate.js
24
+ //= require ./vendor/backbone.forms.js
25
+ //= require ./vendor/backbone.forms.list.js
26
+ //= require ./vendor/backbone.forms.default.js
21
27
  //= require ./vendor/rivets.js
22
28
  //= require ./vendor/async.js
23
29
  //= require ./vendor/tasks.js
@@ -0,0 +1,39 @@
1
+ _.each(["View"], function(name) {
2
+ // Cache Backbone constructor.
3
+ var ctor = Backbone[name];
4
+ // Cache original fetch.
5
+ var delegateEvents = ctor.prototype.delegateEvents;
6
+
7
+ var delegateEventSplitter = /^(\S+)\s*(.*)$/;
8
+
9
+ // Override the fetch method to emit a fetch event.
10
+ ctor.prototype.delegateEvents = function(events) {
11
+ if (!(events || (events = _.result(this, 'events')))) return;
12
+ this.undelegateEvents();
13
+ for (var key in events) {
14
+ var method = events[key];
15
+ if (!_.isFunction(method)) method = this[events[key]];
16
+ if (!method) throw new Error('Method "' + events[key] + '" does not exist');
17
+ var match = key.match(delegateEventSplitter);
18
+ var eventName = match[1], selector = match[2];
19
+ method = _.bind(method, this);
20
+ originalEvent = eventName;
21
+ eventName = '.delegateEvents' + this.cid;
22
+ if ((originalEvent == "click") && (selector !== '')) {
23
+ if (window.TOUCH_SUPPORT) {
24
+ this.$el.on( "touchstart" + eventName, selector, function(event) { $(this).addClass('active'); } );
25
+ this.$el.on( "touchend" + eventName, selector, function(event) { $(this).removeClass('active'); } );
26
+ }
27
+ else {
28
+ this.$el.on( "mousedown" + eventName, selector, function(event) { $(this).addClass('active'); } );
29
+ this.$el.on( "mouseup" + eventName, selector, function(event) { $(this).removeClass('active'); } );
30
+ }
31
+ }
32
+ if (selector === '') {
33
+ this.$el.on(originalEvent + eventName, method);
34
+ } else {
35
+ this.$el.on(originalEvent + eventName, selector, method);
36
+ }
37
+ }
38
+ };
39
+ });
@@ -0,0 +1,15 @@
1
+ _.each(["Model", "Collection"], function(name) {
2
+ // Cache Backbone constructor.
3
+ var ctor = Backbone[name];
4
+ // Cache original fetch.
5
+ var fetch = ctor.prototype.fetch;
6
+
7
+ // Override the fetch method to emit a fetch event.
8
+ ctor.prototype.fetch = function() {
9
+ // Trigger the fetch event on the instance.
10
+ this.trigger("fetch", this);
11
+
12
+ // Pass through to original fetch.
13
+ return fetch.apply(this, arguments);
14
+ };
15
+ });
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Include this file _after_ the main backbone-forms file to override the default templates.
3
+ * You only need to include templates you want to override.
4
+ *
5
+ * Requirements when customising templates:
6
+ * - Each template must have one 'parent' element tag.
7
+ * - "data-type" attributes are required.
8
+ * - The main placeholder tags such as the following are required: fieldsets, fields
9
+ */
10
+ ;(function() {
11
+ var Form = Backbone.Form;
12
+
13
+
14
+ //DEFAULT TEMPLATES
15
+ Form.setTemplates({
16
+
17
+ //HTML
18
+ form: '\
19
+ <form class="bbf-form">{{fieldsets}}</form>\
20
+ ',
21
+
22
+ fieldset: '\
23
+ <fieldset>\
24
+ <legend>{{legend}}</legend>\
25
+ <ul>{{fields}}</ul>\
26
+ </fieldset>\
27
+ ',
28
+
29
+ field: '\
30
+ <li class="bbf-field field-{{key}}">\
31
+ <label for="{{id}}">{{title}}</label>\
32
+ <div class="bbf-editor">{{editor}}</div>\
33
+ <div class="bbf-help">{{help}}</div>\
34
+ <div class="bbf-error">{{error}}</div>\
35
+ </li>\
36
+ ',
37
+
38
+ nestedField: '\
39
+ <li class="bbf-field bbf-nested-field field-{{key}}" title="{{title}}">\
40
+ <label for="{{id}}">{{title}}</label>\
41
+ <div class="bbf-editor">{{editor}}</div>\
42
+ <div class="bbf-help">{{help}}</div>\
43
+ <div class="bbf-error">{{error}}</div>\
44
+ </li>\
45
+ ',
46
+
47
+ list: '\
48
+ <div class="bbf-list">\
49
+ <ul>{{items}}</ul>\
50
+ <div class="bbf-actions"><button type="button" data-action="add">Add</div>\
51
+ </div>\
52
+ ',
53
+
54
+ listItem: '\
55
+ <li>\
56
+ <button type="button" data-action="remove" class="bbf-remove">&times;</button>\
57
+ <div class="bbf-editor-container">{{editor}}</div>\
58
+ </li>\
59
+ ',
60
+
61
+ date: '\
62
+ <div class="bbf-date">\
63
+ <select data-type="date" class="bbf-date">{{dates}}</select>\
64
+ <select data-type="month" class="bbf-month">{{months}}</select>\
65
+ <select data-type="year" class="bbf-year">{{years}}</select>\
66
+ </div>\
67
+ ',
68
+
69
+ dateTime: '\
70
+ <div class="bbf-datetime">\
71
+ <div class="bbf-date-container">{{date}}</div>\
72
+ <select data-type="hour">{{hours}}</select>\
73
+ :\
74
+ <select data-type="min">{{mins}}</select>\
75
+ </div>\
76
+ ',
77
+
78
+ 'list.Modal': '\
79
+ <div class="bbf-list-modal">\
80
+ {{summary}}\
81
+ </div>\
82
+ '
83
+ }, {
84
+
85
+ //CLASSNAMES
86
+ error: 'bbf-error'
87
+
88
+ });
89
+
90
+
91
+ })();