Skip to content

Commit

Permalink
Add: classNames option
Browse files Browse the repository at this point in the history
  • Loading branch information
mugifly committed Apr 18, 2016
1 parent 0b16361 commit e5704e9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
bower_components/
node_modules/
compiling_error.txt

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-page-turner",
"version": "0.1.0",
"version": "0.2.0",
"description": "A simple page turner library for AngularJS v1",
"authors": [
"Masanori Ohgita (https://github.com/mugifly)"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-page-turner",
"version": "0.1.0",
"version": "0.2.0",
"description": "A simple page turner library for AngularJS v1",
"main": "scripts/angular-page-turner.js",
"directories": {
Expand Down
23 changes: 18 additions & 5 deletions scripts/angular-page-turner.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ angular.module('PageTurner', [])
* @return {Integer} ID of the new page
*/
service.addPage = function (args) {

var class_names = [];
if (args.classNames != null) {
class_names = args.classNames.split(/ /);
}

$rootScope.$broadcast('ANGULAR_PAGE_TURNER', {
cmd: 'addPage',
template: args.template
template: args.template,
classNames: class_names
});
};

Expand Down Expand Up @@ -135,9 +142,9 @@ function ($timeout, PageTurner) { // Inject the PageTurner service
* Add the new page
* @param {String} template Template of the page
*/
$scope.addPage = function (template) {
$scope.addPage = function (template, class_names) {

$scope.internalMethods.addPage(template);
$scope.internalMethods.addPage(template, class_names);
$scope.internalMethods.drawPages(true);

};
Expand Down Expand Up @@ -195,7 +202,7 @@ function ($timeout, PageTurner) { // Inject the PageTurner service
$scope.$on('ANGULAR_PAGE_TURNER', function(event, args) {

if (args.cmd == 'addPage') {
$scope.addPage(args.template);
$scope.addPage(args.template, args.classNames);
} else if (args.cmd == 'openPage') {
$scope.openPage(args.pageId);
}
Expand Down Expand Up @@ -235,12 +242,18 @@ function ($timeout, PageTurner) { // Inject the PageTurner service
/**
* Add the new page
* @param {String} template Template of the page
* @param {Array} class_names Class names
*/
scope.internalMethods.addPage = function(template) {
scope.internalMethods.addPage = function(template, class_names) {

var $page = angular.element('<div/>');
$page.html(template);
$page.addClass('page');
if (class_names != null) {
for (var i = 0, l = class_names.length; i < l; i++) {
$page.addClass(class_names[i]);
}
}
$container.append($page);

};
Expand Down

0 comments on commit e5704e9

Please sign in to comment.