From c73cc43c21ccb2e89a003d644cfae1f7ba5c739f Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 8 Nov 2013 17:57:04 -0600 Subject: [PATCH] Updated toggle and moved to view inheritance --- dist/js/ionic.js | 63 +++++++++++++++---------------- js/ext/angular/test/slideBox.html | 6 +-- js/ext/angular/test/tabs.html | 2 +- js/ext/angular/test/toggle.html | 9 ++++- js/views/slideBox.js | 46 +++++++++++----------- js/views/toggleView.js | 17 ++++----- test/slideBox.html | 2 +- 7 files changed, 74 insertions(+), 71 deletions(-) diff --git a/dist/js/ionic.js b/dist/js/ionic.js index 93ba911c2c..3b250409bc 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -3465,33 +3465,33 @@ window.ionic = { (function(ionic) { 'use strict'; - ionic.views.SlideBox = function(opts) { - var _this = this; + ionic.views.SlideBox = ionic.views.View.inherit({ + initialize: function(opts) { + var _this = this; - this.el = opts.el; - this.pager = this.el.querySelector('.slide-box-pager'); + this.el = opts.el; + this.pager = this.el.querySelector('.slide-box-pager'); - // The drag threshold is the pixel delta that will trigger a drag (to - // avoid accidental dragging) - this.dragThresholdX = opts.dragThresholdX || 10; - // The velocity threshold is a velocity of drag that indicates a "swipe". This - // number is taken from hammer.js's calculations - this.velocityXThreshold = opts.velocityXThreshold || 0.3; + // The drag threshold is the pixel delta that will trigger a drag (to + // avoid accidental dragging) + this.dragThresholdX = opts.dragThresholdX || 10; + // The velocity threshold is a velocity of drag that indicates a "swipe". This + // number is taken from hammer.js's calculations + this.velocityXThreshold = opts.velocityXThreshold || 0.3; - // Initialize the slide index to the first page and update the pager - this.slideIndex = 0; - this._updatePager(); + // Initialize the slide index to the first page and update the pager + this.slideIndex = 0; + this._updatePager(); - // Listen for drag and release events - window.ionic.onGesture('drag', function(e) { - _this._handleDrag(e); - }, this.el); - window.ionic.onGesture('release', function(e) { - _this._handleEndDrag(e); - }, this.el); - }; + // Listen for drag and release events + window.ionic.onGesture('drag', function(e) { + _this._handleDrag(e); + }, this.el); + window.ionic.onGesture('release', function(e) { + _this._handleEndDrag(e); + }, this.el); + }, - ionic.views.SlideBox.prototype = { /** * Tell the pager to update itself if content is added or * removed. @@ -3780,7 +3780,7 @@ window.ionic = { } }); } - }; + }); })(window.ionic); ; @@ -3989,14 +3989,13 @@ ionic.views.TabBar.prototype = { (function(ionic) { 'use strict'; - ionic.views.Toggle = function(opts) { - this.el = opts.el; - this.checkbox = opts.checkbox; - this.handle = opts.handle; - this.openPercent = -1; - }; - - ionic.views.Toggle.prototype = { + ionic.views.Toggle = ionic.views.View.inherit({ + initialize: function(opts) { + this.el = opts.el; + this.checkbox = opts.checkbox; + this.handle = opts.handle; + this.openPercent = -1; + }, tap: function(e) { this.val( !this.checkbox.checked ); @@ -4047,7 +4046,7 @@ ionic.views.TabBar.prototype = { return this.checkbox.checked; } - }; + }); })(ionic); ; diff --git a/js/ext/angular/test/slideBox.html b/js/ext/angular/test/slideBox.html index 4d55badb3f..e686e13d86 100644 --- a/js/ext/angular/test/slideBox.html +++ b/js/ext/angular/test/slideBox.html @@ -7,9 +7,9 @@ - - - + + +