Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/js atk4 namespace #201

Merged
merged 39 commits into from Jul 20, 2017
Merged

Conversation

ibelar
Copy link
Contributor

@ibelar ibelar commented Jul 18, 2017

This PullRequest is replacing previous PR194. PR194 should then be closed in order to use this one.
You would need to recompile javascript code using web pack for this PR to work correctly.

npm run build

Javascript

atk Namespace

Add namespace to all atk jQuery plugin and helper function. Plugin should now be called using atk prior to the plugin name like below.

$element->js()->atkReloadView();

Folder structure

Better structure the javascript file by making them more modular. The folder structure is as follow

  • plugins: contains the jquery plugin file
  • helpers: contains extended jquery function, like $.addParams, perhaps eventually univ()...
  • service: contains mainly singleton class responsible to manage semantic-ui module, like the api or - modal module throughout the entire app.

jQuery plugin enhancement

Better handling of jQuery plugin creation via plugin.js. Also now handle direct plugin function call using $('element').plugin('functionToCall', [param]) type syntax.

Service class

Two new service classes, ApiService and ModalService, for managing api or modal throughout the app.

  • ApiService: better handling of error message and api call done via other service, like modal;
  • ModalService: better handling of modal
    • allow support for multiple modal, properly handling close trigger event.
    • allow dynamic content via createModal or Modal.php.
    • allow for regular content via Modal.php

In future, service could be add for other semantic-ui module like form, tab etc, in future.

PHP

Modal.php

Add Modal class in order to allow modal use within a page. Modal extend regular View but can also use CallBack to add content to it.

As a regular view:

$modal = $layout->add(['Modal', 'title' =>'Simple modal']);
$modal->add('Message')->set('Modal message here.');

using callback:

$modal->set(function ($modal) {
    $modal->add(['LoremIpsum', 'size' => 2]);
});

see modal2.php demos.

ibelar added 30 commits July 4, 2017 09:23
- add possibility to simply use html in jsModal, not only Json;
- redesign plugin implementation via a plugin base class
  - add possibility to create plugin method call
  - plugin creation properly done
- move addParam as an helper function.
# Conflicts:
#	js/src/atk4-semantic-ui.js
#	js/src/plugins/createModal.js
…re/js-modal-rev

# Conflicts:
#	js/src/atk4-semantic-ui.js
#	js/src/plugins/createModal.js
Plugin.js : needed to pass option to main function. Because calling the
plugin twice with different option on the same element was not working
since old option was still set in element.
Other plugin file: Need to adjust main function to accept options
spinner.js: add a function in order to remove spinner from element.
When calling the reloadView more than once on the same element the
element was growing because of spinner content not remove.
reloadView: adjust plugin to remove spinner on element being reload.
One day I will get it right on the first commit….
Put jQuery plugin in their own namespace.
This will help avoid name collision in future with other jquery plugin.
@romaninsh romaninsh merged commit 4e28324 into atk4:develop Jul 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants