/* eslint no-alert: 0 */ 'use strict'; // // Here is how to define your module // has dependent on mobile-angular-ui // var app = angular.module('MobileAngularUiExamples', [ 'ngRoute', 'mobile-angular-ui', // touch/drag feature: this is from 'mobile-angular-ui.gestures.js'. // This is intended to provide a flexible, integrated and and // easy to use alternative to other 3rd party libs like hammer.js, with the // final pourpose to integrate gestures into default ui interactions like // opening sidebars, turning switches on/off .. 'mobile-angular-ui.gestures' ]); app.run(function($transform) { window.$transform = $transform; }); // // You can configure ngRoute as always, but to take advantage of SharedState location // feature (i.e. close sidebar on backbutton) you should setup 'reloadOnSearch: false' // in order to avoid unwanted routing. // app.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) { $routeProvider.when('/', {templateUrl: 'http://oa.ahyzxy.cn/m/login/loginform.shtml', params:{},reloadOnSearch: false}); $routeProvider.when('/document/:e_id/:flowid/:offset', {templateUrl: 'http://oa.ahyzxy.cn/m/document/documentread/open.shtml', params:{e_id:"",flowid:"",offset:""},reloadOnSearch: false}); }]); // // `$touch example` // app.directive('toucharea', ['$touch', function($touch) { // Runs during compile return { restrict: 'C', link: function($scope, elem) { $scope.touch = null; $touch.bind(elem, { start: function(touch) { $scope.containerRect = elem[0].getBoundingClientRect(); $scope.touch = touch; $scope.$apply(); }, cancel: function(touch) { $scope.touch = touch; $scope.$apply(); }, move: function(touch) { $scope.touch = touch; $scope.$apply(); }, end: function(touch) { $scope.touch = touch; $scope.$apply(); } }); } }; }]); // // `$drag` example: drag to dismiss // app.directive('dragToDismiss', function($drag, $parse, $timeout) { return { restrict: 'A', compile: function(elem, attrs) { var dismissFn = $parse(attrs.dragToDismiss); return function(scope, elem) { var dismiss = false; $drag.bind(elem, { transform: $drag.TRANSLATE_RIGHT, move: function(drag) { if (drag.distanceX >= drag.rect.width / 4) { dismiss = true; elem.addClass('dismiss'); } else { dismiss = false; elem.removeClass('dismiss'); } }, cancel: function() { elem.removeClass('dismiss'); }, end: function(drag) { if (dismiss) { elem.addClass('dismitted'); $timeout(function() { scope.$apply(function() { dismissFn(scope); }); }, 300); } else { drag.reset(); } } }); }; } }; }); // // Another `$drag` usage example: this is how you could create // a touch enabled "deck of cards" carousel. See `carousel.html` for markup. // app.directive('carousel', function() { return { restrict: 'C', scope: {}, controller: function() { this.itemCount = 0; this.activeItem = null; this.addItem = function() { var newId = this.itemCount++; this.activeItem = this.itemCount === 1 ? newId : this.activeItem; return newId; }; this.next = function() { this.activeItem = this.activeItem || 0; this.activeItem = this.activeItem === this.itemCount - 1 ? 0 : this.activeItem + 1; }; this.prev = function() { this.activeItem = this.activeItem || 0; this.activeItem = this.activeItem === 0 ? this.itemCount - 1 : this.activeItem - 1; }; } }; }); app.directive('carouselItem', function($drag) { return { restrict: 'C', require: '^carousel', scope: {}, transclude: true, template: '
', link: function(scope, elem, attrs, carousel) { scope.carousel = carousel; var id = carousel.addItem(); var zIndex = function() { var res = 0; if (id === carousel.activeItem) { res = 2000; } else if (carousel.activeItem < id) { res = 2000 - (id - carousel.activeItem); } else { res = 2000 - (carousel.itemCount - 1 - carousel.activeItem + id); } return res; }; scope.$watch(function() { return carousel.activeItem; }, function() { elem[0].style.zIndex = zIndex(); }); $drag.bind(elem, { // // This is an example of custom transform function // transform: function(element, transform, touch) { // // use translate both as basis for the new transform: // var t = $drag.TRANSLATE_BOTH(element, transform, touch); // // Add rotation: // var Dx = touch.distanceX; var t0 = touch.startTransform; var sign = Dx < 0 ? -1 : 1; var angle = sign * Math.min((Math.abs(Dx) / 700) * 30, 30); t.rotateZ = angle + (Math.round(t0.rotateZ)); return t; }, move: function(drag) { if (Math.abs(drag.distanceX) >= drag.rect.width / 4) { elem.addClass('dismiss'); } else { elem.removeClass('dismiss'); } }, cancel: function() { elem.removeClass('dismiss'); }, end: function(drag) { elem.removeClass('dismiss'); if (Math.abs(drag.distanceX) >= drag.rect.width / 4) { scope.$apply(function() { carousel.next(); }); } drag.reset(); } }); } }; }); app.directive('dragMe', ['$drag', function($drag) { return { controller: function($scope, $element) { $drag.bind($element, { // // Here you can see how to limit movement // to an element // transform: $drag.TRANSLATE_INSIDE($element.parent()), end: function(drag) { // go back to initial position drag.reset(); } }, { // release touch when movement is outside bounduaries sensitiveArea: $element.parent() } ); } }; }]); // // For this trivial demo we have just a unique MainController // for everything // app.controller('p2paddsave', function ($scope, $http) { $scope.formData={ e_title:"" } $scope.save = function() { formData = $scope.form; }; $scope.submitForm = function($url) { alert($url); var data=$scope.formData; console.log(JSON.stringify(data)); /* $http.post($url, JSON.stringify(data)).success(function($data){ alert($data); });*/ }; }); app.controller('MainController', function($rootScope, $scope,$http,$compile,SharedState) { $rootScope.pagego = function($url) { alert($url); }; $rootScope.getusers = function($e_deptid) { var $url="/m/sysman/infofeed/getuserformultiselect.shtml?scope="+$e_deptid; $http.get($url).success(function (data) { $scope.users = data; }); } ; $scope.p2pdata={ sendsms:0, e_fujian:'' } $scope.lform={ user:"", pass:'' } $rootScope.p2paddsave = function($url) { $http({ method:'post', url:$url, data:$scope.p2pdata, headers: {'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var str = []; for (var s in obj) {str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));} return str.join("&"); } }).success(function(data){ alert(data.msg); }); /*$http.post($url, JSON.stringify($scope.p2pdata)).success(function($data){ alert($data); });*/ } ; $scope.uploadfj = function($url,$fjfield,$fjlist) { var fd = new FormData(); var file = document.querySelector('input[type=file]').files[0]; fd.append('fujianfeed', file); $http({ method:'POST', url:$url, data: fd, headers: {'Content-Type':undefined}, transformRequest: angular.identity }) .success( function ( data ) { if(data.success=="success") { var template = angular.element('

'+data.filename+'

'); angular.element("#"+$fjlist).append($compile(template)($scope)); if($scope.p2pdata.e_fujian=="") $scope.p2pdata.e_fujian=data.fileid; else $scope.p2pdata.e_fujian=$scope.p2pdata.e_fujian+data.fileid; /*if($("#"+$fjfield).val()=="") $("#"+$fjfield).val(data.fileid); else $("#"+$fjfield).val($("#"+$fjfield).val()+","+data.fileid);*/ $rootScope.Ui.turnOff('mymodal'); } else { alert(data.msg); } }); }; $scope.swiped = function(direction) { alert('Swiped ' + direction); }; // User agent displayed in home page $scope.userAgent = navigator.userAgent; // Needed for the loading screen $rootScope.$on('$routeChangeStart', function() { $rootScope.loading = true; }); $rootScope.$on('$routeChangeSuccess', function() { $rootScope.loading = false; }); // Fake text i used here and there. $scope.lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. ' + 'Vel explicabo, aliquid eaque soluta nihil eligendi adipisci error, illum ' + 'corrupti nam fuga omnis quod quaerat mollitia expedita impedit dolores ipsam. Obcaecati.'; // // 'Scroll' screen // var scrollItems = []; for (var i = 1; i <= 100; i++) { scrollItems.push('Item ' + i); } $scope.scrollItems = scrollItems; $scope.bottomReached = function() { alert('Congrats you scrolled to the end of the list!'); }; // // Right Sidebar // $scope.chatUsers = [ {name: 'Carlos Flowers', online: true}, {name: 'Byron Taylor', online: true}, {name: 'Jana Terry', online: true}, {name: 'Darryl Stone', online: true}, {name: 'Fannie Carlson', online: true}, {name: 'Holly Nguyen', online: true}, {name: 'Bill Chavez', online: true}, {name: 'Veronica Maxwell', online: true}, {name: 'Jessica Webster', online: true}, {name: 'Jackie Barton', online: true}, {name: 'Crystal Drake', online: false}, {name: 'Milton Dean', online: false}, {name: 'Joann Johnston', online: false}, {name: 'Cora Vaughn', online: false}, {name: 'Nina Briggs', online: false}, {name: 'Casey Turner', online: false}, {name: 'Jimmie Wilson', online: false}, {name: 'Nathaniel Steele', online: false}, {name: 'Aubrey Cole', online: false}, {name: 'Donnie Summers', online: false}, {name: 'Kate Myers', online: false}, {name: 'Priscilla Hawkins', online: false}, {name: 'Joe Barker', online: false}, {name: 'Lee Norman', online: false}, {name: 'Ebony Rice', online: false} ]; // // 'Forms' screen // $scope.sendsms = true; $scope.email = 'me@example.com'; $scope.login= function($url) { $http({ method:'post', url:$url, data:$scope.lform, headers: {'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function(obj) { var str = []; for (var s in obj) {str.push(encodeURIComponent(s) + "=" + encodeURIComponent(obj[s]));} return str.join("&"); } }).success(function(data){ if(data.success=="success") location.href="/m/"; else alert(data.message); }); }; // // 'Drag' screen // $scope.notices = []; for (var j = 0; j < 10; j++) { $scope.notices.push({icon: 'envelope', message: 'Notice ' + (j + 1)}); } $scope.deleteNotice = function(notice) { var index = $scope.notices.indexOf(notice); if (index > -1) { $scope.notices.splice(index, 1); } }; });