Progress on #37

This commit is contained in:
Max Lynch
2013-10-15 14:33:34 -05:00
parent bb2ec72053
commit 6ac2cd3797
32 changed files with 250 additions and 143 deletions

View File

@ -22,7 +22,7 @@ ionic.controllers.NavController = function(opts) {
// TODO: Is this the best way?
this.navBar.shouldGoBack = function() {
_this.pop();
}
};
};
ionic.controllers.NavController.prototype = {

View File

@ -1,5 +1,6 @@
(function(ionic) {
'use strict';
/**
* The SideMenuController is a controller with a left and/or right menu that
* can be slid out and toggled. Seen on many an app.
@ -179,11 +180,11 @@
// what the drag velocity is
var ratio = this.getOpenRatio();
if(ratio == 0)
if(ratio === 0)
return;
var velocityThreshold = 0.3;
var velocityX = e.gesture.velocityX
var velocityX = e.gesture.velocityX;
var direction = e.gesture.direction;
// Less than half, going left
@ -250,7 +251,7 @@
if(!this._isDragging && Math.abs(this._lastX - this._startX) > this.dragThresholdX) {
// if the difference is greater than threshold, start dragging using the current
// point as the starting point
this._startX = this._lastX
this._startX = this._lastX;
this._isDragging = true;
// Initialize dragging

View File

@ -1,4 +1,5 @@
(function(ionic) {
'use strict';
ionic.controllers.TabBarController = function(options) {
this.tabBar = options.tabBar;
@ -117,6 +118,6 @@ ionic.controllers.TabBarController.prototype = {
this._clearSelected();
this.selectController(0);
},
}
};
})(window.ionic);

View File

@ -1,3 +1,6 @@
(function() {
'use strict';
angular.module('ionic.ui.actionSheet', [])
.directive('actionSheet', function() {
@ -22,5 +25,7 @@ angular.module('ionic.ui.actionSheet', [])
'<button class="button" ng-click="cancel()">{{cancelText}}</button>' +
'</div>' +
'</div>'
}
};
});
})();

View File

@ -1,3 +1,6 @@
(function() {
'use strict';
angular.module('ionic.ui.checkbox', [])
@ -36,5 +39,7 @@ angular.module('ionic.ui.checkbox', [])
$scope.checkbox.val(ngModel.$viewValue);
};
}
}
})
};
});
})();

View File

@ -1,3 +1,6 @@
(function() {
'use strict';
angular.module('ionic.ui.content', [])
// The content directive is a core scrollable content area
@ -24,7 +27,8 @@ angular.module('ionic.ui.content', [])
c.addClass('has-tabs');
}
c.append(transclude($scope));
}
};
}
}
})
};
});
})();

View File

@ -1,3 +1,6 @@
(function() {
'use strict';
angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
.directive('listItem', function() {
@ -6,7 +9,6 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
require: '^list',
replace: true,
transclude: true,
scope: true,
scope: {
item: '=',
onSelect: '&',
@ -42,7 +44,7 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
$scope.isEditing = v;
});
}
}
};
})
.directive('list', function() {
@ -78,7 +80,9 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
if(attr.animation) {
$element.addClass(attr.animation);
}
}
};
}
}
})
};
});
})();

View File

@ -1,3 +1,6 @@
(function() {
'use strict';
angular.module('ionic.ui.nav', ['ionic.service'])
.controller('NavCtrl', ['$scope', '$element', '$compile', 'TemplateLoader', function($scope, $element, $compile, TemplateLoader) {
@ -16,7 +19,7 @@ angular.module('ionic.ui.nav', ['ionic.service'])
$element.append(cloned);
});
});
}
};
ionic.controllers.NavController.call(this, {
content: {
@ -53,7 +56,7 @@ angular.module('ionic.ui.nav', ['ionic.service'])
controller: 'NavCtrl',
//templateUrl: 'ext/angular/tmpl/ionicTabBar.tmpl.html',
template: '<div class="view" ng-transclude></div>',
}
};
})
.directive('navBar', function() {
@ -70,9 +73,9 @@ angular.module('ionic.ui.nav', ['ionic.service'])
scope.navController = navCtrl;
scope.goBack = function() {
navCtrl.pop();
}
};
}
}
};
})
.directive('navContent', function() {
@ -101,5 +104,7 @@ angular.module('ionic.ui.nav', ['ionic.service'])
}
});
}
}
};
});
})();

View File

@ -1,5 +1,19 @@
angular.module('ionic.ui.sideMenu', [])
(function() {
'use strict';
/**
* @description
* The sideMenuCtrl lets you quickly have a draggable side
* left and/or right menu, which a center content area.
*/
angular.module('ionic.ui.sideMenu', ['ionic.service.gesture'])
/**
* The internal controller for the side menu controller. This
* extends our core Ionic side menu controller and exposes
* some side menu stuff on the current scope.
*/
.controller('SideMenuCtrl', function($scope) {
var _this = this;
@ -35,21 +49,22 @@ angular.module('ionic.ui.sideMenu', [])
return {
restrict: 'CA',
controller: 'SideMenuCtrl',
}
};
})
.directive('sideMenuContent', function() {
.directive('sideMenuContent', ['Gesture', function(Gesture) {
return {
restrict: 'CA',
require: '^sideMenuCtrl',
scope: true,
compile: function(element, attr, transclude) {
return function($scope, $element, $attr, sideMenuCtrl) {
window.ionic.onGesture('drag', function(e) {
Gesture.on('drag', function(e) {
sideMenuCtrl._handleDrag(e);
}, $element[0]);
window.ionic.onGesture('release', function(e) {
Gesture.on('release', function(e) {
sideMenuCtrl._endDrag(e);
}, $element[0]);
@ -76,8 +91,8 @@ angular.module('ionic.ui.sideMenu', [])
});
};
}
}
})
};
}])
.directive('menu', function() {
@ -100,5 +115,6 @@ angular.module('ionic.ui.sideMenu', [])
$element.append(transclude($scope));
};
}
}
})
};
});
})();

View File

@ -38,7 +38,7 @@ angular.module('ionic.ui.tabs', [])
return function($scope, $element, $attr) {
};
}
}
};
})
// Generic controller directive
@ -63,7 +63,7 @@ angular.module('ionic.ui.tabs', [])
scope.iconOff = attrs.iconOff;
tabsCtrl.addController(scope);
}
}
};
})
@ -77,7 +77,7 @@ angular.module('ionic.ui.tabs', [])
template: '<div class="tabs tabs-primary">' +
'<tab-item title="{{controller.title}}" icon="{{controller.icon}}" icon-on="{{controller.iconOn}}" icon-off="{{controller.iconOff}}" active="controller.isVisible" index="$index" ng-repeat="controller in controllers"></tab-item>' +
'</div>'
}
};
})
.directive('tabItem', function() {
@ -105,5 +105,5 @@ angular.module('ionic.ui.tabs', [])
'<i class="{{iconOn}}" ng-if="active"></i>' +
'<i class="{{iconOff}}" ng-if="!active"></i> {{title}}' +
'</a>'
}
};
});

View File

@ -44,5 +44,5 @@ angular.module('ionic.ui.toggle', [])
$scope.toggle.val(ngModel.$viewValue);
};
}
}
})
};
});

View File

@ -19,7 +19,7 @@ angular.module('ionic.service.actionSheet', ['ionic.service', 'ionic.ui.actionSh
scope.sheet.hide();
//scope.$destroy();
opts.cancel();
}
};
scope.buttonClicked = function(index) {
// Check if the button click event returned true, which means
@ -37,17 +37,17 @@ angular.module('ionic.service.actionSheet', ['ionic.service', 'ionic.ui.actionSh
scope.sheet.hide();
//scope.$destroy();
}
}
};
// Compile the template
var element = $compile('<action-sheet buttons="buttons"></action-sheet>')(scope);
var scope = element.scope();
var s = element.scope();
$document[0].body.appendChild(element[0]);
var sheet = new ionic.views.ActionSheet({el: element[0] });
scope.sheet = sheet;
s.sheet = sheet;
sheet.show();

View File

@ -0,0 +1,9 @@
angular.module('ionic.service.gesture', [])
.factory('Gesture', [function() {
return {
on: function(eventType, cb, element) {
return window.ionic.onGesture(eventType, cb, element);
}
};
}]);

View File

@ -11,5 +11,5 @@ angular.module('ionic.service', [])
return deferred.promise;
}
}
};
}]);

View File

@ -91,4 +91,4 @@ describe('Tab Item directive', function() {
a.click();
expect(scope.selectTab).toHaveBeenCalled();
});
})
});

View File

@ -9,30 +9,32 @@
}
return ret;
}
}
};
if (window.jQuery) {
// if jQuery is present then it should be the default
jq = window.jQuery;
var fnExtended = function() {
var
x,
ret; // if incase this isn't an ionic component
for(x = 0; x < this.length; x++) {
ionic.component( this[x] );
if( this[x].component ) {
ret = this[x].component[name].apply(this[x].component, arguments);
}
}
// if this isn't an ionic component, run the usual jQuery fn
return jQueryFn.apply(this, arguments);
};
// extend the methods which are in ionic.fn and in jQuery.fn
for(var name in ionic.fn) {
var jQueryFn = jq.fn[name];
jq.fn[name] = function() {
var
x,
ret; // if incase this isn't an ionic component
for(x = 0; x < this.length; x++) {
ionic.component( this[x] );
if( this[x].component ) {
ret = this[x].component[name].apply(this[x].component, arguments);
}
}
// if this isn't an ionic component, run the usual jQuery fn
return jQueryFn.apply(this, arguments);
}
jq.fn[name] = fnExtended;
}
} else {
@ -56,7 +58,7 @@
$ = function(selector, context) {
return jq.init(selector, context);
}
};
}
})(this, document, ionic);

View File

@ -30,5 +30,5 @@
}
return null;
}
}
};
})(window.ionic);

View File

@ -97,11 +97,11 @@
// Map some convenient top-level functions for event handling
ionic.on = function() { ionic.EventController.on.apply(ionic.EventController, arguments); }
ionic.off = function() { ionic.EventController.off.apply(ionic.EventController, arguments); }
ionic.trigger = function() { ionic.EventController.trigger.apply(ionic.EventController.trigger, arguments); }
ionic.onGesture = function() { ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); }
ionic.offGesture = function() { ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); }
ionic.on = function() { ionic.EventController.on.apply(ionic.EventController, arguments); };
ionic.off = function() { ionic.EventController.off.apply(ionic.EventController, arguments); };
ionic.trigger = function() { ionic.EventController.trigger.apply(ionic.EventController.trigger, arguments); };
ionic.onGesture = function() { ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
ionic.offGesture = function() { ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
// DISABLING FOR NOW. THE TAP CODE AT THE EXT LEVEL SHOULD BE DOING THIS
// Set up various listeners

View File

@ -33,7 +33,7 @@
}
return parseFloat(window.device.version) >= 7.0;
}
}
};
ionic.Platform.detect();
})(window.ionic);

View File

@ -18,9 +18,9 @@
// if the source event wasn't from a touch event then don't use this polyfill
if(!e.gesture || e.gesture.pointerType !== "touch" || !e.gesture.srcEvent) return;
var
e = e.gesture.srcEvent, // evaluate the actual source event, not the created event by gestures.js
ele = e.target;
e = e.gesture.srcEvent; // evaluate the actual source event, not the created event by gestures.js
var ele = e.target;
while(ele) {
if( ele.tagName === "INPUT" || ele.tagName === "TEXTAREA" || ele.tagName === "SELECT" ) {

View File

@ -18,5 +18,5 @@
}
return dest;
},
}
};
})(window.ionic);

View File

@ -7,7 +7,7 @@
},
end: function(e) {
}
}
};
var SlideDrag = function(opts) {
this.dragThresholdX = opts.dragThresholdX || 10;
@ -117,7 +117,7 @@
content.classList.remove('list-item-sliding');
}
e.target.removeEventListener('webkitTransitionEnd', onRestingAnimationEnd);
}
};
window.requestAnimationFrame(function() {
var currentX = parseFloat(_this._currentDrag.content.style.webkitTransform.replace('translate3d(', '').split(',')[0]) || 0;
@ -134,12 +134,13 @@
// We are done, notify caller
doneCallback && doneCallback();
});
}
};
var ReorderDrag = function(opts) {
this.dragThresholdY = opts.dragThresholdY || 0;
this.el = opts.el;
};
ReorderDrag.prototype = new DragOp();
ReorderDrag.prototype.start = function(e) {

View File

@ -1,4 +1,3 @@
(function(ionic) {
ionic.views.NavBar = function(opts) {
@ -38,7 +37,7 @@
this._currentBackButton = back;
this._currentBackButton.onclick = function(event) {
_this.shouldGoBack && _this.shouldGoBack();
}
};
}
if(shouldShow && !this._currentBackButton.parentNode) {