Random angular stuff and testing things

This commit is contained in:
Max Lynch
2013-09-04 17:00:29 -05:00
parent 7794ce1a7a
commit 4f7e87bfcc
14 changed files with 2265 additions and 63 deletions

View File

@ -1,12 +0,0 @@
/* used to tie angular.js with the framework */
/* nowhere should the framework reference angular.js */
/* nowhere in angular.js should it reference the framework */
var ionic = angular.module('ionic', ['ngTouch']);
ionic.directive('panel', ['$parse', '$timeout', '$rootElement',
function($parse, $timeout, $rootElement) {
return function(scope, element, attrs) {
};
}
]);

BIN
docs/iphone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -18,10 +18,42 @@
</head> </head>
<body ng-app="ionic.menu"> <body ng-app="ionic.menu">
<ionic-left-right-menu> <ionic-left-right-menu>
<section id="page" class="full-section menu-animated">
<header class="bar bar-header bar-dark">
<div class="buttons">
<a id="left-button" class="button button-dark" href="#">
<i class="icon-reorder"></i>
</a>
</div>
<h1 class="title">Chats</h1>
<div class="buttons">
<button id="right-button" class="button button-dark">
<i class="icon-cog"></i>
</button>
</div>
</header>
</section>
<div class="menu menu-left">
<ul class="list">
<li class="list-divider">Left Nav Things</li>
</ul>
</div>
<div class="menu menu-right">
<ul class="list">
<li class="list-divider">Right Nav Things</li>
</ul>
</div>
<!--
<ionic-menu side="left"> <ionic-menu side="left">
</ionic-menu> </ionic-menu>
<ionic-content>
<h2>ASDF</h2>
<ionic-content>
<ionic-menu side="right"> <ionic-menu side="right">
</ionic-menu> </ionic-menu>
-->
</ionic-left-right-menu> </ionic-left-right-menu>
</body> </body>
</html> </html>

View File

@ -3,25 +3,26 @@ angular.module('ionic.menu', [])
.controller('LeftRightMenuController', ['$scope', '$element', .controller('LeftRightMenuController', ['$scope', '$element',
function LeftRightMenuCtrl($scope, $element) { function LeftRightMenuCtrl($scope, $element) {
var ctrl = ion.controllers.LeftRightMenuViewController; var ctrl = ion.controllers.LeftRightMenuViewController;
$scope.controllerInitData = {};
$scope.initIonicController = function() {
$scope._ionicController = new ctrl($scope.controllerInitData);
};
}]) }])
.directive('ionicLeftRightMenu', function() { .directive('ionicLeftRightMenu', function() {
return { return {
restrict: 'EA', restrict: 'EA',
scope: true,
transclude: true,
controller: 'LeftRightMenuController', controller: 'LeftRightMenuController',
compile: function(elm, attrs, transclude) { link: function($scope, element, attributes) {
return function(scope, element, attrs, menuCtrl) { $scope
console.log('Compile'); console.log('link', $scope);
};
},
link: function(scope) {
console.log('link');
} }
} }
}) })
/*
.directive('ionicMenu', function() { .directive('ionicMenu', function() {
return { return {
restrict: 'EA', restrict: 'EA',
@ -37,3 +38,4 @@ function LeftRightMenuCtrl($scope, $element) {
} }
}); });
*/

9
ext/angular/src/ionicContent.js vendored Normal file
View File

@ -0,0 +1,9 @@
angular.module('ionic.ui.content', {})
.directive('content', function() {
return {
restrict: 'E',
replace: true,
template: '<div class="content"></div>'
}
});

78
ext/angular/src/ionicTabBar.js vendored Normal file
View File

@ -0,0 +1,78 @@
angular.module('ionic.ui.tabbar', {})
.controller('TabBarCtrl', function($scope) {
$scope.selectTab = function(index) {
};
$scope.beforeTabSelect = function(index) {
};
$scope.tabSelected = function(index) {
};
this.getSelectedTabIndex = function() {
return $scope.selectedIndex;
}
this.selectTabAtIndex = function(index) {
$scope.selectedIndex = index;
};
})
.directive('tabBar', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
controller: 'TabBarCtrl',
//templateUrl: 'ext/angular/tmpl/ionicTabBar.tmpl.html',
template: '<div class="full-section"></div>',
}
})
.controller('TabsCtrl', function($scope) {
})
.directive('tabs', function() {
return {
restrict: 'E',
replace: true,
controller: 'TabBarCtrl',
template: '<footer class="bar bar-tabs bar-footer bar-success">' +
'<nav class="tabs">' +
'<ul class="tabs-inner">' +
'<tab-item ng-repeat="tab in tabs">' +
'</tab-item>' +
'</ul>' +
'</nav>' +
'</footer>'
}
})
.directive('tabItem', function() {
return {
restrict: 'E',
replace: true,
controller: 'TabBarCtrl',
scope: {
text: '@',
icon: '@',
tabSelected: '@'
},
link: function(scope, element, attrs, TabBarCtrl) {
// Set a default item text if none is provided
attrs.$observe('text', function(value) {
scope.text = value || 'Item';
});
// Set a default item icon if none is provided
attrs.$observe('icon', function(value) {
scope.icon = value || 'icon-default';
});
},
template: '<li class="tab-item">' +
'<a href="#" ng-click="selectTabItem($index)">' +
'<i class="{{icon}}"></i>' +
'{{text}}' +
'</a></li>'
}
});

View File

@ -0,0 +1,15 @@
describe('Ionic Content directive', function() {
var compile, element, scope;
beforeEach(module('ionic.ui.content'));
beforeEach(inject(function($compile, $rootScope) {
compile = $compile;
scope = $rootScope;
}));
it('Has content class', function() {
element = compile('<content></content>')(scope);
expect(element.hasClass('content')).toBe(true);
});
});

View File

@ -0,0 +1,84 @@
describe('Tab Bar Controller', function() {
var compile, element, scope;
beforeEach(module('ionic.ui.tabbar'));
beforeEach(inject(function($compile, $rootScope, $controller) {
compile = $compile;
scope = $rootScope;
ctrl = $controller('TabBarCtrl', { $scope: scope, $element: null });
}));
it('Select item in controller works', function() {
ctrl.selectTabAtIndex(1);
expect(ctrl.getSelectedTabIndex()).toEqual(1);
});
});
describe('Tab Bar directive', function() {
var compile, element, scope;
beforeEach(module('ionic.ui.tabbar'));
//beforeEach(module('ext/angular/tmpl/ionicTabBar.tmpl.html', 'ext/angular/tmpl/ionicTabs.tmpl.html'));
beforeEach(inject(function($compile, $rootScope) {
compile = $compile;
scope = $rootScope;
}));
it('Has section wrapper class', function() {
element = compile('<tab-bar></tab-bar>')(scope);
expect(element.hasClass('full-section')).toBe(true);
});
});
describe('Tabs directive', function() {
var compile, element, scope;
beforeEach(module('ionic.ui.tabbar'));
beforeEach(inject(function($compile, $rootScope) {
compile = $compile;
scope = $rootScope;
}));
it('Has tab class', function() {
element = compile('<tabs></tabs>')(scope);
expect(element.hasClass('bar-tabs')).toBe(true);
});
it('Has tab children', function() {
scope.tabs = [
{ text: 'Home', icon: 'icon-home' },
{ text: 'Fun', icon: 'icon-fun' },
{ text: 'Beer', icon: 'icon-beer' },
];
element = compile('<tabs></tabs>')(scope);
scope.$digest();
expect(element.find('li').length).toBe(3);
});
});
describe('Tab Item directive', function() {
var compile, element, scope, ctrl;
beforeEach(module('ionic.ui.tabbar'));
beforeEach(inject(function($compile, $rootScope) {
compile = $compile;
scope = $rootScope;
}));
it('Default text works', function() {
element = compile('<tab-item></tab-item>')(scope);
scope.$digest();
expect(element.find('a').text()).toEqual('Item');
});
it('Default icon works', function() {
element = compile('<tab-item></tab-item>')(scope);
scope.$digest();
expect(element.find('i').hasClass('icon-default')).toBeTruthy();
});
})

View File

@ -0,0 +1,2 @@
<div class="full-section">
</div>

View File

@ -0,0 +1,12 @@
<footer class="bar bar-tabs bar-footer bar-success">
<nav id="tab-bar" class="tabs">
<ul class="tabs-inner">
<li class="tab-item" ng-repeat="tab in tabs">
<a href="#">
<i class="{{tab.icon}}"></i>
{{tab.text}}
</a>
</li>
</ul>
</nav>
</footer>

70
ionic.conf.js Normal file
View File

@ -0,0 +1,70 @@
// Karma configuration
// Generated on Wed Sep 04 2013 08:59:26 GMT-0500 (CDT)
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'vendor/angular/1.2.0rc1/*',
'ext/angular/src/**/*.js',
'ext/angular/test/**/*.js',
],
// list of files to exclude
exclude: [
'**/*.swp'
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};

View File

@ -1,42 +0,0 @@
(function(window, document, ion) {
// this file should not be apart of the build
// its just just for testing that the correct
// events are being triggered and at the correct
// times, and so we don't have to hardcode/remove
// console calls throughout the code
ion.on('ready', function(){
console.log('ready');
});
ion.on('initalized', function(){
console.log('initalized');
});
ion.on('pageinit', function(e){
console.log('pageinit:', e.detail);
});
ion.on('pageinitfailed', function(){
console.log('pageinitfailed');
});
ion.on('pageloaded', function(e){
console.log('pageloaded,', e.detail.data.url, ", Title:", e.detail.data.title);
});
ion.on('pagecreate', function(e){
console.log('pagecreate,', e.detail.url);
});
ion.on('pageview', function(){
console.log('pageview');
});
ion.on('pageremove', function(){
console.log('pageremove');
});
})(this, document, ion = ion.FM || {});

1952
vendor/angular/1.2.0rc1/angular-mocks.js vendored Normal file

File diff suppressed because it is too large Load Diff