76
76
</div >
77
77
<div class =" form-group" >
78
78
{!! Form:: label (' country' , ' Country' ) ! !}   ;
79
- {!! Form:: text (' country' , old (' country' ), [' class' => ' form-control input-sm' , ' placeholder ' => ' country' ]) ! !}
79
+ {!! Form:: select (' country' , array (), old (' country' ), [' class' => ' form-control input-sm' , ' id ' => ' sel- country' ]) ! !}
80
80
</div >
81
81
<div class =" form-group" >
82
82
{!! Form:: label (' state' , ' State' ) ! !}   ;
117
117
@section (' script' )
118
118
<script type =" text/javascript" src =" {{ asset (' assets/external/package/Cropper/cropper.min.js' )} }" ></script >
119
119
<script type =" text/javascript" src =" {{ asset (' assets/external/sa/js/datetimepicker.min.js' )} }" ></script >
120
+ <script type =" text/javascript" src =" {{ asset (' assets/external/sa/js/chosen.min.js' )} }" ></script >
120
121
<script type =" text/javascript" >
121
122
var cropper = null ;
122
123
$ (function () {
124
+ pageInit ();
125
+ });
126
+
127
+ function pageInit () {
123
128
var $dateOnly = $ (" .date-only" );
124
- if ($dateOnly .length > 0 ) {
129
+ if ($dateOnly .length > 0 ) {
125
130
$dateOnly .datetimepicker ({
126
131
pickTime: false
127
132
});
128
- $ (' .datetime-pick input:text' ).on (' click' , function () {
133
+ $ (' .datetime-pick input:text' ).on (' click' , function () {
129
134
$ (this ).closest (' .datetime-pick' ).find (' .add-on i' ).click ();
130
135
});
131
136
}
132
- });
137
+ getRESTCountries ({
138
+ " url" : " {{ asset (" assets/internal/json/countries.json" )} }"
139
+ }, function (countries ) {
140
+ console .info (' countries' , countries);
141
+ var $selCountry = $ (" #sel-country" );
142
+ $ .each (countries, function (index , country ) {
143
+ $selCountry .append (
144
+ $ (" <option>" ).attr ({
145
+ " value" : country .name
146
+ }).text (country .name )
147
+ );
148
+ });
149
+ $selCountry .select ();
150
+ // $("#sel-country").autocomplete({
151
+ // source: function (request, response) {
152
+ // var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term), "i");
153
+ // response($.grep(countries, function (item) {
154
+ // return matcher.test(item.name)
155
+ // }))
156
+ // },
157
+ // }).data("ui-autocomplete")._renderItem = function (ul, item) {
158
+ // return $(ul).addClass("dropdown-menu inner").append(
159
+ // $("<li>").attr("data-value", item.name).append(
160
+ // $("<a>").attr("href", "#").text(item.name)
161
+ // )
162
+ // );
163
+ // };
164
+ });
165
+ }
133
166
134
167
function previewSelectedImage (el ) {
135
168
if (getFileSizeFromInput (el) <= 0 || getFileSizeFromInput (el) > 950 * 1024 ) {
@@ -198,9 +231,7 @@ function submitProfilePicture(data, callback) {
198
231
" type" : " put" ,
199
232
" data" : {
200
233
" _token" : " {!! csrf_token () ! !}" ,
201
- " user" : {
202
- " profile_pic" : data
203
- }
234
+ " profile_pic" : data
204
235
},
205
236
' cache' : false ,
206
237
' dataType' : " json" ,
@@ -211,7 +242,7 @@ function submitProfilePicture(data, callback) {
211
242
}
212
243
},
213
244
" error " : function () {
214
- console . info ( " Upload error " );
245
+ alertP ( " Profile Picture Upload Failed " , " Unable to upload profile picture, please try again later. " );
215
246
}
216
247
})
217
248
}
@@ -221,9 +252,31 @@ function objectDropOnProfilePicture(el, e) {
221
252
e .stopPropagation ();
222
253
}
223
254
224
- function updateUserProfileOnClick ()
225
- {
255
+ function updateUserProfileOnClick () {
256
+ var params = $ (" #frm-update-user-profile" ).serialize ();
257
+ submitUserProfile (params, function (response ) {
258
+ if (response .status == true ) {
259
+ alertP (" Profile Updated" , " You profile information has been updated." );
260
+ }
261
+ });
262
+ }
226
263
264
+ function submitUserProfile (data , callback ) {
265
+ $ .ajax ({
266
+ " url" : " {{ url (" user/profile" )} }" ,
267
+ " type" : " put" ,
268
+ " data" : data,
269
+ ' cache' : false ,
270
+ ' dataType' : " json" ,
271
+ " success " : function (response ) {
272
+ if ($ .isFunction (callback)) {
273
+ callback (response);
274
+ }
275
+ },
276
+ " error " : function () {
277
+ alertP (" Profile Update Failed" , " Unable to update profile, please try again later." );
278
+ }
279
+ });
227
280
}
228
281
</script >
229
- @stop
282
+ @stop
0 commit comments