I have used angular-file-upload to upload files, files are uploading everything working fine.
Now, I have to add restriction that user can not able to upload more
then 5 pictures and at one shot single file should upload How is it possible,
Below is my code
Controller
'use strict';
angular.module('Modulename')
.controller('AppController', ['$scope', 'FileUploader', function($scope, FileUploader) {
var uploader = $scope.uploader = new FileUploader({
url: site_url+'upload.php'
});
// FILTERS
uploader.filters.push({
name: 'imageFilter',
fn: function(item /*{File|FileLikeObject}*/, options) {
var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
}
});
// CALLBACKS
uploader.onWhenAddingFileFailed = function(item /*{File|FileLikeObject}*/, filter, options) {
console.info('onWhenAddingFileFailed', item, filter, options);
};
uploader.onAfterAddingFile = function(fileItem) {
console.info('onAfterAddingFile', fileItem);
// fileItem.upload();
};
uploader.onAfterAddingAll = function(addedFileItems) {
console.info('onAfterAddingAll', addedFileItems);
};
uploader.onBeforeUploadItem = function(item) {
console.info('onBeforeUploadItem', item);
};
uploader.onProgressItem = function(fileItem, progress) {
console.info('onProgressItem', fileItem, progress);
};
uploader.onProgressAll = function(progress) {
console.info('onProgressAll', progress);
};
uploader.onSuccessItem = function(fileItem, response, status, headers) {
console.info('onSuccessItem', fileItem, response, status, headers);
};
uploader.onErrorItem = function(fileItem, response, status, headers) {
console.info('onErrorItem', fileItem, response, status, headers);
};
uploader.onCancelItem = function(fileItem, response, status, headers) {
console.info('onCancelItem', fileItem, response, status, headers);
};
uploader.onCompleteItem = function(fileItem, response, status, headers) {
console.info('onCompleteItem', fileItem, response, status, headers);
};
uploader.onCompleteAll = function() {
console.info('onCompleteAll');
};
console.info('uploader', uploader);
}]);
View section
<section ng-switch-when="1" class="form-section {{animationClass}} wow" ng-class="{{animationClass}}" ng-controller ="AppController" nv-file-drop="" uploader="uploader">
<div class="form-section-block">
<h3 class="heading text-center">Upload photos</h3>
<!-- Upload demo area -->
<style>
.my-drop-zone { border: dotted 3px lightgray; }
.nv-file-over { border: dotted 3px red; } /* Default class applied to drop zones on over */
.another-file-over-class { border: dotted 3px green; }
html, body { height: 100%; }
canvas {
background-color: #f3f3f3;
-webkit-box-shadow: 3px 3px 3px 0 #e3e3e3;
-moz-box-shadow: 3px 3px 3px 0 #e3e3e3;
box-shadow: 3px 3px 3px 0 #e3e3e3;
border: 1px solid #c3c3c3;
height: 100px;
margin: 6px 0 0 6px;
}
</style>
<div class="row">
<div class="col-md-3">
<h3>Select files</h3>
<div ng-show="uploader.isHTML5">
<!-- 3. nv-file-over uploader="link" over-class="className" -->
<div class="well my-drop-zone" nv-file-over="" uploader="uploader" options="{autoUpload :'true'}">
Base drop zone
<input type="file" nv-file-select="" uploader="uploader" multiple />
</div>
</div>
</div>
<div class="col-md-9" style="margin-bottom: 40px">
<table class="table">
<thead>
<tr>
<th width="50%">Name</th>
<th ng-show="uploader.isHTML5">Size</th>
<th ng-show="uploader.isHTML5">Progress</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in uploader.queue">
<td>
<strong>{{ item.file.name }}</strong>
<!-- Image preview -->
<!--auto height-->
<!--<div ng-thumb="{ file: item.file, width: 100 }"></div>-->
<!--auto width-->
<div ng-show="uploader.isHTML5" ng-thumb="{ file: item._file, height: 100 }"></div>
<!--fixed width and height -->
<!--<div ng-thumb="{ file: item.file, width: 100, height: 100 }"></div>-->
</td>
<td ng-show="uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
<td ng-show="uploader.isHTML5">
<div class="progress" style="margin-bottom: 0;">
<div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div>
</div>
</td>
<td class="text-center">
<span ng-show="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span>
<span ng-show="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span>
<span ng-show="item.isError"><i class="glyphicon glyphicon-remove"></i></span>
</td>
<td nowrap>
<button type="button" class="btn btn-success btn-xs" ng-click="item.upload()" ng-disabled="item.isReady || item.isUploading || item.isSuccess">
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
<button type="button" class="btn btn-warning btn-xs" ng-click="item.cancel()" ng-disabled="!item.isUploading">
<span class="glyphicon glyphicon-ban-circle"></span> Cancel
</button>
<button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
<span class="glyphicon glyphicon-trash"></span> Remove
</button>
</td>
</tr>
</tbody>
</table>
<div>
<div>
Queue progress:
<div class="progress" style="">
<div class="progress-bar" role="progressbar" ng-style="{ 'width': uploader.progress + '%' }"></div>
</div>
</div>
<button type="button" class="btn btn-success btn-s" ng-click="uploader.uploadAll()" ng-disabled="!uploader.getNotUploadedItems().length">
<span class="glyphicon glyphicon-upload"></span> Upload all
</button>
<button type="button" class="btn btn-warning btn-s" ng-click="uploader.cancelAll()" ng-disabled="!uploader.isUploading">
<span class="glyphicon glyphicon-ban-circle"></span> Cancel all
</button>
<button type="button" class="btn btn-danger btn-s" ng-click="uploader.clearQueue()" ng-disabled="!uploader.queue.length">
<span class="glyphicon glyphicon-trash"></span> Remove all
</button>
</div>
</div>
</div>
<!-- Upload demo area -->
<div class="col-md-4 col-sm-4 label-block"></div>
<div class="col-md-6 col-sm-8 signup-full-column">
<div class="stepToggle-btn">
<span class="">
<i class="fa fa-angle-up" aria-hidden="true"></i>
</span>
<button type="submit" class="btn btn-success down" data-toggle="tooltip" tooltip-placement="top" uib-tooltip="Next Step" ><i class="fa fa-angle-down" aria-hidden="true"></i>
</button>
</div>
</div>
<div class="clearfix"></div>
</div>
</section>
You can use the queue limit filter for this
var uploader = new FileUploader({
queueLimit: 1
});
<element nv-file-drop filters="queueLimit"></element>
I build my page with angularJS. When I test it every thing works well,
but sometimes the page flickers.
Here is a sample when I click M1 > Sub-Menu-Item, I see the page flicker.
Can anybody help me, please?
My ngRoute:
'use strict';
angular.module('ssdWebClientApp.Routes', [])
.config(['$routeProvider',
function($routeProvider) {
$routeProvider
.when('/m1/', {
templateUrl: '/views/m1/m1_list.html',
controller: 'M1'
})
...
.otherwise({
redirectTo: '/main'
});
}
]);
My Modules Main.js that enable pushState Featrue:
var App = angular.module('ssdWebClientApp', [
'ngGrid',
'ngCookies',
'ngResource',
'ngRoute',
'ngAnimate',
'angular.filter',
'ssdWebClientApp.Controllers',
'ssdWebClientApp.Routes',
'ssdWebClientApp.Services',
'ssdWebClientApp.Directives'
])
...
.config(function($interpolateProvider, $locationProvider, $httpProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$locationProvider.hashPrefix = '!';
$httpProvider.defaults.timeout = 300;
})
...
My Sub Module Script for M1:
'use strict';
angular.module('ssdWebClientApp.Controllers')
//s064
.controller('M1', ['$rootScope', '$scope', '$http', '$location', '$cookies', '$routeParams', '$filter', 'empty', 'm1',
function($rootScope, $scope, $http, $location, $cookies, $routeParams, $filter, empty, m1) {
console.debug('m1 init.');
$http.defaults.headers.common['X-CSRFToken'] = $cookies.csrftoken;
//
var params = {};
var sortingBy = ' +' || ' -';
var inquery_has_been_clicked = false;
//
$scope.inquery = function(reset){
$scope.hide_grid = false;
if(reset){
$scope.form.offset = 0;
params.downloadOrderId = $scope.form.downloadOrderId;
params.homeSIMMSISDN = $scope.form.homeSIMMSISDN;
params.iccid = $scope.form.iccid;
params.msisdn = $scope.form.msisdn;
params.limit = $scope.form.limit;
params.offset = $scope.form.offset;
}
else{
params.offset = $scope.form.offset;
if(!params.limit){
params.limit = $scope.form.limit;
}
}
// clean data for java server....lol
if(!params.downloadOrderId) delete params.downloadOrderId;
if(!params.homeSIMMSISDN) delete params.homeSIMMSISDN;
if(!params.iccid) delete params.iccid;
if(!params.msisdn) delete params.msisdn;
$scope.ajaxing = true;
m1.m1_downloaded_sim_list(params, function(data, status){
if (data.status != 200) {
$rootScope.go_error(status, data.error || data.message || data.error_message || data.msg);
$scope.customers = [];
$scope.total = [];
$scope.ajaxing = false;
return;
};
$scope.customers = data.objects;
$scope.customers.every(function(row){
row.origin_status = row.status;
return true;
});
$scope.total = data.meta.total_count;
$scope.ajaxing = false;
}, function(data, status){
$rootScope.go_error(status, data.error || data.message || data.error_message || data.msg);
$scope.ajaxing = false;
});
};
//
$scope.inquery_clicked = function(reset){
var input_params = [$scope.form.downloadOrderId, $scope.form.homeSIMMSISDN, $scope.form.iccid, $scope.form.msisdn];
var not_empty_count = 0;
for(var i = 0; i < input_params.length; i++){
if(input_params[i]){
not_empty_count += 1;
}
};
if(not_empty_count >= 2){
alert('Please keep only one input');
return;
};
if($scope.form.downloadOrderId || $scope.form.homeSIMMSISDN || $scope.form.iccid || $scope.form.msisdn){
$scope.inquery(reset);
inquery_has_been_clicked = true;
}
else{
alert('No input found.');
}
};
//
$scope.show_m1_iccid = function(item){
// console.log(item);
var url = item.iccidImage || '';
// url = CONFIG.file_path + url;
$('#m1_iccid_bar_code')
.modal('show')
.find('.bar_code')
.attr('src', url);
};
//
$scope.show_m1_msisdn = function(item){
// console.log(item);
var url = item.msisdnImage || '';
// url = CONFIG.file_path + url;
$('#m1_msisdn_bar_code')
.modal('show')
.find('.bar_code')
.attr('src', url);
};
//
$scope.input_security_code = function(item){
$scope.securityCode = '';
$scope.prepare_update_record = item;
$('#input_security_code').modal('show');
};
//
$scope.update = function(securityCode){
if(!securityCode){
alert("Please input security code.");
return;
}
var post_data = {
imsi: $scope.prepare_update_record.imsi,
homeSIMMSISDN: $scope.prepare_update_record.homeSIMMSISDN,
securityCode: securityCode,
status: $scope.prepare_update_record.status,
};
m1.m1_downloaded_sim_update(post_data, function(data, status){
if (data.status != 200) {
$rootScope.go_error(status, data.error || data.message || data.error_message || data.msg);
return;
}
alert('Update Success!');
$('#input_security_code button[data-dismiss=modal]').click();
$scope.inquery(false);
}, function(data, status){
$rootScope.go_error(status, data.error || data.message || data.error_message || data.msg);
});
};
//
$scope.sorting = function(field){
if($scope.customers && $scope.customers.length > 0){
$scope.customers.sort(function(first ,next){
if(sortingBy == ' +'){
return first[field] > next[field];
}
else{
return first[field] < next[field];
}
})
}
$('th[field] span.sortingBy').empty();
$('th[field=' + field + '] span.sortingBy').text(sortingBy);
if(sortingBy == ' +'){
sortingBy = ' -';
}
else{
sortingBy = ' +';
}
};
//
$scope.hide_grid = true;
$scope.ajaxing = false;
$scope.prepare_update_record = null;
$scope.form = {};
$scope.form.downloadOrderId = $routeParams.downloadOrderId || '';
$scope.form.homeSIMMSISDN = $routeParams.homeSIMMSISDN || '';
$scope.form.iccid = $routeParams.iccid || '';
$scope.form.msisdn = $routeParams.msisdn || '';
$scope.form.limit = $routeParams.limit || 12;
$scope.form.offset = $routeParams.offset || 0;
$scope.total = 0;
$scope.customers = [];
$scope.statusList = [];
$scope.query_string = $scope.form;
$scope.securityCode = '1';
//
m1.m1_downloaded_sim_status_list(function(data, status){
if(status != 200){
$rootScope.go_error(status, data.error || data.message || data.error_message || data.msg);
return;
}
$scope.statusList = data.statusList;
}, function(data, status){
$rootScope.go_error(status, data.error || data.message || data.error_message || data.msg);
});
//
$scope.$watch('form.offset', function(new_value, old_value){
if(inquery_has_been_clicked){
$scope.inquery();
};
}, true);
}
]);
My M1 Feature's View:
<div class="container r ssd-platform" style="width: 1300px; min-width: 1300px;">
<h3 style="text-align: center;">Inquire M1 SIM</h3>
<br>
<form role="form" class="form-inline m1">
<div class="row">
<div class="col-md-4 col-voucher">
<div class="input-group" style="width: 100%;">
<div class="input-group-addon m1_control_panel_label" style="font-size: 10pt;">Voucher No:</div>
<input class="form-control" type="text" ng-model="form.downloadOrderId" maxlength="24">
</div>
</div>
<div class="col-md-4 col-homesimmsisdn">
<div class="input-group" style="width: 100%;">
<div class="input-group-addon m1_control_panel_label" style="font-size: 10pt;">Home SIM MSISDN:</div>
<input class="form-control" type="text" ng-model="form.homeSIMMSISDN" maxlength="16">
</div>
</div>
<div class="col-md-4 col-m1iccid">
<div class="input-group" style="width: 100%;">
<div class="input-group-addon m1_control_panel_label" style="font-size: 10pt;">M1 ICCID:</div>
<input class="form-control" type="text" ng-model="form.iccid" maxlength="20">
</div>
</div>
<div class="col-md-4 m1-msisdn">
<div class="input-group" style="width: 100%;">
<div class="input-group-addon m1_control_panel_label" style="font-size: 10pt;">M1 MSISDN:</div>
<input class="form-control" type="text" ng-model="form.msisdn" maxlength="16">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 input-group m1-query-btn pull-right" style="margin-top: 5px;">
<button type="button" class="btn btn-info btn-lg" style="border-radius: 5px; width: 100%; height: 40px; border-radius: 0px; height: 38px;" ng-click="inquery_clicked(true);">Inquery</button>
</div>
</div>
</form>
<div ng-hide="create_paginator(total, form.limit, form.offset).length <= 0" style="position: relative;">
<ul class="pagination" style="margin: 0px; float: left;" ng-show="create_paginator(total, form.limit, form.offset).length > 0">
<li><a href ng-click="prev(form);">«</a></li>
<li ng-repeat="num in create_paginator(total, form.limit, form.offset)" ng-class="{true: 'active', false: ''}[form.offset/form.limit+1 == num]">
<a href ng-click="page(form, num)">{{num}}</a>
</li>
<li><a href ng-click="next(form, total)">»</a></li>
</ul>
</div>
<hr>
<br />
<table class="table table-bordered no-border-width top-spa" style="width: 100%;">
<tr>
<th field="downloadOrderId" style="cursor: pointer; width: 243px;" ng-click="sorting('downloadOrderId')">
Voucher No
<span class="sortingBy"></span>
</th>
<th field="homeSIMMSISDN" style="cursor: pointer; width: 178px;" ng-click="sorting('homeSIMMSISDN')">
Home SIM MSISDN
<span class="sortingBy"></span>
</th>
<th field="iccid" style="cursor: pointer; width: 190px;" ng-click="sorting('iccid')">
M1 ICCID
<span class="sortingBy"></span>
</th>
<th field="imsi" style="cursor: pointer; width: 200px;" ng-click="sorting('imsi')">
M1 IMSI
<span class="sortingBy"></span>
</th>
<th field="msisdn" style="cursor: pointer; width: 200px;" ng-click="sorting('msisdn')">
M1 MSISDN
<span class="sortingBy"></span>
</th>
<th field="status" style="cursor: pointer; width: 135px;" ng-click="sorting('status')">
Status
<span class="sortingBy"></span>
</th>
<th style="width: 108px;">
Action
</th>
</tr>
<tr ng-repeat="item in customers" ng-if="customers.length > 0 && ajaxing == false && !hide_grid">
<td style="text-align: center;">{{ item.downloadOrderId }}</td>
<td style="text-align: left;">{{ item.homeSIMMSISDN }}</td>
<td style="text-align: center;">
<a ng-click="show_m1_iccid(item);">
{{ item.iccid }}
</a>
</td>
<td style="text-align: center;">{{ item.imsi }}</td>
<td style="text-align: center;">
<a ng-click="show_m1_msisdn(item);">
{{ item.msisdn }}
</a>
</td>
<td style="text-align: center;">
<select class="form-control" ng-model="item.status" style="padding: 0px; width: 110px!important;" ng-disabled="item.origin_status == 'Reject' || item.origin_status == 'Collected'">
<option ng-repeat="status in statusList" value="{{ status }}" ng-selected="item.status == status">{{ status }}</option>
</select>
</td>
<td style="text-align: center;">
<button
type="button"
class="btn btn-default btn-lg"
style="border-radius: 0px; width: 100%; height: 25px; padding: 0px;"
ng-click="input_security_code(item)"
ng-disabled="item.status == 'Booking' || item.origin_status == 'Reject' || item.origin_status == 'Collected'">
Update
</button>
</td>
</tr>
<tr ng-show="customers.length == 0 && ajaxing == false && !hide_grid">
<td colspan="7">
<div style="width: 100%; background-color: transparent; text-align: center; color: red;">
No Data Found.
</div>
</td>
</tr>
<tr ng-show="ajaxing == true && !hide_grid">
<td colspan="7">
<div class="ajaxing-min" style="min-height: 30px; width: 100%;"></div>
</td>
</tr>
</table>
<!-- Modal -->
<div class="modal fade" id="m1_iccid_bar_code" style="z-index:9999;">
<div class="modal-dialog" style="width: 800px; margin-top: 200px;">
<div class="modal-content">
<div class="modal-header bg-primary" style="border-radius: 5px 5px 0px 0px;">
<div class="row">
<div class="col-md-8">
<h3 class="modal-title" id="ModalLabel" style="color: white;">M1 ICCID Bar Code</h3>
</div>
</div>
</div>
<div class="modal-body" style="text-align: center;">
<img class="bar_code" src="/images/glyphicons-halflings.png" alt="bar_code">
</div>
<div class="modal-footer">
<button type="button" style="margin-left: 40%; margin-right: 40%; width: 20%; padding: 0px 10px 0px 10px; border-radius: 0px; height: 25px;" class="btn btn-default btn-lg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="m1_msisdn_bar_code" style="z-index:9999;">
<div class="modal-dialog" style="width: 800px; margin-top: 200px;">
<div class="modal-content">
<div class="modal-header bg-primary" style="border-radius: 5px 5px 0px 0px;">
<div class="row">
<div class="col-md-8">
<h3 class="modal-title" id="ModalLabel" style="color: white;">M1 MSISDN Bar Code</h3>
</div>
</div>
</div>
<div class="modal-body" style="text-align: center;">
<img class="bar_code" src="/images/glyphicons-halflings.png" alt="bar_code">
</div>
<div class="modal-footer">
<button type="button" style="margin-left: 40%; margin-right: 40%; width: 20%; padding: 0px 10px 0px 10px; border-radius: 0px; height: 25px;" class="btn btn-default btn-lg" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="input_security_code" style="z-index:9999;">
<div class="modal-dialog" style="width: 600; margin-top: 200px;">
<div class="modal-content">
<div class="modal-header bg-primary" style="border-radius: 5px 5px 0px 0px;">
<div class="row">
<div class="col-md-8">
<h3 class="modal-title" id="ModalLabel" style="color: white;">Input Security Code</h3>
</div>
</div>
</div>
<div class="modal-body" style="text-align: center;">
<input type="text" class="form-control" placeholder="Security Code" ng-model="securityCode" />
</div>
<div class="modal-footer">
<div class="btn-group-lg top-spa" style="text-align: center;">
<button type="button" style="width: 20%; padding: 0px 10px 0px 10px; border-radius: 0px; height: 25px;" class="btn btn-default btn-lg" ng-click="update(securityCode);">OK</button>
<button type="button" style="width: 20%; padding: 0px 10px 0px 10px; border-radius: 0px; height: 25px;" class="btn btn-default btn-lg" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Counter -->
<style>
form.m1 div[class^=col-md] {
font-size: 8pt;
padding: 0px;
padding-left: 5px;
font-weight: bold;
}
.ajaxing-min {
background-image: url('/images/ajaxing-min.gif');
background-repeat: no-repeat;
background-position: center;
}
.col-voucher {
width: 27%;
}
.m1-query-btn, .col-voucher {
padding-left: 0px!important;
}
.col-homesimmsisdn {
width: 25%;
}
.col-m1iccid {
width: 25%;
}
.m1-msisdn {
width: 23%;
}
.m1-query-btn {
width: 200px;
float: right;
}
th {
background-color: lightgrey;
text-align: center;
}
</style>
My index.html
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<!--[if lt IE 9]><script src="http://code.jquery.com/jquery-1.10.2.min.js"></script><![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>GreenRoam</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css /styles/app.css -->
<link rel="stylesheet" href="/components/jquery-ui/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/components/jqueryui-timepicker-addon/dist/jquery-ui-timepicker-addon.css">
<link rel="stylesheet" href="/components/swipebox/src/css/swipebox.css">
<!-- <link rel="stylesheet" href="/components/jquery-resizable-columns/dist/jquery.resizableColumns.css"> -->
<link rel="stylesheet" href="/components/ng-grid/ng-grid.min.css"></script>
<link rel="stylesheet" href="/styles/bootstrap.css">
<link rel="stylesheet" href="/styles/main.css">
<link rel="stylesheet" href="/styles/ssd-platform.css">
<link rel="stylesheet" href="/styles/ssd-platform-ng-grid-extends.css">
<!-- endbuild -->
</head>
<body ng-app="ssdWebClientApp">
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please upgrade your browser to improve your experience.</p>
<![endif]-->
<!--[if lt IE 9]>
<script src="{% get_static_prefix %}components/es5-shim/es5-shim.js"></script>
<script src="{% get_static_prefix %}components/json3/lib/json3.min.js"></script>
<![endif]-->
<!-- Add your site or application content here -->
<!-- Header - NaviBar -->
<ssd-navbar></ssd-navbar>
<!-- Render Part -->
<div ng-view></div>
<!-- Footer -->
<ssd-footer></ssd-footer>
<!-- Additional Template -->
<ssd-alert></ssd-alert>
<!-- build:js /scripts/app.js -->
<script src="/components/jquery/dist/jquery.js"></script>
<script src="/components/jquery-ui/ui/minified/jquery-ui.min.js"></script>
<script src="/components/jqueryui-timepicker-addon/dist/jquery-ui-sliderAccess.js"></script>
<script src="/components/jqueryui-timepicker-addon/dist/jquery-ui-timepicker-addon.js"></script>
<script src="/components/swipebox/src/js/jquery.swipebox.js"></script>
<script src="/components/angular/angular.js"></script>
<script src="/components/bootstrap/js/affix.js"></script>
<script src="/components/bootstrap/js/alert.js"></script>
<script src="/components/bootstrap/js/button.js"></script>
<script src="/components/bootstrap/js/carousel.js"></script>
<script src="/components/bootstrap/js/collapse.js"></script>
<script src="/components/bootstrap/js/dropdown.js"></script>
<script src="/components/bootstrap/js/modal.js"></script>
<script src="/components/bootstrap/js/scrollspy.js"></script>
<script src="/components/bootstrap/js/tab.js"></script>
<script src="/components/bootstrap/js/tooltip.js"></script>
<script src="/components/bootstrap/js/transition.js"></script>
<script src="/components/bootstrap/js/popover.js"></script>
<script src="/components/smoothscroll-for-websites/SmoothScroll.js"></script>
<script src="/components/angular-resource/angular-resource.js"></script>
<script src="/components/angular-cookies/angular-cookies.js"></script>
<script src="/components/angular-route/angular-route.js"></script>
<script src="/components/angular-animate/angular-animate.js"></script>
<script src="/components/angular-filter/dist/angular-filter.js"></script>
<script src="/components/ng-grid/build/ng-grid.js"></script>
<script src="/components/ng-grid/plugins/ng-grid-flexible-height.js"></script>
<script src="/components/ng-grid/plugins/ng-grid-layout.js"></script>
<!-- Base -->
<script src="/scripts/Config/config.js"></script>
<script src="/scripts/Config/base_config.js"></script>
<script src="/scripts/Config/code_config.js"></script>
<script src="/scripts/Modules/main.js"></script>
<!-- Routes -->
<script src="/scripts/Routes/routes.js"></script>
<!-- Services -->
<script src="/scripts/Services/services.js"></script>
<script src="/scripts/Modules/product/services.js"></script>
<script src="/scripts/Modules/customer/faq/services.js"></script>
<script src="/scripts/Modules/product/onstore_management/services.js"></script>
<!-- Directives -->
<script src="/scripts/Directives/directives.js"></script>
<!-- Modules -->
...
<script src="/scripts/Modules/m1/m1.js"></script>
...
<!-- Main -->
<script src="/scripts/app.js"></script>
<!-- endbuild -->
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-X');
ga('send', 'pageview');
</script>
</body>
</html>
Ok, I hava solved this problem, the top-bar-space in the moment cause by
CSS Style
style="width: 100%!important; position: fixed;"
or
style="position: fixed!important; width: 100%!important; top: 0px!important;"
After I remove it, It's work well. But I don't know why...
I have the following angular js htmlapp:
<!DOCTYPE html>
<html ng-app="StudentProgram">
<head>
<title>Student Program Management</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.10.0.min.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/badge.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">{{subcategory.name2}} - Add Courses</h4>
</div>
<div class="modal-body">
<div class="panel panel-default">
<div class="panel-body">
<div class="panel col-md-5">
<div class="panel-body">
<p><font size="2">Required Credits : <span class="badge badge-machb pull-right">{{subcategory.required2}} </span></p>
<p>Completed Credits : <span class="badge badge-machb pull-right">{{subcategory.completed2}} </span></p>
<p>Planned Credits : <span class="badge badge-machb pull-right">{{subcategory.planned2}} </span></font></p>
</div>
</div>
<!--<input type="checkbox">{{child}}-->
<div class="panel progress col-md-7" style="height:121px;">
<div class="panel-body">
PROGRESS
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{getPercentage()}}" aria-valuemin="0" aria-valuemax="100" ng-style="{width:(getPercentage()+'%')}">
{{getPercentage()}}%
</div>
</div>
</div>
</div>
<div class="panel panel-default" style="float:left;width:525px;">
<div class="panel-body" data-spy="scroll" data-target="#navbar-example" data-offset="0" style="height:200px;overflow:auto;position:relative;">
<table class="table table-hover checkbox">
<tr>
<th>Course</th>
<th>Credits</th>
</tr>
<tr ng-repeat="child in subcategory.children">
<td class="vcenter"><input type="checkbox" ng-checked="selectedCourses.indexOf(child) != -1" ng-click="toggleCheck(child)" value=""/>{{child}}</td>
<td class="vcenter">3</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" ng-click="ok()">Save</button>
<button class="btn btn-default" ng-click="cancel()">Cancel</button>
</div>
</script>
</head>
<body>
<div class="container">
<div class="col-lg-9 col-md-9 col-sm-10">
<div class="" id="content">
<div class="pull-right">
<span class="glyphicon glyphicon-plus-sign"></span>
<span class="glyphicon glyphicon-file"></span>
<span class="glyphicon glyphicon-calendar"></span>
<span class="glyphicon glyphicon-search"></span>
</div>
<br/><br/>
<div ng-controller="mycontroller">
<div ng-repeat="detail in details">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><span class="badge badge-machb pull-right">{{detail.completed}} / {{detail.required}}</span>{{detail.name1}}</h3>
</div>
<div ng-repeat="subcategory in detail.subcategory1" class="panel-body">
<h4><strong>{{subcategory.name2}}
<button class="btn btn-default pull-right" ng-disabled="subcategory.required2 == subcategory.completed2" ng-click="open(subcategory)">Add Course <span class="glyphicon glyphicon-plus"></span></button>
</strong></h4>
<table class="table table-hover">
<tr>
<th>Course</th>
<th>Term</th>
<th>Credit</th>
<th>Grade</th>
</tr>
<tr ng-repeat="subcategory2 in subcategory.subcategory2">
<td>{{subcategory2.course}}</td>
<td>{{subcategory2.term}}</td>
<td>{{subcategory2.credit}}</td>
<td>{{subcategory2.grade}}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="js/bootstrap.js"></script>
<script>
var app = angular.module('StudentProgram', ['ui.bootstrap']);
app.controller('mycontroller', function($scope, $modal, $log){
$scope.details=[
{name1:"TIER 1 - CORE FOUNDATIONS", completed:"9", required:"13", subcategory1:[
{name2:"Critical Reading and Writing",completed2:"6",required2:"6",planned2:"0",children:['ENGL-1301','HIST-1301'], subcategory2:[
{course:"HIST 1301",term:"Spring 2012",credit:"3.0",grade:"B"},
{course:"ENGL 1301",term:"Spring 2012",credit:"3.0",grade:"A"}
]},
{name2:"Speaking and Listening",completed2:"3",required2:"3",planned2:"0",children:['SPCH-1311','SPCH-1315','SPCH-1321','ARAB-1311','ARAB-1312','ARAB-1411','ARAB-1412','CHIN-1311','CHIN-1312','CHIN-1411','CHIN-1412','CZEC-1311','CZEC-1312','CZEC-1411','CZEC-1412','FREN-1311','FREN-1312','FREN-1411','FREN-1412','GERM-1311','GERM-1312','GERM-1411','GERM-1412','GREE-1311','GREE-1312','GREE-1411','GREE-1412','ITAL-1311','ITAL-1312','ITAL-1411','ITAL-1412','JAPN-1311','JAPN-1312','JAPN-1411','JAPN-1412','KORE-1311','KORE-1312','KORE-1411','KORE-1412','LATI-1311','LATI-1312','LATI-1411','LATI-1412','PORT-1311','PORT-1312','PORT-1411','PORT-1412','RUSS-1311','RUSS-1312','RUSS-1411','RUSS-1412','SGNL-1301','SGNL-1302','SPAN-1311','SPAN-1312','SPAN-1411','SPAN-1412','VIET-1311','VIET-1312','VIET-1411','VIET-1412'],
subcategory2:[
{course:"SPCH 1311",term:"Spring 2012",credit:"4.0",grade:"A"}
]},
{name2:"Quantitative Reasoning",completed2:"0",required2:"3",planned2:"0",children:['MATH-1314','MATH-1414','MATH-1316','MATH-1324','MATH-1325','MATH-1425','MATH-1332','MATH-1333','MATH-1348','MATH-1350','MATH-1351','MATH-2321','MATH-2421','MATH-2342','MATH-2442','MATH-2412','MATH-2413','MATH-2414','MATH-2415','MATH-2318','MATH-2418','MATH-2320','MATH-2420','MATH-2305'],
subcategory2:[
]},
{name2:"Wellness and The Human Experience",completed2:"0",required2:"1",planned2:"0",children:['ARTS-1311','ARTS-1312','ARTS-1313','ARTS-1316','ARTS-2313','ARTS-2316','ARTS-2326','ARTS-2333','ARTS-2336','ARTS-2341','ARTS-2346','ARTS-2348','ARTS-2356','ARTS-2366','BIOL-1322','BUSI-1307','COMM-1316','COMM-1318','DANC-1245','DANC-1341','DANC-1347','DANC-1351','DRAM-1322','DRAM-1330','DRAM-1351','MUEN-1122','MUEN-1131','MUEN-1132','MUEN-1133','MUEN-1134','MUEN-1135','MUEN-1136','MUEN-1137','MUEN-1151','MUEN-1152','MUEN-1153','MUEN-2123','MUEN-2141','MUSI-1116','MUSI-1181','MUSI-1183','MUSI-1192','MUSI-1263','MUSI-1301','PHED-1100','PHED-1101','PHED-1102','PHED-1104','PHED-1105','PHED-1106','PHED-1107','PHED-1108','PHED-1109','PHED-1110','PHED-1111','PHED-1112','PHED-1113','PHED-1114','PHED-1115','PHED-1116','PHED-1117','PHED-1118','PHED-1119','PHED-1120','PHED-1121','PHED-1122','PHED-1123','PHED-1124','PHED-1125','PHED-1126','PHED-1127','PHED-1128','PHED-1129','PHED-1164','PHED-1165','PHED-1251','PHED-1304','PHED-1306','PHED-1346','SOCI-2301','SOCI-2340','SPCH 2341'],
subcategory2:[
]}
]},
{name1:"TIER 2 - CORE DOMAINS", completed:"10", required:"26", subcategory1:[
{name2:"Qualitative Reasoning, Literacy and Research",completed2:"3",required2:"3",planned2:"0",children:['ENGL-1302'],
subcategory2:[
{course:"ENGL 1302",term:"Summer 2012",credit:"3.0",grade:"A"}
]},
{name2:"Self and Society",completed2:"3",required2:"9",planned2:"0",children:['HIST-1302','HIST-2301','HIST-2328','HIST-2381','GOVT-2305','ANTH-2302','ANTH-2346','ANTH-2351','COMM-1307','CRIJ-1301','CRIJ-1307','ECON-1301','ECON-2302','ECON-2311','GEOG-1302','GEOG-1303','GEOG-2312','GOVT-2304','GOVT-2311','HIST-2321','HIST-2322','HIST-2327','PSYC-2301','PSYC-2306','PSYC-2314','PSYC-2316','SOCI-1301','SOCI-1306','SOCI-2306','SOCI-2319','SOCI-2336','TECA-1303','TECA-1354'],
subcategory2:[
{course:"GOVT 2301",term:"Spring 2012",credit:"3.0",grade:"B"},
{course:"PSYC 2301",term:"Summer 2012",credit:"--",grade:"--"}
]},
{name2:"Humanity, Creativity and the Aesthetic Experience",completed2:"0",required2:"6",planned2:"0",children:['ARTS-1301','ARTS-1303','ARTS-1304','DANC-2303','DRAM-1310','DRAM-2361','DRAM-2366','HUMA-1311','HUMA-1315','MUSI-1306','MUSI-1308','MUSI-1309','MUSI-1310',
'CUST-2370','ENGL-2321','ENGL-2322','ENGL-2323','ENGL-2326','ENGL-2327','ENGL-2328','ENGL-2331','ENGL-2332','ENGL-2333','ENGL-2342','ENGL-2343','ENGL-2351','HUMA-1302','HUMA-1305','HUMA-2319','PHIL-1301','PHIL-1304','PHIL-1316','PHIL-1317','PHIL-2303','PHIL-2306','PHIL-2307','PHIL-2316','PHIL-2317','PHIL-2318','PHIL-2321','ARAB-2311','ARAB-2312','CHIN-2311','CHIN-2312','CZEC-2311','CZEC-2312','FREN-2311','FREN-2312','GERM-2311','GERM-2312','GREE-2311','GREE-2312','ITAL-2311','ITAL-2312','JAPN-2311','JAPN-2312','KORE-2311','KORE-2312','LATI-2311','LATI-2312','PORT-2311','PORT-2312','RUSS-2311','RUSS-2312','SPAN-2311','PAN-2312','SPAN-2321','SPAN-2322','SPAN-2323','SPAN-2324','VIET-2311','VIET-2312'],
subcategory2:[
]},
{name2:"Scientific Discovery and Sustainability",completed2:"4",required2:"8",planned2:"0",children:['ANTH-2401','BIOL-1406','BIOL-1407','BIOL-1408','BIOL-1409','BIOL-1411','BIOL-2401','BIOL-2402','BIOL-2406','BIOL-2416','BIOL-2420','BIOL-2421','CHEM-1405','CHEM-1406','CHEM-1407','CHEM-1411','CHEM-1412','CHEM-2423','CHEM-2425','ENVR-1401','ENVR-1402','GEOL-1401','GEOL-1402','GEOL-1403','GEOL-1404','GEOL-1405','GEOL-1445','GEOL-1447','PHYS-1401','PHYS-1402','PHYS-1403','PHYS-1404','PHYS-1405','PHYS-1407','PHYS-1415','PHYS-1417','PHYS-2425','PHYS-2426'],
subcategory2:[
{course:"BIOL 1406",term:"Spring 2012",credit:"4.0",grade:"B"},
{course:"BIOL 1407",term:"Summer 2012",credit:"--",grade:"--"}
]}
]}
];
$scope.open = function (subcat) {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
detail: function() {
return subcat;
}
}
});
};
});
var ModalInstanceCtrl = function ($scope, $modalInstance, detail) {
$scope.subcategory = detail;
$scope.selectedCourses= [];
$scope.subcategory.planned2 = parseInt($scope.subcategory.planned2,10);
$scope.subcategory.completed2 = parseInt($scope.subcategory.completed2,10);
$scope.subcategory.required2 = parseInt($scope.subcategory.required2,10);
angular.forEach(detail.subcategory2, function(item) {
$scope.selectedCourses.push(item.course);
});
$scope.toggleCheck = function (course) {
if (($scope.selectedCourses.indexOf(course) === -1) && ($scope.subcategory.planned2 + $scope.subcategory.completed2 < $scope.subcategory.required2)) {
$scope.selectedCourses.push(course);
$scope.subcategory.planned2 += 3;
if (($scope.subcategory.planned2 + $scope.subcategory.completed2) == $scope.subcategory.required2) {
alert('Requirement met');
}
} else {
$scope.selectedCourses.splice($scope.selectedCourses.indexOf(course), 1);
$scope.subcategory.planned2 -= 3;
}
$scope.getPercentage = function () {
return (($scope.subcategory.planned2+$scope.subcategory.completed2)/($scope.subcategory.required2)*100).toFixed(2);
}
};
$scope.ok = function () {
$scope.subcategory.subcategory2 = [];
for(var i = 0; i < $scope.selectedCourses.length; i++){
$scope.subcategory.subcategory2.push({course: $scope.selectedCourses[i], term:"--",credit:"--",grade:"--"});
}
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
</script>
</div>
</body>
</html>
When we click on the add courses button(for example in the self and society section), it opens a modal that has a progress bar to the right. The progress bar changes once we press on some course from the list below it. But i want the progress bar to load along with the modal ie. in the self and society section, the progress bar already has a value of 33.3% but it does not load that until we trigger a course. How do i do it?
Please help
You accidentally defined the getPercentage function inside the toggleCheck function. You need to define it outside toggleCheck, and then call it at the end of toggleCheck:
$scope.getPercentage = function () {
return (($scope.subcategory.planned2+$scope.subcategory.completed2)/($scope.subcategory.required2)*100).toFixed(2);
}
$scope.toggleCheck = function (course) {
if (($scope.selectedCourses.indexOf(course) === -1) && ($scope.subcategory.planned2 + $scope.subcategory.completed2 < $scope.subcategory.required2)) {
$scope.selectedCourses.push(course);
$scope.subcategory.planned2 += 3;
if (($scope.subcategory.planned2 + $scope.subcategory.completed2) == $scope.subcategory.required2) {
alert('Requirement met');
}
} else {
$scope.selectedCourses.splice($scope.selectedCourses.indexOf(course), 1);
$scope.subcategory.planned2 -= 3;
}
$scope.getPercentage();
};