Skip to content

Commit

Permalink
Merge pull request #2 from Cahdek/master
Browse files Browse the repository at this point in the history
Correction for serving AngularJS library from local directory
  • Loading branch information
bignall committed Aug 24, 2016
2 parents 16bf3cc + f4fa58d commit 7eda4ad
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 43 deletions.
9 changes: 5 additions & 4 deletions Angular/View/Helper/Angular/Container.php
Expand Up @@ -206,7 +206,7 @@ public function setMinified($bool)
$this->_minified = ($bool==true);
return $this;
}

/**
* Use the minified version (true) or dev version (false)?
*
Expand Down Expand Up @@ -563,13 +563,13 @@ protected function _renderScriptTags()
document.createElement('ng-include');
document.createElement('ng-pluralize');
document.createElement('ng-view');
// Optionally these for CSS
document.createElement('ng:include');
document.createElement('ng:pluralize');
document.createElement('ng:view');
</script>
<![endif]-->
<![endif]-->
IEHAPPY;

foreach ($this->_plugins as $plugin) {
Expand Down Expand Up @@ -641,7 +641,8 @@ protected function _getAngularLibraryBaseCdnUri()
protected function _getAngularLibraryPath()
{
if($this->_angularLibraryPath != null) {
$source = $this->_angularLibraryPath;
$source = $this->_angularLibraryPath .
($this->_minified==true? AngularZF1_Angular::CDN_ANGULAR_MIN_PATH_GOOGLE : AngularZF1_Angular::CDN_ANGULAR_PATH_GOOGLE);
} else {
$baseUri = $this->_getAngularLibraryBaseCdnUri();
$source = $baseUri .
Expand Down
85 changes: 46 additions & 39 deletions README.md
Expand Up @@ -2,38 +2,45 @@

by [Rosina Bignall](http://rosinabignall.com) and [Gregory Wilson](http://drakos7.net)

AngularZF1 is a [Zend Framework version 1](http://framework.zend.com/manual/1.12/en/manual.html) resource
AngularZF1 is a [Zend Framework version 1](http://framework.zend.com/manual/1.12/en/manual.html) resource
plugin to enable [AngularJs](https://angularjs.org/) and other Javascript libraries in your views.
It is a fork from the ZendX_JQuery component. In contrast to ZendX_JQuery, this plugin automatically
switches between non and SSL depending on your server configuration.


## Usage

Extract the zip file in your ZF1 library path.

Change directory name to AngularZF1

Modify your application config ini to include

autoloadernamespaces[] = "AngularZF1_"
autoloadernamespaces[] = "AngularZF1"
pluginPaths.AngularZF1_Application_Resource = "AngularZF1/Application/Resource"
resources.Angular.enable = true
resources.Angular.render_mode = 255
resources.Angular.version = "1.0.3"
resources.Angular.version = "1.5.8"
resources.Angular.minified = false
;UNCOMMENT NEXT LINE AND CHANGE THIS TO THE LOCATION OF YOUR ANGULAR
;INSTALLATION (angular.js OR angular.min.js IF MINIFIED AND resources.Angular.minified = true)
;resources.Angular.localpath = '/js/angular'

resources.Js.enable = true
resources.Js.render_mode = 255 ; default
resources.Js.minified = false

resources.Js.javascriptfile = "/some/file.js"
resources.Js.javascriptfiles.0 = "/some/file.js"

Add the following line to the head section of your layout.phtml

<?php $this->angular(); ?>
<?php $this->js(); ?>
Note: These are not needed if .enable is set to true in your config ini.
Also <?php $this->js(); ?> is optional if none of the Javascript
plugins are enabled in the config and there are no javascript files included

Note: These are not needed if .enable is set to true in your config ini.
Also <?php $this->js(); ?> is optional if none of the Javascript
plugins are enabled in the config and there are no javascript files included
in the resources config.

Or add the following to your pre-dispatch loop:
Expand All @@ -52,21 +59,21 @@ angular data-binding.

Current Angular plugins include:

- angular-resource(https://docs.angularjs.org/api/ngResource),
- angular-route(https://docs.angularjs.org/api/ngRoute),
- angular-sanitize(https://docs.angularjs.org/api/ngSanitize),
- angular-ui(http://angular-ui.github.io/),
- angular-ui-router(https://github.com/angular-ui/ui-router),
- angular-uibootstrap(https://angular-ui.github.io/bootstrap/),
- angular-animate(https://docs.angularjs.org/api/ngAnimate),
- angular-aria(https://docs.angularjs.org/api/ngAria),
- angular-resource(https://docs.angularjs.org/api/ngResource),
- angular-route(https://docs.angularjs.org/api/ngRoute),
- angular-sanitize(https://docs.angularjs.org/api/ngSanitize),
- angular-ui(http://angular-ui.github.io/),
- angular-ui-router(https://github.com/angular-ui/ui-router),
- angular-uibootstrap(https://angular-ui.github.io/bootstrap/),
- angular-animate(https://docs.angularjs.org/api/ngAnimate),
- angular-aria(https://docs.angularjs.org/api/ngAria),
- angular-messages(https://docs.angularjs.org/api/ngMessages),
- angular-material(https://material.angularjs.org/),
- angular-material(https://material.angularjs.org/),
- angular-filter(https://github.com/a8m/angular-filter#angular-filter-----),
- Restangular (https://github.com/mgonto/restangular)
- Restangular (https://github.com/mgonto/restangular)
- angular-bootstrap-calendar (https://github.com/mattlewis92/angular-bootstrap-calendar)

Current Javascript plugins include:
Current Javascript plugins include:

- Lodash (https://lodash.com/)
- Moment (http://momentjs.com/)
Expand Down Expand Up @@ -107,10 +114,10 @@ You can include additional plugins by modifying your config.ini to include
resources.Js.plugin.lodash.enable = false
; Moment
resources.Js.plugin.moment.enable = false


Each plugin has a .enable. If true, the scripts will be added to the head
section when you use $this->angular() or $this->js() or automatically if
section when you use $this->angular() or $this->js() or automatically if
the rescources .enable is true. If .enable is false, you can include
the scripts by adding the following lines to your view script.

Expand All @@ -119,7 +126,7 @@ the scripts by adding the following lines to your view script.
<?php $this->angularSanitize(); ?>
<?php $this->angularUi(); ?>
<?php $this->angularUirouter(); ?>
<?php $this->angularUiBootstrap(); ?>
<?php $this->angularUiBootstrap(); ?>
<?php $this->angularAnimate(); ?>
<?php $this->angularAria(); ?>
<?php $this->angularMessages(); ?>
Expand All @@ -129,24 +136,24 @@ the scripts by adding the following lines to your view script.
<?php $this->angularBootstrapCalendar(); ?>
<?php $this->jsLodash(); ?>
<?php $this->jsMoment(); ?>

The Angular plugin uses the default google apis CDN as shown on the Angular
homepage (https://angularjs.org/) to create the script tags. You can override it by setting
resources.Angular.base in your application config.
homepage (https://angularjs.org/) to create the script tags. You can override it by setting
resources.Angular.base in your application config.

Plugins for standard Angular modules (angular-resource, angular-sanitize, angular-animate,
angular-aria, and angular-messages) use the same base as the Angular
plugin.
angular-aria, and angular-messages) use the same base as the Angular
plugin.

The angular-material, angular-filter and angular-ui-router use the default CDNs
The angular-material, angular-filter and angular-ui-router use the default CDNs
as shown in their documentation. You can override the CDN by setting
the .base in the resource configuration.
The angular-ui, angular-uibootstrap, and angular-bootstrap-calendar
plugins do not have a default base url, so the

The angular-ui, angular-uibootstrap, and angular-bootstrap-calendar
plugins do not have a default base url, so the
.base for those plugins must be set in the application configuration.

The Angular plugin uses a default version (currently 1.5.7). You can override the default
The Angular plugin uses a default version (currently 1.5.7). You can override the default
version by setting resources.Angular.version in your application config.
The angular-filter and angular-material plugins also use default versions
and can be overridden by setting the .version for the plugin.
Expand All @@ -157,8 +164,8 @@ Lodash isn't an angular module, but it's required by Restangular so
we make it easy by making a plugin for it. The Restangular plugin will
automatically include Lodash in the view.

Moment is also a javascript module. It is required by angular-bootstrap-calendar
and will be included in the view automatically when angular-bootstrap-calendar is.
Moment is also a javascript module. It is required by angular-bootstrap-calendar
and will be included in the view automatically when angular-bootstrap-calendar is.

Aria, Messages and Animate are required by Angular Material, so they are
automatically included in the view when Material is included.
Expand All @@ -167,11 +174,11 @@ automatically included in the view when Material is included.

###Aug 5, 2016

Added plugins for angular-bootstrap-calendar and Moment. Fixed the settings
in the JS initilization which were modifying angular settings instead of
Added plugins for angular-bootstrap-calendar and Moment. Fixed the settings
in the JS initilization which were modifying angular settings instead of
js settings. Updated default angular version to 1.5.7.

##Acknowledgments

This module was written and continues to be developed as part of my work
for Social & Scientific Systems, Inc. (http://s-3.com/).
This module was written and continues to be developed as part of my work
for Social & Scientific Systems, Inc. (http://s-3.com/).

0 comments on commit 7eda4ad

Please sign in to comment.