Module: Hyperloop::Component::Mixin
- Included in:
- ReactiveRecord::WhileLoading
- Defined in:
- lib/reactive_record/active_record/reactive_record/while_loading.rb
Instance Method Summary collapse
- #component_did_mount(*args) ⇒ Object
- #component_did_update(*args) ⇒ Object
- #original_component_did_mount ⇒ Object
- #original_component_did_update ⇒ Object
- #reactive_record_link_set_while_loading_container_class ⇒ Object
- #reactive_record_link_to_enclosing_while_loading_container ⇒ Object
Instance Method Details
#component_did_mount(*args) ⇒ Object
245 246 247 248 249 |
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 245 def component_did_mount(*args) original_component_did_mount(*args) reactive_record_link_to_enclosing_while_loading_container reactive_record_link_set_while_loading_container_class end |
#component_did_update(*args) ⇒ Object
253 254 255 256 |
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 253 def component_did_update(*args) original_component_did_update(*args) reactive_record_link_set_while_loading_container_class end |
#original_component_did_mount ⇒ Object
243 244 245 246 247 |
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 243 def component_did_mount(*args) original_component_did_mount(*args) reactive_record_link_to_enclosing_while_loading_container reactive_record_link_set_while_loading_container_class end |
#original_component_did_update ⇒ Object
251 252 253 254 |
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 251 def component_did_update(*args) original_component_did_update(*args) reactive_record_link_set_while_loading_container_class end |
#reactive_record_link_set_while_loading_container_class ⇒ Object
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 274 def reactive_record_link_set_while_loading_container_class %x{ var node = #{dom_node}; var wl = #{!self.is_a?(ReactiveRecord::WhileLoading)} if (#{!self.is_a?(ReactiveRecord::WhileLoading)} && $(node).is('[data-reactive_record_while_loading_container_id]')) { return } var while_loading_container_id = $(node).attr('data-reactive_record_enclosing_while_loading_container_id'); if (while_loading_container_id) { var while_loading_container = $('[data-reactive_record_while_loading_container_id='+while_loading_container_id+']'); var loading = #{!!waiting_on_resources == true}; if (loading) { $(node).addClass('reactive_record_is_loading'); $(node).removeClass('reactive_record_is_loaded'); $(while_loading_container).addClass('reactive_record_is_loading'); $(while_loading_container).removeClass('reactive_record_is_loaded'); } else if (!$(node).hasClass('reactive_record_is_loaded')) { if (!$(node).attr('data-reactive_record_while_loading_container_id')) { $(node).removeClass('reactive_record_is_loading'); $(node).addClass('reactive_record_is_loaded'); } if (!$(while_loading_container).hasClass('reactive_record_is_loaded')) { var loading_children = $(while_loading_container). find('[data-reactive_record_enclosing_while_loading_container_id='+while_loading_container_id+'].reactive_record_is_loading') if (loading_children.length == 0) { $(while_loading_container).removeClass('reactive_record_is_loading') $(while_loading_container).addClass('reactive_record_is_loaded') } } } } } end |
#reactive_record_link_to_enclosing_while_loading_container ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 258 def reactive_record_link_to_enclosing_while_loading_container # Call after any component mounts - attaches the containers loading id to this component # Fyi, the while_loading container is responsible for setting its own link to itself %x{ var node = #{dom_node}; if (!$(node).is('[data-reactive_record_enclosing_while_loading_container_id]')) { var while_loading_container = $(node).closest('[data-reactive_record_while_loading_container_id]') if (while_loading_container.length > 0) { var container_id = $(while_loading_container).attr('data-reactive_record_while_loading_container_id') $(node).attr('data-reactive_record_enclosing_while_loading_container_id', container_id) } } } end |