lol_framework 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/.gitignore +19 -0
  2. data/.rspec +4 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +30 -0
  6. data/Rakefile +1 -0
  7. data/lib/generators/lol_framework/setup/lol_framework.rb +27 -0
  8. data/lib/generators/lol_framework/setup/setup_generator.rb +17 -0
  9. data/lib/lol_framework.rb +8 -0
  10. data/lib/lol_framework/common.rb +20 -0
  11. data/lib/lol_framework/config.rb +17 -0
  12. data/lib/lol_framework/config/components.rb +16 -0
  13. data/lib/lol_framework/config/components/css.rb +44 -0
  14. data/lib/lol_framework/config/components/js.rb +75 -0
  15. data/lib/lol_framework/railtie.rb +14 -0
  16. data/lib/lol_framework/version.rb +3 -0
  17. data/lol_framework.gemspec +28 -0
  18. data/spec/lol_framework/config/components/css_spec.rb +5 -0
  19. data/spec/lol_framework/config/components/js_spec.rb +11 -0
  20. data/spec/lol_framework/config/components_spec.rb +24 -0
  21. data/spec/lol_framework/config_spec.rb +19 -0
  22. data/spec/lol_framework/lol_framework_spec.rb +13 -0
  23. data/spec/spec_helper.rb +20 -0
  24. data/vendor/assets/images/lol_framework/datatable/sorting_bg.png +0 -0
  25. data/vendor/assets/images/lol_framework/glyphicons-lol-origin-white.png +0 -0
  26. data/vendor/assets/images/lol_framework/glyphicons-lol-origin.png +0 -0
  27. data/vendor/assets/images/lol_framework/glyphicons-lol.png +0 -0
  28. data/vendor/assets/javascripts/.gitkeep +0 -0
  29. data/vendor/assets/javascripts/Jasmine/jasmine-html.js +616 -0
  30. data/vendor/assets/javascripts/Jasmine/jasmine.js +2529 -0
  31. data/vendor/assets/javascripts/lol.js +18 -0
  32. data/vendor/assets/javascripts/lol_framework/Ajax.coffee +183 -0
  33. data/vendor/assets/javascripts/lol_framework/Alert.coffee +113 -0
  34. data/vendor/assets/javascripts/lol_framework/Button.coffee +268 -0
  35. data/vendor/assets/javascripts/lol_framework/Core.coffee +85 -0
  36. data/vendor/assets/javascripts/lol_framework/Datatable.coffee +340 -0
  37. data/vendor/assets/javascripts/lol_framework/Date.coffee +0 -0
  38. data/vendor/assets/javascripts/lol_framework/Debug.coffee +45 -0
  39. data/vendor/assets/javascripts/lol_framework/I18n.coffee +81 -0
  40. data/vendor/assets/javascripts/lol_framework/Lang/en-us.coffee +54 -0
  41. data/vendor/assets/javascripts/lol_framework/Lang/pt-br.coffee +57 -0
  42. data/vendor/assets/javascripts/lol_framework/Library/date-functions.js +409 -0
  43. data/vendor/assets/javascripts/lol_framework/Library/jquery.dataTables.min.js +157 -0
  44. data/vendor/assets/javascripts/lol_framework/Library/jquery.mobile.js +14 -0
  45. data/vendor/assets/javascripts/lol_framework/Loader.coffee +83 -0
  46. data/vendor/assets/javascripts/lol_framework/Lol.coffee +4 -0
  47. data/vendor/assets/javascripts/lol_framework/Modal.coffee +221 -0
  48. data/vendor/assets/javascripts/lol_framework/Model.coffee +71 -0
  49. data/vendor/assets/javascripts/lol_framework/Model/Rest.coffee +15 -0
  50. data/vendor/assets/javascripts/lol_framework/Tests/Alert.coffee +83 -0
  51. data/vendor/assets/javascripts/lol_framework/Tests/Core.coffee +35 -0
  52. data/vendor/assets/javascripts/lol_framework/Tests/Debug.coffee +14 -0
  53. data/vendor/assets/javascripts/lol_framework/Tests/I18n.coffee +7 -0
  54. data/vendor/assets/javascripts/lol_framework/Tests/Lang.coffee +130 -0
  55. data/vendor/assets/javascripts/lol_framework/Tests/Library.coffee +13 -0
  56. data/vendor/assets/javascripts/lol_framework/Tests/Lol.coffee +4 -0
  57. data/vendor/assets/javascripts/lol_framework/Tests/Utils.coffee +22 -0
  58. data/vendor/assets/javascripts/lol_framework/Utils.coffee +42 -0
  59. data/vendor/assets/javascripts/lol_main_tests.js +43 -0
  60. data/vendor/assets/stylesheets/.gitkeep +0 -0
  61. data/vendor/assets/stylesheets/jasmine.css +81 -0
  62. data/vendor/assets/stylesheets/lol_framework/_mixin.scss +650 -0
  63. data/vendor/assets/stylesheets/lol_framework/_variable.scss +107 -0
  64. data/vendor/assets/stylesheets/lol_framework/components/_alert.scss +46 -0
  65. data/vendor/assets/stylesheets/lol_framework/components/_datatable.scss +172 -0
  66. data/vendor/assets/stylesheets/lol_framework/components/_loader.scss +15 -0
  67. data/vendor/assets/stylesheets/lol_framework/components/_modal.scss +68 -0
  68. metadata +222 -0
@@ -0,0 +1,85 @@
1
+ ###
2
+ @summary Lol Framework
3
+ @description Framework of RIAs applications
4
+ @version 1.0.0
5
+ @file Core.js
6
+ @author Welington Sampaio (http://welington.zaez.net/)
7
+ @contact http://welington.zaez.net/site/contato
8
+
9
+ @copyright Copyright 2012 Welington Sampaio, all rights reserved.
10
+
11
+ This source file is free software, under the license MIT, available at:
12
+ http://lolframework.zaez.net/license
13
+
14
+ This source file is distributed in the hope that it will be useful, but
15
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
+ or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
17
+
18
+ For details please refer to: http://welington.zaez.net
19
+ ###
20
+
21
+ ###
22
+ Create a new instance of Core.
23
+
24
+ @classDescription This class creates a new Core.
25
+ @return {Core}   Returns a new Core.
26
+ @type {Object}
27
+ ###
28
+ class Lol.Core
29
+ ###
30
+ ID of identification of object
31
+ @type String hash @see Lol.Utils.uniqid
32
+ ###
33
+ id : null
34
+ ###
35
+ Atual Index of prints Debuging
36
+ ###
37
+ debugIndex : 1
38
+ ###
39
+ Prefix debug message
40
+ ###
41
+ debugPrefix : null
42
+ ###
43
+ All settings
44
+ ###
45
+ settings:
46
+ debug: false
47
+ ###
48
+ Checks if there is bibliotaco jQuery,
49
+ returns false if there
50
+ @exception If there jQuery
51
+ @return Boolean
52
+ ###
53
+ verifyJQuery: ->
54
+ if jQuery == undefined
55
+ throw 'Required jQuery library'
56
+ false
57
+ else
58
+ true
59
+ ###
60
+ Responsible for generating a unique
61
+ id for the object in question
62
+ @return String Id generated
63
+ ###
64
+ generateId: ->
65
+ @id = Lol.Utils.uniqid()
66
+ Lol.Utils.addObject @
67
+ ###
68
+ Destroy the object and cleaning of Utils
69
+ @see Lol.Utils.removeObject()
70
+ ###
71
+ destroy: ->
72
+ Lol.Utils.removeObject @id
73
+ ###
74
+ Print messages of debug
75
+ @param (Mixin) ... All params are printed
76
+ @return (Integer) Next index of message
77
+ ###
78
+ debug: ->
79
+ Lol.Debug.print
80
+ debug : @settings.debug
81
+ prefix : @debugPrefix
82
+ object_id: @id
83
+ index : @debugIndex
84
+ messages : arguments
85
+ @debugIndex += 1
@@ -0,0 +1,340 @@
1
+ ###
2
+ @summary Lol Framework
3
+ @description Framework of RIAs applications
4
+ @version 1.0.0
5
+ @file Datatable.js
6
+ @author Welington Sampaio (http://welington.zaez.net/)
7
+ @contact http://welington.zaez.net/site/contato
8
+
9
+ @copyright Copyright 2012 Welington Sampaio, all rights reserved.
10
+
11
+ This source file is free software, under the license MIT, available at:
12
+ http://lolframework.zaez.net/license
13
+
14
+ This source file is distributed in the hope that it will be useful, but
15
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
+ or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
17
+
18
+ For details please refer to: http://welington.zaez.net
19
+ ###
20
+
21
+ ###
22
+ Create a new instance of Datatable.
23
+
24
+ @classDescription This class creates a new Datatable.
25
+ @param {Object} Receives configuration to create the Datatable, @see Lol.datatable.defaults
26
+ @return {Datatable}   Returns a new Datatable.
27
+ @type {Object}
28
+ @example
29
+ *-* Auto configuration *-*
30
+ <table id="lol-datatable" data-lol-datatable="true">
31
+ <thead>
32
+ <tr>
33
+ <th>ID</th>
34
+ <th>First Name</th>
35
+ <th>Last Name</th>
36
+ </tr>
37
+ </thead>
38
+ <tbody>
39
+ <tr
40
+ data-datatable-link="http://welington.zaez.net/"
41
+ data-datatable-edit-link="#edit_my_page_ws"
42
+ data-datatable-view-link="#view_my_page_ws"
43
+ data-datatable-delete-link="#delete_my_page_ws">
44
+ <td>1</td>
45
+ <td>Welington</td>
46
+ <td>Sampaio</td>
47
+ </tr>
48
+ <tr
49
+ data-datatable-link="http://fabricio.zaez.net/"
50
+ data-datatable-edit-link="#edit_my_page_fm"
51
+ data-datatable-view-link="#view_my_page_fm"
52
+ data-datatable-delete-link="#delete_my_page_fm">
53
+ <td>2</td>
54
+ <td>Fabricio</td>
55
+ <td>Monte</td>
56
+ </tr>
57
+ </tbody>
58
+ </table>
59
+ *-* Setting manually configuration *-*
60
+ var datatable = new Lol.Datatable({
61
+ debug : true,
62
+ selectable : true,
63
+ target : '#lol-datatable',
64
+ delayDblclick : 3000,
65
+ classes: {
66
+ activeRow : 'active_row'
67
+ },
68
+ contextMenu: {
69
+ delete: function(row, object) {
70
+ // See default configuration
71
+ },
72
+ edit: function(row, object) {
73
+ object.debug row.data(object.dataset.editLink)
74
+ window.location = row.data(object.dataset.editLink)
75
+ return false },
76
+ view: function(row, object) {
77
+ window.location = row.data(object.dataset.showLink)
78
+ return false },
79
+ iconView : 'icon-eye-open icon-white',
80
+ useIcons : true,
81
+ },
82
+ configuration: {
83
+ aaSortingFixed : null,
84
+ aoColumnDefs : null,
85
+ aoColumns : null,
86
+ asStripeClasses: null,
87
+ bAutoWidth : true,
88
+ bDeferRender : false,
89
+ bDestroy : false,
90
+ bFilter : true,
91
+ bInfo : true,
92
+ bJQueryUI : false,
93
+ bLengthChange : false,
94
+ bPaginate : true,
95
+ bProcessing : false,
96
+ bRetrieve : false,
97
+ bScrollAutoCss : true,
98
+ bScrollCollapse: false,
99
+ bScrollInfinite: false,
100
+ bServerSide : false,
101
+ bSort : true,
102
+ bSortCellsTop : false,
103
+ bSortClasses : true,
104
+ bStateSave : false,
105
+ iCookieDuration: 7200,
106
+ iDeferLoading : null,
107
+ iDisplayLength : 20,
108
+ iDisplayStart : 0,
109
+ iScrollLoadGap : 100,
110
+ iTabIndex : 0,
111
+ sAjaxDataProp : "aaData",
112
+ sAjaxSource : null,
113
+ sCookiePrefix : "SpryMedia_DataTables_",
114
+ sDom : "lfrtip",
115
+ sPaginationType: "two_button",
116
+ sScrollX : "",
117
+ sScrollXInner : "",
118
+ sScrollY : "",
119
+ sServerMethod : "GET" }
120
+ });
121
+ ###
122
+ class Lol.Datatable extends Lol.Core
123
+ # declaration of variables
124
+ debugPrefix : 'Lol_Datatable'
125
+ namespace : '.datatable'
126
+ table : null
127
+ # the methods
128
+ constructor: (args={})->
129
+ throw 'Required jQuery library' if jQuery == undefined
130
+ @settings = jQuery.extend true, {}, Lol.datatable.defaults, args
131
+ @id = Lol.Utils.uniqid()
132
+ Lol.Utils.addObject @
133
+ @dataset = Lol.datatable.private.dataset
134
+ @setTable()
135
+ @setConfigTable()
136
+ @setTranslation()
137
+ @setAjax()
138
+ @generate()
139
+ @setEvents()
140
+ @
141
+ createMenuContext: (row, event)->
142
+ if row.data(@dataset.deleteLink) or row.data(@dataset.editLink) or row.data(@dataset.viewLink)
143
+ _this = @
144
+ context = jQuery "<div id='context-menu-#{@id}' class='context-menu'></div>"
145
+ context.css
146
+ left : event.pageX - 10
147
+ top : event.pageY - 10
148
+ context.bind
149
+ mouseleave: (event)->
150
+ jQuery(@).stop().animate {opacity: 0}, 'slow', ->
151
+ jQuery(@).remove()
152
+ mouseenter: (event)->
153
+ jQuery(@).stop().animate {opacity: 1}
154
+ ul = jQuery "<ul></ul>"
155
+ if ( row.data(@dataset.viewLink) )
156
+ view = jQuery "<li><a href='#{row.data(@dataset.viewLink)}'>#{Lol.t('datatable_view')}</a></li>"
157
+ jQuery("<i class='#{@settings.contextMenu.iconView}'></i>").prependTo view.find('a') if @settings.contextMenu.useIcons
158
+ view.bind
159
+ click: ->
160
+ _this.settings.contextMenu.view row, _this
161
+ view.appendTo ul
162
+ if ( row.data(@dataset.editLink) )
163
+ edit = jQuery "<li><a href='#{row.data(@dataset.editLink)}'>#{Lol.t('datatable_edit')}</a></li>"
164
+ jQuery("<i class='#{@settings.contextMenu.iconEdit}'></i>").prependTo edit.find('a') if @settings.contextMenu.useIcons
165
+ edit.bind
166
+ click: ->
167
+ _this.debug 'aki'
168
+ _this.settings.contextMenu.edit row, _this
169
+ edit.appendTo ul
170
+ if ( row.data(@dataset.deleteLink) )
171
+ remove = jQuery "<li><a href='#{row.data(@dataset.deleteLink)}'>#{Lol.t('datatable_delete')}</a></li>"
172
+ jQuery("<i class='#{@settings.contextMenu.iconDelete}'></i>").prependTo remove.find('a') if @settings.contextMenu.useIcons
173
+ remove.bind
174
+ click: ->
175
+ _this.settings.contextMenu.delete row, _this
176
+ remove.appendTo ul
177
+ ul.appendTo context
178
+ context.appendTo 'body'
179
+ generate: ->
180
+ @table.dataTable @settings.configuration
181
+ jQuery('.dataTables_filter input').attr('placeholder', Lol.t('datatable_search'))
182
+ getDt: ->
183
+ @table.dataTable()
184
+ goLink: (row)->
185
+ link = jQuery(row).data(@dataset.link)
186
+ Lol.Utils.redirector link if link
187
+ isRowActive: (row)->
188
+ row.hasClass @settings.classes.activeRow
189
+ setActiveRow: (row)->
190
+ @unsetActiveRow()
191
+ row.addClass @settings.classes.activeRow
192
+ row.data( @dataset.timeClicked, new Date().getTime() + @settings.delayDblclick )
193
+ setAjax: ->
194
+ if @table.data( @dataset.ajaxResource )
195
+ @settings.configuration.sAjaxSource = @table.data( @dataset.ajaxResource )
196
+ @settings.configuration.bProcessing = true
197
+ @settings.configuration.sServerMethod = @table.data( @dataset.ajaxMethod ) if @table.data( @dataset.ajaxMethod )
198
+ @settings.configuration.sAjaxDataProp = @table.data( @dataset.ajaxRoot ) if @table.data( @dataset.ajaxRoot )
199
+ setConfigTable: ->
200
+ @table.addClass 'lol-datatable'
201
+ setEvents: ->
202
+ _this = @
203
+ rows = jQuery("tbody tr", @table)
204
+ rows.live "click#{@namespace}", (e)->
205
+ row = jQuery @
206
+ if _this.isRowActive(row)
207
+ if row.data(_this.dataset.timeClicked) > new Date().getTime()
208
+ _this.goLink row
209
+ else
210
+ _this.unsetActiveRow(row)
211
+ else
212
+ _this.setActiveRow(row)
213
+ rows.live "contextmenu#{@namespace}", (event)->
214
+ row = jQuery @
215
+ _this.setActiveRow(row)
216
+ _this.createMenuContext(row, event)
217
+ false
218
+ setTable: ->
219
+ @table = @settings.target
220
+ setTranslation: ->
221
+ jQuery.extend(
222
+ true,
223
+ @settings.configuration,
224
+ {
225
+ oLanguage:
226
+ oAria:
227
+ sSortAscending : Lol.t 'datatable_oAria_sSortAscending'
228
+ sSortDescending: Lol.t 'datatable_oAria_sSortDescending'
229
+ oPaginate:
230
+ sFirst : Lol.t 'datatable_oPaginate_sFirst'
231
+ sLast : Lol.t 'datatable_oPaginate_sLast'
232
+ sNext : Lol.t 'datatable_oPaginate_sNext'
233
+ sPrevious: Lol.t 'datatable_oPaginate_sPrevious'
234
+ sEmptyTable : Lol.t 'datatable_sEmptyTable'
235
+ sInfo : Lol.t 'datatable_sInfo'
236
+ sInfoEmpty : Lol.t 'datatable_sInfoEmpty'
237
+ sInfoFiltered : Lol.t 'datatable_sInfoFiltered'
238
+ sInfoPostFix : Lol.t 'datatable_sInfoPostFix'
239
+ sInfoThousands : Lol.t 'datatable_sInfoThousands'
240
+ sLengthMenu : Lol.t 'datatable_sLengthMenu'
241
+ sLoadingRecords: Lol.t 'datatable_sLoadingRecords'
242
+ sProcessing : Lol.t 'datatable_sProcessing'
243
+ sSearch : Lol.t 'datatable_sSearch'
244
+ sUrl : Lol.t 'datatable_sUrl'
245
+ sZeroRecords : Lol.t 'datatable_sZeroRecords'
246
+ }
247
+ )
248
+ unsetActiveRow: ()->
249
+ jQuery("tr.#{@settings.classes.activeRow}", @table).removeClass @settings.classes.activeRow
250
+
251
+
252
+ Lol.datatable =
253
+ ## private configs
254
+ private:
255
+ dataset:
256
+ ajaxResource: 'datatableAjax'
257
+ ajaxRoot : 'datatableAjaxRoot'
258
+ ajaxMethod : "datatableAjaxMethod"
259
+ autoGenerate: 'lolDatatable'
260
+ link : 'datatableLink'
261
+ deleteLink : 'datatableDeleteLink'
262
+ editLink : 'datatableEditLink'
263
+ viewLink : 'datatableViewLink'
264
+ timeClicked : 'datatableClicked'
265
+ defaults:
266
+ debug : true
267
+ selectable : true
268
+ target : null
269
+ delayDblclick : 3000
270
+ classes:
271
+ activeRow : 'active_row'
272
+ contextMenu:
273
+ delete: (row, object)->
274
+ new Lol.Modal
275
+ buttons : 'OK_CANCEL'
276
+ content : Lol.t('datatable_confirm_delete')
277
+ title : Lol.t('datatable_confirm_delete_title')
278
+ callbacks:
279
+ buttonClick: (button, obj)->
280
+ obj.destroy()
281
+ buttonParams:
282
+ fn:
283
+ OK_CLICK: (event, obj)->
284
+ rest = Lol.model
285
+ object: row
286
+ console.log rest
287
+ false
288
+ edit: (row, object)->
289
+ object.debug row.data(object.dataset.editLink)
290
+ window.location = row.data(object.dataset.editLink)
291
+ false
292
+ view: (row, object)->
293
+ window.location = row.data(object.dataset.viewLink)
294
+ false
295
+ iconView : 'icon-eye-open icon-white'
296
+ useIcons : true
297
+ model : null # typeof Lol.Model
298
+ configuration:
299
+ aaSortingFixed : null
300
+ aoColumnDefs : null
301
+ aoColumns : null
302
+ asStripeClasses: null
303
+ bAutoWidth : true
304
+ bDeferRender : false
305
+ bDestroy : false
306
+ bFilter : true
307
+ bInfo : true
308
+ bJQueryUI : false
309
+ bLengthChange : false
310
+ bPaginate : true
311
+ bProcessing : false
312
+ bRetrieve : false
313
+ bScrollAutoCss : true
314
+ bScrollCollapse: false
315
+ bScrollInfinite: false
316
+ bServerSide : false
317
+ bSort : true
318
+ bSortCellsTop : false
319
+ bSortClasses : true
320
+ bStateSave : false
321
+ iCookieDuration: 7200
322
+ iDeferLoading : null
323
+ iDisplayLength : 20
324
+ iDisplayStart : 0
325
+ iScrollLoadGap : 100
326
+ iTabIndex : 0
327
+ sAjaxDataProp : "aaData"
328
+ sAjaxSource : null
329
+ sCookiePrefix : "SpryMedia_DataTables_"
330
+ sDom : "lfrtip"
331
+ sPaginationType: "two_button"
332
+ sScrollX : ""
333
+ sScrollXInner : ""
334
+ sScrollY : ""
335
+ sServerMethod : "GET"
336
+
337
+ jQuery ->
338
+ jQuery('[data-lol-datatable]').each ->
339
+ new Lol.Datatable
340
+ target: jQuery(@)
@@ -0,0 +1,45 @@
1
+ ###
2
+ @summary Lol Framework
3
+ @description Framework of RIAs applications
4
+ @version 1.0.0
5
+ @file Debug.js
6
+ @author Welington Sampaio (http://welington.zaez.net/)
7
+ @contact http://welington.zaez.net/site/contato
8
+
9
+ @copyright Copyright 2012 Welington Sampaio, all rights reserved.
10
+
11
+ This source file is free software, under the license MIT, available at:
12
+ http://lolframework.zaez.net/license
13
+
14
+ This source file is distributed in the hope that it will be useful, but
15
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
+ or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
17
+
18
+ For details please refer to: http://welington.zaez.net
19
+ ###
20
+
21
+ ###
22
+ Responsible for handling debug messages
23
+ @type {Object}
24
+ ###
25
+ Lol.Debug =
26
+ ###
27
+ Configuration default debug
28
+ @type {Object}
29
+ ###
30
+ paramsDefault:
31
+ debug : false
32
+ prefix : 'Lol_Debug'
33
+ object_id: ''
34
+ index : 1
35
+ messages : []
36
+ ###
37
+ Paramenters traverses the past and
38
+ prints everything in the browser console
39
+ ###
40
+ print: ( params )->
41
+ params = $.extend true, {}, @paramsDefault, params
42
+ if (params.debug or Lol.debug) and window.console
43
+ message = ["#{params.prefix} #{params.object_id} - #{params.index}"]
44
+ message.push params.messages[value] for value of params.messages
45
+ console.log message