chore: remove animation & type attributes, standard controller names

This commit is contained in:
Andy Joslin
2014-03-18 14:49:05 -06:00
parent 5117d5673a
commit 83f4776f53
26 changed files with 257 additions and 331 deletions

View File

@@ -2,9 +2,17 @@ module.exports = [
{
name: 'controller',
transformFn: function(doc, tag) {
return '{@link ionic.controller:' + tag.description.trim() + '}';
var desc = tag.description.trim();
var id = desc.split(' ')[0];
var other = desc.split(' ').splice(1).join(' ');
var link = '{@link ionic.controller:' + id + '}';
return link + (other ? ' ' + other : '');
}
},
{
name: 'controllerBind',
},
{
name: 'parent',
transformFn: function(doc, tag) {

View File

@@ -22,13 +22,15 @@ docType: "<$ doc.docType $>"
<$ doc.name $>
<@ endif @>
<@ if doc.parentLinks @>
<br />
<small>
(child of <$ doc.parentLinks $>)
Child of <$ doc.parentLinks $>
</small>
<@ endif @>
<@ if doc.controller @>
<br/>
<small>
(controller: <$ doc.controller $>)
Controller: <$ doc.controller $>
</small>
<@ endif @>
</h1>

View File

@@ -3,10 +3,10 @@ var buildConfig = require('./config/build.config.js');
var changelog = require('conventional-changelog');
var connect = require('connect');
var dgeni = require('dgeni');
var lunr = require('lunr');
var htmlparser = require('htmlparser2');
var yaml = require('js-yaml');
var es = require('event-stream');
var htmlparser = require('htmlparser2');
var lunr = require('lunr');
var yaml = require('js-yaml');
var http = require('http');
var cp = require('child_process');
@@ -47,7 +47,7 @@ gulp.task('build', ['bundle', 'sass']);
gulp.task('docs-index', function() {
var idx = lunr(function() {
this.field('path');
this.field('path');
this.field('title', {boost: 10});
this.field('body');
this.ref('path')
@@ -55,7 +55,7 @@ gulp.task('docs-index', function() {
var ref = {};
return gulp.src([
'tmp/ionic-site/docs/{components,guide,overview,angularjs}/**/*.{md,html}',
'tmp/ionic-site/docs/{components,guide,overview,angularjs}/**/*.{md,html}',
'tmp/ionic-site/tutorials/**/*.{md,html}'
])
.pipe(es.map(function(file, callback) {
@@ -72,7 +72,7 @@ gulp.task('docs-index', function() {
var properties = yaml.safeLoad(yamlRaw);
contents = contents.slice(yamlEndIndex+3);
if(properties.title && properties.layout) {
title = properties.title;
layout = properties.layout;
@@ -87,7 +87,7 @@ gulp.task('docs-index', function() {
// Ignore any Jekyll expressions
body += text.replace(/{%.*%}/, '', 'g');
},
});
});
parser.write(contents);
parser.end();
@@ -115,7 +115,7 @@ gulp.task('docs', function(done) {
});
var IS_WATCH = false;
gulp.task('watch', function() {
gulp.task('watch', ['bundle'], function() {
IS_WATCH = true;
gulp.watch('js/**/*.js', ['bundle']);
gulp.watch('scss/**/*.scss', ['sass']);

View File

@@ -49,29 +49,43 @@
};
},
isOpenLeft: function() {
return this._leftShowing;
},
isOpenRight: function() {
return this._rightShowing;
},
/**
* Toggle the left menu to open 100%
*/
toggleLeft: function() {
toggleLeft: function(shouldOpen) {
if (arguments.length === 0) {
shouldOpen = !this._leftShowing;
}
this.content.enableAnimation();
var openAmount = this.getOpenAmount();
if(openAmount > 0) {
this.openPercentage(0);
} else {
if(shouldOpen) {
this.openPercentage(100);
} else {
this.openPercentage(0);
}
},
/**
* Toggle the right menu to open 100%
*/
toggleRight: function() {
toggleRight: function(shouldOpen) {
if (arguments.length === 0) {
shouldOpen = !this._rightShowing;
}
this.content.enableAnimation();
var openAmount = this.getOpenAmount();
if(openAmount < 0) {
this.openPercentage(0);
} else {
if(shouldOpen) {
this.openPercentage(-100);
} else {
this.openPercentage(0);
}
},

View File

@@ -17,7 +17,7 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
* @name ionHeaderBar
* @module ionic
* @restrict E
* @controller ionicBar
* @controller ionicBar as $scope.$ionicHeaderBarController
*
* @description
* Adds a fixed header bar above some content.
@@ -25,9 +25,9 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
* Is able to have left or right buttons, and additionally its title can be
* aligned through the {@link ionic.controller:ionicBar ionicBar controller}.
*
* @param {string=} model The model to assign this headerBar's
* @param {string=} controller-bind The scope variable to bind this header bar's
* {@link ionic.controller:ionicBar ionicBar controller} to.
* Defaults to assigning to $scope.headerBarController.
* Default: $scope.$ionicHeaderBarController.
* @param {string=} align-title Where to align the title at the start.
* Avaialble: 'left', 'right', or 'center'. Defaults to 'center'.
*
@@ -54,7 +54,7 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
* @name ionFooterBar
* @module ionic
* @restrict E
* @controller ionicBar
* @controller ionicBar as $scope.$ionicFooterBarController
*
* @description
* Adds a fixed footer bar below some content.
@@ -62,9 +62,9 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
* Is able to have left or right buttons, and additionally its title can be
* aligned through the {@link ionic.controller:ionicBar ionicBar controller}.
*
* @param {string=} model The model to assign this footerBar's
* @param {string=} controller-bind The scope variable to bind this footer bar's
* {@link ionic.controller:ionicBar ionicBar controller} to.
* Defaults to assigning to $scope.footerBarController.
* Default: $scope.$ionicFooterBarController.
* @param {string=} align-title Where to align the title at the start.
* Avaialble: 'left', 'right', or 'center'. Defaults to 'center'.
*
@@ -91,8 +91,8 @@ function barDirective(isHeader) {
'<header class="bar bar-header" ng-transclude></header>' :
'<footer class="bar bar-footer" ng-transclude></footer>';
var BAR_MODEL_DEFAULT = isHeader ?
'headerBarController' :
'footerBarController';
'$ionicHeaderBarController' :
'$ionicFooterBarController';
return ['$parse', function($parse) {
return {
restrict: 'E',
@@ -105,7 +105,7 @@ function barDirective(isHeader) {
alignTitle: $attr.alignTitle || 'center'
});
$parse($attr.model || BAR_MODEL_DEFAULT).assign($scope, hb);
$parse($attr.controllerBind || BAR_MODEL_DEFAULT).assign($scope, hb);
}
};
}];

View File

@@ -1,43 +0,0 @@
(function() {
angular.module('ionic.ui.navAnimation', [])
/**
* @ngdoc directive
* @name ionNavAnimation
* @module ionic
* @restrict A
* @parent ionic.directive:ionNavView
*
* @description
* When used under an {@link ionic.directive:ionNavView} and on an `<a>` element,
* allows you to set the animation all clicks on that link within the navView use.
*
* @usage
* ```html
* <ion-nav-view>
* <ion-view>
* <ion-content>
* <a href="#/some-page" ion-nav-animation="slide-in-up">
* Click me and #/some-page will transition in with the slide-in-up animation!
* </a>
* </ion-content>
* </ion-view>
* </ion-nav-view>
* ```
*
* @param {string} ion-nav-animation The animation to make the parent ionNavView change pages with when clicking this element.
*/
.directive('ionNavAnimation', function() {
return {
restrict: 'A',
require: '^?ionNavView',
link: function($scope, $element, $attrs, navViewCtrl) {
if (!navViewCtrl) {
return;
}
ionic.on('tap', function() {
navViewCtrl.setNextAnimation($attrs.ionNavAnimation);
}, $element[0]);
}
};
});
})();

View File

@@ -8,16 +8,18 @@ angular.module('ionic.ui.navBar', ['ionic.service.view', 'ngSanitize'])
* @description
* Controller for the {@link ionic.directive:ionNavBar} directive.
*/
.controller('$ionicNavBar', ['$scope', '$element', '$ionicViewService', '$animate', '$compile',
.controller('$ionicNavBar', [
'$scope',
'$element',
'$ionicViewService',
'$animate',
'$compile',
function($scope, $element, $ionicViewService, $animate, $compile) {
//Let the parent know about our controller too so that children of
//sibling content elements can know about us.
//sibling content elements can know about us
$element.parent().data('$ionNavBarController', this);
var hb = this._headerBarView = new ionic.views.HeaderBar({
el: $element[0],
alignTitle: $scope.alignTitle || 'center'
});
var self = this;
this.leftButtonsElement = angular.element(
$element[0].querySelector('.buttons.left-buttons')
@@ -148,7 +150,7 @@ function($scope, $element, $ionicViewService, $animate, $compile) {
var insert = oldTitleEl && angular.element(oldTitleEl) || null;
$animate.enter(newTitleEl, $element, insert, function() {
hb.align();
self._headerBarView.align();
});
//Cleanup any old titles leftover (besides the one we already did replaceWith on)
@@ -174,7 +176,7 @@ function($scope, $element, $ionicViewService, $animate, $compile) {
* @ngdoc directive
* @name ionNavBar
* @module ionic
* @controller ionicNavBar
* @controller ionicNavBar as $scope.$ionicNavBarController
* @restrict E
*
* @description
@@ -186,25 +188,26 @@ function($scope, $element, $ionicViewService, $animate, $compile) {
* We can add buttons depending on the currently visible view using
* {@link ionic.directive:ionNavButtons}.
*
* Assign an [animation class](/docs/components#animations) to the element to
* enable animated changing of titles (recommended: 'slide-left-right' or 'nav-title-slide-ios7')
*
* @usage
*
* ```html
* <body ng-app="starter">
* <!-- The nav bar that will be updated as we navigate -->
* <ion-nav-bar class="bar-positive"
* animation="nav-title-slide-ios7">
* <ion-nav-bar class="bar-positive nav-title-slide-ios7">
* </ion-nav-bar>
*
* <!-- where the initial view template will be rendered -->
* <ion-nav-view animation="slide-left-right"></ion-nav-view>
* <ion-nav-view></ion-nav-view>
* </body>
* ```
*
* @param model {string=} The model to assign the
* @param controller-bind {string=} The scope expression to bind this element's
* {@link ionic.controller:ionicNavBar ionicNavBar controller} to.
* Default: assigns it to $scope.navBarController.
* @param animation {string=} The animation used to transition between titles.
* @param align {string=} Where to align the title of the navbar.
* Default: $ionicNavBarController.
* @param align-title {string=} Where to align the title of the navbar.
* Available: 'left', 'right', 'center'. Defaults to 'center'.
*/
.directive('ionNavBar', ['$ionicViewService', '$rootScope', '$animate', '$compile', '$parse',
@@ -215,10 +218,6 @@ function($ionicViewService, $rootScope, $animate, $compile, $parse) {
replace: true,
transclude: true,
controller: '$ionicNavBar',
scope: {
animation: '@',
alignTitle: '@'
},
template:
'<header class="bar bar-header nav-bar{{navBarClass()}}">' +
'<div class="buttons left-buttons"> ' +
@@ -230,7 +229,13 @@ function($ionicViewService, $rootScope, $animate, $compile, $parse) {
compile: function(tElement, tAttrs, transclude) {
return function link($scope, $element, $attr, navBarCtrl) {
$parse($attr.model || 'navBarController').assign($scope.$parent, navBarCtrl);
navBarCtrl._headerBarView = new ionic.views.HeaderBar({
el: $element[0],
alignTitle: $attr.alignTitle || 'center'
});
$parse($attr.controllerBind || '$ionicNavBarController')
.assign($scope, navBarCtrl);
//Put transcluded content (usually a back button) before the rest
transclude($scope, function(clone) {
@@ -246,7 +251,7 @@ function($ionicViewService, $rootScope, $animate, $compile, $parse) {
$scope.navBarClass = function() {
return ($scope.isReverse ? ' reverse' : '') +
($scope.isInvisible ? ' invisible' : '') +
($scope.shouldAnimate && $scope.animation ? ' ' + $scope.animation : '');
(!$scope.shouldAnimate ? ' no-animation' : '');
};
};
}
@@ -282,9 +287,9 @@ function($ionicViewService, $rootScope, $animate, $compile, $parse) {
* With custom click action, using {@link ionic.controller:ionicNavBar ionicNavBar controller}:
*
* ```html
* <ion-nav-bar model="navBarController">
* <ion-nav-bar>
* <ion-nav-back-button class="button-icon"
* ng-click="canGoBack && navBarController.back()">
* ng-click="canGoBack && $ionicNavBarController.back()">
* <i class="ion-arrow-left-c"></i> Back
* </ion-nav-back-button>
* </ion-nav-bar>
@@ -294,9 +299,9 @@ function($ionicViewService, $rootScope, $animate, $compile, $parse) {
* {@link ionic.controller:ionicNavBar ionicNavBar controller}.
*
* ```html
* <ion-nav-bar model="navBarController">
* <ion-nav-bar>
* <ion-nav-back-button class="button button-icon ion-arrow-left-c">
* {% raw %}{{navBarController.getPreviousTitle() || 'Back'}}{% endraw %}
* {% raw %}{{$ionicNavBarController.getPreviousTitle() || 'Back'}}{% endraw %}
* </ion-nav-back-button>
* </ion-nav-bar>
* ```
@@ -395,7 +400,8 @@ function($ionicViewService, $rootScope, $animate, $compile, $parse) {
$animate.leave(clone);
});
//The original element is just a completely empty <ion-nav-buttons></ion-nav-buttons> - make it invisible
// The original element is just a completely empty <ion-nav-buttons> element.
// make it invisible just to be sure it doesn't change any layout
$element.css('display', 'none');
};
}

View File

@@ -32,11 +32,25 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie
* @ngdoc method
* @name ionicSideMenus#toggleLeft
* @description Toggle the left side menu (if it exists).
* @param {boolean=} isOpen Whether to open or close the menu.
* Default: Toggles the menu.
*/
/**
* @ngdoc method
* @name ionicSideMenus#toggleRight
* @description Toggle the right side menu (if it exists).
* @param {boolean=} isOpen Whether to open or close the menu.
* Default: Toggles the menu.
*/
/**
* @ngdoc method
* @name ionicSideMenus#isOpenLeft
* @returns {boolean} Whether the left menu is currently opened.
*/
/**
* @ngdoc method
* @name ionicSideMenus#isOpenRight
* @returns {boolean} Whether the right menu is currently opened.
*/
/**
@@ -44,7 +58,7 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie
* @name ionSideMenus
* @module ionic
* @restrict E
* @controller ionicSideMenus
* @controller ionicSideMenus as $scope.$ionicSideMenusController
*
* @description
* A container element for side menu(s) and the main content. Allows the left
@@ -85,7 +99,9 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie
* }
* ```
*
* @param {expression=} model The model to assign this side menu container's {@link ionic.controller:ionicSideMenus} controller to. By default, assigns to $scope.sideMenuController.
* @param {string=} controller-bind The scope variable to bind these side menus'
* {@link ionic.controller:ionicSideMenus ionicSideMenus controller} to.
* Default: $scope.$ionicSideMenusController.
*
*/
.directive('ionSideMenus', function() {
@@ -103,7 +119,7 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie
$scope.sideMenuContentTranslateX = 0;
$parse($attrs.model || 'sideMenuController').assign($scope, this);
$parse($attrs.controllerBind || '$ionicSideMenusController').assign($scope, this);
}],
replace: true,
transclude: true,

View File

@@ -12,7 +12,7 @@ angular.module('ionic.ui.slideBox', [])
* @name ionSlideBox
* @module ionic
* @restrict E
* @controller ionicSlideBox
* @controller ionicSlideBox as $scope.$ionicSlideBoxController
* @description
* The Slide Box is a multi-page container where each page can be swiped or dragged between:
*
@@ -33,7 +33,9 @@ angular.module('ionic.ui.slideBox', [])
* </ion-slide-box>
* ```
*
* @param {expression=} model The model to assign this slide box container's {@link ionic.controller:ionicSlideBox} controller to. By default, assigns to $scope.slideBoxController.
* @param {string=} controller-bind The scope variable to bind this slide box's
* {@link ionic.controller:ionicSlideBox ionicSlideBox controller} to.
* Default: $scope.$ionicSlideBoxController.
* @param {boolean=} does-continue Whether the slide box should automatically slide.
* @param {number=} slide-interval How many milliseconds to wait to change slides (if does-continue is true). Defaults to 4000.
* @param {boolean=} show-pager Whether a pager should be shown for this slide box.
@@ -41,7 +43,7 @@ angular.module('ionic.ui.slideBox', [])
* @param {expression=} on-slide-changed Expression called whenever the slide is changed.
* @param {expression=} active-slide Model to bind the current slide to.
*/
.directive('ionSlideBox', ['$timeout', '$compile', '$ionicSlideBoxDelegate', function($timeout, $compile, $ionicSlideBoxDelegate) {
.directive('ionSlideBox', ['$timeout', '$compile', function($timeout, $compile) {
return {
restrict: 'E',
replace: true,
@@ -100,9 +102,7 @@ angular.module('ionic.ui.slideBox', [])
slider.slide(index);
});
$parse($attrs.model || 'slideBoxController').assign($scope.$parent, slider);
$ionicSlideBoxDelegate.register($scope, $element);
$parse($attrs.controllerBind || '$ionicSlideBoxController').assign($scope.$parent, slider);
this.slidesCount = function() {
return slider.slidesCount();

View File

@@ -132,17 +132,23 @@ angular.module('ionic.ui.tabs', ['ionic.service.view'])
* @name ionTabs
* @module ionic
* @restrict E
* @controller ionicTabs
* @controller ionicTabs as $scope.$ionicTabsController
* @codepen KbrzJ
*
* @description
* Powers a multi-tabbed interface with a Tab Bar and a set of "pages" that can be tabbed through.
* Powers a multi-tabbed interface with a Tab Bar and a set of "pages" that can be tabbed
* through.
*
* See the {@link ionic.directive:ionTab} directive's documentation for more details.
* Assign any [tabs class](/docs/components#tabs) or
* [animation class](/docs/components#animation) to the element to define
* its look and feel.
*
* See the {@link ionic.directive:ionTab} directive's documentation for more details on
* individual tabs.
*
* @usage
* ```html
* <ion-tabs tabs-type="tabs-icon-only">
* <ion-tabs class="tabs-positive tabs-icon-only">
*
* <ion-tab title="Home" icon-on="ion-ios7-filing" icon-off="ion-ios7-filing-outline">
* <!-- Tab 1 content -->
@@ -158,13 +164,12 @@ angular.module('ionic.ui.tabs', ['ionic.service.view'])
* </ion-tabs>
* ```
*
* @param {expression=} model The model to assign this tab bar's {@link ionic.controller:ionicTabs} controller to. By default, assigns to $scope.tabsController.
* @param {string=} animation The animation to use when changing between tab pages.
* @param {string=} tabs-style The class to apply to the tabs. Defaults to 'tabs-positive'.
* @param {string=} tabs-type Whether to put the tabs on the top or bottom. Defaults to 'tabs-bottom'.
* @param {string=} controller-bind The scope variable to bind these tabs'
* {@link ionic.controller:ionicTabs ionicTabs controller} to.
* Default: $scope.$ionicTabsController.
*/
.directive('ionTabs', ['$ionicViewService', '$ionicBind', '$parse', function($ionicViewService, $ionicBind, $parse) {
.directive('ionTabs', ['$ionicViewService', '$parse', function($ionicViewService, $parse) {
return {
restrict: 'E',
replace: true,
@@ -172,22 +177,14 @@ angular.module('ionic.ui.tabs', ['ionic.service.view'])
transclude: true,
controller: 'ionicTabs',
template:
'<div class="view {{$animation}}">' +
'<div class="tabs {{$tabsStyle}} {{$tabsType}}">' +
'<div class="view">' +
'<div class="tabs">' +
'</div>' +
'</div>',
compile: function(element, attr, transclude) {
if(angular.isUndefined(attr.tabsType)) attr.$set('tabsType', 'tabs-positive');
return function link($scope, $element, $attr, tabsCtrl) {
$ionicBind($scope, $attr, {
$animation: '@animation',
$tabsStyle: '@tabsStyle',
$tabsType: '@tabsType'
});
$parse(attr.model || 'tabsController').assign($scope, tabsCtrl);
$parse(attr.model || '$ionicTabsController').assign($scope, tabsCtrl);
tabsCtrl.$scope = $scope;
tabsCtrl.$element = $element;

View File

@@ -8,7 +8,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
* @name ionView
* @module ionic
* @restrict E
* @parent ionNavBar
* @parent ionNavView
*
* @description
* A container for content, used to tell a parent {@link ionic.directive:ionNavBar}
@@ -19,7 +19,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
*
* ```html
* <ion-nav-bar></ion-nav-bar>
* <ion-nav-view>
* <ion-nav-view class="slide-left-right">
* <ion-view title="My Page">
* <ion-content>
* Hello!
@@ -30,8 +30,9 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
*
* @param {string=} title The title to display on the parent {@link ionic.directive:ionNavBar}.
* @param {boolean=} hideBackButton Whether to hide the back button on the parent
* {@link ionic.directive:ionNavBar}.
* @param {boolean=} hideNavBar Whether to hide the parent {@link ionic.directive:ionNavBar}.
* {@link ionic.directive:ionNavBar} by default.
* @param {boolean=} hideNavBar Whether to hide the parent
* {@link ionic.directive:ionNavBar} by default.
*/
.directive('ionView', ['$ionicViewService', '$rootScope', '$animate',
function( $ionicViewService, $rootScope, $animate) {
@@ -107,8 +108,11 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
* {@link ionic.directive:ionNavBar} directive which will render a header bar that updates as we
* navigate through the navigation stack.
*
* You can any [animation class](/docs/components#animation) on the navView to have its pages slide.
* Recommended for page transitions: 'slide-left-right', 'slide-left-right-ios7', 'slide-in-up'.
*
* ```html
* <ion-nav-view>
* <ion-nav-view class="slide-left-right">
* <!-- Center content -->
* <ion-nav-bar>
* </ion-nav-bar>
@@ -163,8 +167,6 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
* @param {string=} name A view name. The name should be unique amongst the other views in the
* same state. You can have views of the same name that live in different states. For more
* information, see ui-router's [ui-view documentation](http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.directive:ui-view).
* @param {string=} animation The animation to use for views underneath this ionNavView.
* Defaults to 'slide-left-right'.
*/
.directive('ionNavView', ['$ionicViewService', '$state', '$compile', '$controller', '$animate',
function( $ionicViewService, $state, $compile, $controller, $animate) {
@@ -177,10 +179,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
terminal: true,
priority: 2000,
transclude: true,
controller: ['$scope', function($scope) {
this.setNextAnimation = function(anim) {
$scope.$nextAnimation = anim;
};
controller: [function(){
}],
compile: function (element, attr, transclude) {
return function(scope, element, attr, navViewCtrl) {

View File

@@ -1,3 +1,4 @@
/*
(function() {
'use strict';
@@ -20,3 +21,4 @@ angular.module('ionic.ui.virtRepeat', [])
};
});
})(ionic);
*/

View File

@@ -1,4 +1,4 @@
/*
(function() {
'use strict';
@@ -33,7 +33,6 @@ function isTagNameInList(element, list){
// Utility to find the viewport/content elements given the start element:
function findViewportAndContent(startElement){
/*jshint eqeqeq:false, curly:false */
var root = $rootElement[0];
var e, n;
// Somewhere between the grandparent and the root node
@@ -123,13 +122,13 @@ function computeRowHeight(element){
angular.module('ionic.ui.virtualRepeat', [])
/**
* A replacement for ng-repeat that supports virtual lists.
* This is not a 1 to 1 replacement for ng-repeat. However, in situations
* where you have huge lists, this repeater will work with our virtual
* scrolling to only render items that are showing or will be showing
* if a scroll is made.
*/
//
// A replacement for ng-repeat that supports virtual lists.
// This is not a 1 to 1 replacement for ng-repeat. However, in situations
// where you have huge lists, this repeater will work with our virtual
// scrolling to only render items that are showing or will be showing
// if a scroll is made.
//
.directive('ionVirtualRepeat', ['$log', function($log) {
return {
require: ['?ngModel, ^virtualList'],
@@ -326,3 +325,4 @@ angular.module('ionic.ui.virtualRepeat', [])
}]);
})(ionic);
*/

View File

@@ -25,8 +25,7 @@ angular.module('ionic.service', [
// UI specific services and delegates
angular.module('ionic.ui.service', [
'ionic.ui.service.scrollDelegate',
'ionic.ui.service.slideBoxDelegate'
'ionic.ui.service.scrollDelegate'
]);
angular.module('ionic.ui', [

View File

@@ -1,29 +0,0 @@
(function() {
'use strict';
angular.module('ionic.ui.service.slideBoxDelegate', [])
.factory('$ionicSlideBoxDelegate', ['$rootScope', '$timeout', function($rootScope, $timeout) {
return {
/**
* Trigger a slidebox to update and resize itself
*/
update: function(animate) {
$rootScope.$broadcast('slideBox.update');
},
register: function($scope, $element) {
$scope.$parent.$on('slideBox.update', function(e) {
if(e.defaultPrevented) {
return;
}
$timeout(function() {
$scope.$parent.slideBoxController.setup();
});
e.preventDefault();
});
}
};
}]);
})(ionic);

View File

@@ -4,11 +4,11 @@ describe('bar directives', function() {
angular.forEach([{
tag: 'ion-header-bar',
element: 'header',
model: 'headerBarController'
controllerBind: '$ionicHeaderBarController'
}, {
tag: 'ion-footer-bar',
element: 'footer',
model: 'footerBarController'
controllerBind: '$ionicFooterBarController'
}], function(data) {
describe(data.tag, function() {
@@ -31,22 +31,22 @@ describe('bar directives', function() {
expect(el[0].tagName.toLowerCase()).toBe(data.element);
});
it('should assign views.HeaderBar to default model', function() {
it('should assign views.HeaderBar to default controllerBind', function() {
var el = setup();
expect(el.scope()[data.model] instanceof ionic.views.HeaderBar).toBe(true);
expect(el.scope()[data.controllerBind] instanceof ionic.views.HeaderBar).toBe(true);
});
it('should assign views.HeaderBar to attr model', function() {
var el = setup('model="monkeys"');
it('should assign views.HeaderBar to attr controllerBind', function() {
var el = setup('controller-bind="monkeys"');
expect(el.scope().monkeys instanceof ionic.views.HeaderBar).toBe(true);
});
it('should pass center to views.HeaderBar option by default', function() {
var el = setup();
expect(el.scope()[data.model].opts.alignTitle).toBe('center');
expect(el.scope()[data.controllerBind].opts.alignTitle).toBe('center');
});
it('should pass attr.alignTitle to views.HeaderBar', function() {
var el = setup('align-title="left"');
expect(el.scope()[data.model].opts.alignTitle).toBe('left');
expect(el.scope()[data.controllerBind].opts.alignTitle).toBe('left');
});
});
});

View File

@@ -1,41 +0,0 @@
describe('ionNavAnimation directive', function() {
beforeEach(module('ionic.ui.navAnimation'));
var navViewCtrl;
function setup(anim, noNavViewCtrl) {
if (noNavViewCtrl) {
navViewCtrl = null;
} else {
navViewCtrl = {
setNextAnimation: jasmine.createSpy('setNextAnimation')
};
}
var element = angular.element(
'<div ion-nav-animation="'+(anim||'')+'"></div>'
);
element.data('$ionNavViewController', navViewCtrl);
inject(function($compile, $rootScope) {
$compile(element)($rootScope.$new());
});
return element;
}
it('should not listen for tap if no navViewCtrl', function() {
spyOn(ionic, 'on');
setup('', true);
expect(ionic.on).not.toHaveBeenCalled();
});
it('should listen for tap', function() {
spyOn(ionic, 'on');
var el = setup('');
expect(ionic.on).toHaveBeenCalledWith('tap', jasmine.any(Function), el[0]);
});
it('should call navViewCtrl.setNextAnimation on tap', function() {
var el = setup('foobar');
ionic.trigger('tap', { target: el[0] });
expect(navViewCtrl.setNextAnimation).toHaveBeenCalledWith('foobar');
});
});

View File

@@ -232,11 +232,11 @@ describe('ionNavBar', function() {
it('should assign $scope.navBarController by default', function() {
var el = setup();
expect(el.controller('ionNavBar')).toBeTruthy(); //sanity
expect(el.scope().navBarController).toBe(el.controller('ionNavBar'));
expect(el.scope().$ionicNavBarController).toBe(el.controller('ionNavBar'));
});
it('should assign $scope.navBarController to attr.model if set', function() {
var el = setup('model="theNavBarCtrl"');
var el = setup('controller-bind="theNavBarCtrl"');
expect(el.controller('ionNavBar')).toBeTruthy();
expect(el.scope().theNavBarCtrl).toBe(el.controller('ionNavBar'));
});
@@ -244,27 +244,18 @@ describe('ionNavBar', function() {
it('should have isInvisible class (default true)', function() {
var el = setup();
expect(el.hasClass('invisible')).toBe(true);
el.isolateScope().$apply('isInvisible = false');
el.scope().$apply('isInvisible = false');
expect(el.hasClass('invisible')).toBe(false);
el.isolateScope().$apply('isInvisible = true');
el.scope().$apply('isInvisible = true');
expect(el.hasClass('invisible')).toBe(true);
});
it('should have animation class', function() {
var el = setup('animation="my-anim"');
expect(el.hasClass('my-anim')).toBe(true);
el.isolateScope().$apply('shouldAnimate = false');
expect(el.hasClass('my-anim')).toBe(false);
el.isolateScope().$apply('shouldAnimate = true');
expect(el.hasClass('my-anim')).toBe(true);
});
it('should have reverse class', function() {
var el = setup();
expect(el.hasClass('reverse')).toBe(false);
el.isolateScope().$apply('isReverse = true');
el.scope().$apply('isReverse = true');
expect(el.hasClass('reverse')).toBe(true);
el.isolateScope().$apply('isReverse = false');
el.scope().$apply('isReverse = false');
expect(el.hasClass('reverse')).toBe(false);
});
});

View File

@@ -7,15 +7,15 @@ describe('Ionic Angular Side Menu', function() {
beforeEach(module('ionic.ui.sideMenu'));
it('should assign sideMenuController', inject(function($compile, $rootScope) {
it('should assign $ionicSideMenusController', inject(function($compile, $rootScope) {
var el = $compile('<ion-side-menus></ion-side-menus>')($rootScope);
var scope = el.scope();
expect(el.controller('ionSideMenus')).toBeDefined();
expect(scope.sideMenuController).toBe(el.controller('ionSideMenus'));
expect(scope.$ionicSideMenusController).toBe(el.controller('ionSideMenus'));
}));
it('should assign sideMenuController with option', inject(function($compile, $rootScope) {
var el = $compile('<ion-side-menus model="supermodel"></ion-side-menus>')($rootScope);
var el = $compile('<ion-side-menus controller-bind="supermodel"></ion-side-menus>')($rootScope);
var scope = el.scope();
expect(el.controller('ionSideMenus')).toBeDefined();
expect(scope.supermodel).toBe(el.controller('ionSideMenus'));

View File

@@ -3,12 +3,11 @@
* see the core Ionic sideMenu controller tests.
*/
describe('Ionic Angular Slide Box', function() {
var el, delegate, compile, rootScope, timeout;
var el, compile, rootScope, timeout;
beforeEach(module('ionic'));
beforeEach(inject(function($compile, $rootScope, $timeout, $ionicSlideBoxDelegate) {
delegate = $ionicSlideBoxDelegate;
beforeEach(inject(function($compile, $rootScope, $timeout) {
timeout = $timeout;
rootScope = $rootScope;
compile = $compile;
@@ -32,26 +31,17 @@ describe('Ionic Angular Slide Box', function() {
it('Should init', function() {
var scope = el.scope();
expect(scope.slideBoxController).toBeDefined()
expect(scope.slideBoxController.slide).toBeDefined();
expect(scope.$ionicSlideBoxController).toBeDefined()
expect(scope.$ionicSlideBoxController.slide).toBeDefined();
});
it('Should init with custom model attr', inject(function($compile, $rootScope) {
var el = $compile('<ion-slide-box model="myModel"></ion-slide-box>')($rootScope);
it('Should init with custom controller-bind attr', inject(function($compile, $rootScope) {
var el = $compile('<ion-slide-box controller-bind="myModel"></ion-slide-box>')($rootScope);
var scope = el.scope();
expect(scope.myModel).toBeDefined();
expect(scope.myModel.slide).toBeDefined();
}));
it('Should update with delegate', function() {
var scope = el.scope();
var slideBox = scope.slideBoxController;
spyOn(slideBox, 'setup');
delegate.update();
timeout.flush();
expect(slideBox.setup).toHaveBeenCalled();
});
it('Should set initial active slide', function() {
el = compile('<ion-slide-box active-slide="2">\
<ion-slide>\
@@ -70,6 +60,6 @@ describe('Ionic Angular Slide Box', function() {
</ion-slide-box>')(rootScope);
var scope = el.scope();
expect(scope.slideBoxController.currentIndex()).toBe(2);
expect(scope.$ionicSlideBoxController.currentIndex()).toBe(2);
});
});

View File

@@ -224,10 +224,10 @@ describe('tabs', function() {
return element;
}
it('should bind controller to scope.tabsController by default', function() {
it('should bind controller to scope.$ionicTabsController by default', function() {
var el = setup();
expect(el.controller('ionTabs')).toBeTruthy(); //sanity
expect(el.scope().tabsController).toBe(el.controller('ionTabs'));
expect(el.scope().$ionicTabsController).toBe(el.controller('ionTabs'));
});
it('should bind controller to scope[attr.model]', function() {
@@ -236,17 +236,6 @@ describe('tabs', function() {
expect(el.scope().superman).toBe(el.controller('ionTabs'));
});
it('should set attr classes', function() {
var el = setup('animation="foo" tabs-style="bar" tabs-type="baz"');
expect(el.hasClass('foo')).toBe(true);
expect(el.children().hasClass('bar baz')).toBe(true);
});
it('should default tabsType to tabs-positive', function() {
var el = setup();
expect(el.children().hasClass('tabs-positive')).toBe(true);
});
it('should transclude content with same scope', function() {
var el = setup('', '<div class="content"></div>');
expect(el.children().eq(1).hasClass('content')).toBe(true);

View File

@@ -1,4 +1,4 @@
describe('Ionic ScrollDelegate Service', function() {
xdescribe('Ionic ScrollDelegate Service', function() {
var $ionicScrollDelegate, rootScope, compile, timeout, document;
beforeEach(module('ionic'));

View File

@@ -12,8 +12,7 @@
<body>
<div ng-controller="AppCtrl">
<ion-nav-bar animation="nav-title-slide-ios7"
type="bar-positive">
<ion-nav-bar class="nav-title-slide-ios7 bar-positive">
<ion-nav-back-button class="button-icon icon ion-arrow-left-c">
Back
</ion-nav-back-button>
@@ -34,7 +33,7 @@
<button class="button button-icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content has-header="true">
<ion-content class="has-header" padding="true">
<div class="padding">
<button class="button button-block button-positive" ng-click="signIn(user)">
Sign-In
@@ -56,7 +55,7 @@
</script>
<script id="forgot-password.html" type="text/ng-template">
<ion-view title="'Forgot Password'" hide-nav-bar="true">
<ion-view title="Forgot Password" hide-nav-bar="true">
<ion-content has-header="true" padding="true">
<p>This ion-view hides the nav bar using the hideNavBar attribute.</p>
<p>
@@ -102,7 +101,7 @@
<script id="tabs.html" type="text/ng-template">
<ion-tabs tabs-style="tabs-icon-top" tabs-type="tabs-positive">
<ion-tabs class="tabs-icon-top tabs-positive tabs-top">
<ion-tab title="Automobiles" icon="ion-model-s" href="#/tabs/autos">
<ion-nav-view name="auto-nav-view"></ion-nav-view>
@@ -117,8 +116,8 @@
</ion-tab>
<ion-tab title="Info" icon="ion-information-circled">
<ion-view title="'Information'">
<ion-content has-header="true" has-tabs="true" padding="true">
<ion-view title="Information">
<ion-content class="has-header has-subheader" padding="true">
<h3>Information</h3>
<p>
This is a sample seed project for the Ionic Framework. Please change it to match your needs.
@@ -140,8 +139,8 @@
</script>
<script id="auto-list.html" type="text/ng-template">
<ion-view title="'Auto List'">
<ion-content has-header="true" has-tabs="true">
<ion-view title="Auto List">
<ion-content class="has-header has-subheader" padding="true">
<ion-list>
<ion-item ng-repeat="auto in autos" ng-href="#/tabs/autos/{{ $index }}" ion-nav-animation="{{$index === 0 ? 'slide-in-up' : 'slide-left-right'}}">
{{ auto.year }} {{ auto.make }} {{ auto.model }}
@@ -160,12 +159,12 @@
</script>
<script id="auto-detail.html" type="text/ng-template">
<ion-view title="'Auto Details'">
<ion-view title="Auto Details">
<ion-nav-buttons side="left">
<button class="button button-icon icon ion-refresher">
</button>
</ion-nav-buttons>
<ion-content has-header="true" has-tabs="true" padding="true">
<ion-content class="has-header has-subheader" padding="true">
<h2>{{ auto.year }} {{ auto.make }} {{ auto.model }}</h2>
<p ng-bind="auto.desc"></p>
@@ -202,8 +201,8 @@
</script>
<script id="add-auto.html" type="text/ng-template">
<ion-view title="'Add Auto'">
<ion-content has-header="true" has-tabs="true">
<ion-view title="Add Auto">
<ion-content class="has-header has-subheader" padding="true">
<div class="list">
<label class="item item-input">
@@ -232,8 +231,8 @@
</script>
<script id="about.html" type="text/ng-template">
<ion-view title="'About'">
<ion-content has-header="true" has-tabs="true" padding="true">
<ion-view title="About">
<ion-content class="has-header has-subheader" padding="true">
<h3>About this app!</h3>
<p>
Current View: {{ $viewHistory.currentView }}<br>

View File

@@ -118,7 +118,7 @@ function run {
echo "##########################"
# Do sauce unit tests and e2e tests with all browsers (takes longer)
gulp cloudtest
# gulp cloudtest
echo "##########################################"
echo "# Complete! v$VERSION nightly published! #"

View File

@@ -28,42 +28,6 @@
background-size: 0;
line-height: $tabs-height;
&.tabs-light {
@include tab-style($tabs-light-bg, $tabs-light-border, $tabs-light-text);
@include tab-badge-style($tabs-light-text, $tabs-light-bg);
}
&.tabs-stable {
@include tab-style($tabs-stable-bg, $tabs-stable-border, $tabs-stable-text);
@include tab-badge-style($tabs-stable-text, $tabs-stable-bg);
}
&.tabs-positive {
@include tab-style($tabs-positive-bg, $tabs-positive-border, $tabs-positive-text);
@include tab-badge-style($tabs-positive-text, $tabs-positive-bg);
}
&.tabs-calm {
@include tab-style($tabs-calm-bg, $tabs-calm-border, $tabs-calm-text);
@include tab-badge-style($tabs-calm-text, $tabs-calm-bg);
}
&.tabs-assertive {
@include tab-style($tabs-assertive-bg, $tabs-assertive-border, $tabs-assertive-text);
@include tab-badge-style($tabs-assertive-text, $tabs-assertive-bg);
}
&.tabs-balanced {
@include tab-style($tabs-balanced-bg, $tabs-balanced-border, $tabs-balanced-text);
@include tab-badge-style($tabs-balanced-text, $tabs-balanced-bg);
}
&.tabs-energized {
@include tab-style($tabs-energized-bg, $tabs-energized-border, $tabs-energized-text);
@include tab-badge-style($tabs-energized-text, $tabs-energized-bg);
}
&.tabs-royal {
@include tab-style($tabs-royal-bg, $tabs-royal-border, $tabs-royal-text);
@include tab-badge-style($tabs-royal-text, $tabs-royal-bg);
}
&.tabs-dark {
@include tab-style($tabs-dark-bg, $tabs-dark-border, $tabs-dark-text);
@include tab-badge-style($tabs-dark-text, $tabs-dark-bg);
}
@media (min--moz-device-pixel-ratio: 1.5),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
@@ -76,9 +40,58 @@
background-size: 100% 1px;
background-repeat: no-repeat;
}
}
/* Allow parent element of tabs to define color, or just the tab itself */
.tabs-light > .tabs,
.tabs.tabs-light {
@include tab-style($tabs-light-bg, $tabs-light-border, $tabs-light-text);
@include tab-badge-style($tabs-light-text, $tabs-light-bg);
}
.tabs-stable > .tabs,
.tabs.tabs-stable {
@include tab-style($tabs-stable-bg, $tabs-stable-border, $tabs-stable-text);
@include tab-badge-style($tabs-stable-text, $tabs-stable-bg);
}
.tabs-positive > .tabs,
.tabs.tabs-positive {
@include tab-style($tabs-positive-bg, $tabs-positive-border, $tabs-positive-text);
@include tab-badge-style($tabs-positive-text, $tabs-positive-bg);
}
.tabs-calm > .tabs,
.tabs.tabs-calm {
@include tab-style($tabs-calm-bg, $tabs-calm-border, $tabs-calm-text);
@include tab-badge-style($tabs-calm-text, $tabs-calm-bg);
}
.tabs-assertive > .tabs,
.tabs.tabs-assertive {
@include tab-style($tabs-assertive-bg, $tabs-assertive-border, $tabs-assertive-text);
@include tab-badge-style($tabs-assertive-text, $tabs-assertive-bg);
}
.tabs-balanced > .tabs,
.tabs.tabs-balanced {
@include tab-style($tabs-balanced-bg, $tabs-balanced-border, $tabs-balanced-text);
@include tab-badge-style($tabs-balanced-text, $tabs-balanced-bg);
}
.tabs-energized > .tabs,
.tabs.tabs-energized {
@include tab-style($tabs-energized-bg, $tabs-energized-border, $tabs-energized-text);
@include tab-badge-style($tabs-energized-text, $tabs-energized-bg);
}
.tabs-royal > .tabs,
.tabs.tabs-royal {
@include tab-style($tabs-royal-bg, $tabs-royal-border, $tabs-royal-text);
@include tab-badge-style($tabs-royal-text, $tabs-royal-bg);
}
.tabs-dark > .tabs,
.tabs.tabs-dark {
@include tab-style($tabs-dark-bg, $tabs-dark-border, $tabs-dark-text);
@include tab-badge-style($tabs-dark-text, $tabs-dark-bg);
}
.tabs-top {
/* Allow parent element to have tabs-top */
.tabs-top > .tabs,
.tabs.tabs-top {
top: $bar-height;
padding-top: 0;
padding-bottom: 2px;

View File

@@ -88,7 +88,21 @@ describe('SideMenuController', function() {
ctrl.toggleRight();
expect(ctrl.getOpenPercentage()).toEqual(-100);
});
it('should isOpenLeft', function() {
expect(ctrl.isOpenLeft()).toEqual(false);
ctrl.toggleLeft();
expect(ctrl.getOpenPercentage()).toEqual(100);
expect(ctrl.isOpenLeft()).toEqual(true);
});
it('should isOpenRight', function() {
expect(ctrl.isOpenRight()).toEqual(false);
ctrl.toggleRight();
expect(ctrl.getOpenPercentage()).toEqual(-100);
expect(ctrl.isOpenRight()).toEqual(true);
});
// Snap
it('Should snap', function() {
@@ -131,7 +145,7 @@ describe('SideMenuController', function() {
}
});
expect(ctrl.getOpenPercentage()).toEqual(-100);
// Going right, more than half, or quickly (snap open)
ctrl.openPercentage(-51);
ctrl.snapToRest({