-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase-resources
512 lines (422 loc) · 20.5 KB
/
base-resources
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
SCRIPT TO DEBUG IN MOBILE DEVICES
<script src="{% static 'js/vendor/vconsole.min.js' %}"></script>
<script>
var vConsole = new VConsole();
</script>
{% if request.user.is_authenticated %}
<li class="top-nav-user-li">
<a href="#du" class="user-image navbar-item is-account drop-trigger">
{% if request.user.thumbnail %}
<img src="{{ oss }}/{{request.user.thumbnail}}" alt="Picture Profile"
style="width:30px;height:30px;border-radius: 50%;"
class="img-drop-trigger rounded-circle mb-3 mb-md-0 mr-0 md-3 img-fluid" id="thumb-pic" />
{% else %}
<img src="{% static 'img/user.png' %}" height="30px" width="30px" alt="No Profile Picture" />
{% endif %}
</a>
<div id="du" class="has-caret">
<div class="nav-drop is-account-dropdown">
<div class="inner">
<div class="nav-drop-header is-auth-user">
<span class="username">{{ request.user.username|truncatechars:12}}</span>
<a href="#" id="close">❌
{% trans 'CLOSE' %}
</a>
</div>
<div class="nav-drop-body account-items">
<a class="account-item" href="{% url 'users:detail' request.user.username %}">
<div class="media">
<div class="icon-wrap">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="feather feather-user">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
<circle cx="12" cy="7" r="4" /></svg>
</div>
<div>
<h3>
{% trans 'My Profile' %}
</h3>
<small>
{% trans 'Access profile & settings' %}
</small>
</div>
</div>
</a>
<a class="account-item" href="{% url 'account_logout' %}">
<div class="media">
<div class="icon-wrap">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="feather feather-power">
<path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path>
<line x1="12" y1="2" x2="12" y2="12"></line>
</svg>
</div>
<div>
<h3>
{% trans 'Log out' %}
</h3>
<small>
{% trans 'Log out from your account.' %}
</small>
</div>
</div>
</a>
<!-- close nav-drop-body -->
</div>
<!-- close inner div-->
</div>
<div class="nav-drop acc-nav-toggle" id="">
</div>
<!-- close inner, nav-drop, ac-dropdown -->
</div>
</div>
</li>
{% else %}
<li class="top-nav-user-li">
<a href="#d" class="user-image navbar-item is-account drop-trigger">
<img class="user-image" src="{% static 'img/user.png' %}"
height="30px" width="30px" alt="No Profile Picture" />
</a>
<div id="d" class="has-caret">
<div class="nav-drop is-navbarTop is-account-dropdown">
<div class="inner">
<div class="nav-drop-header guest-user">
<a href="#" id="close">❌ CLOSE</a>
</div>
<div class="nav-drop-body account-items">
<a class="account-item" href="{% url 'account_login' %}">
<div class="media">
<div class="icon-wrap">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="feather feather-user">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
<circle cx="12" cy="7" r="4" /></svg>
</div>
<div>
<h3>Login</h3>
</div>
</div>
</a>
<a class="account-item" href="{% url 'account_signup' %}">
<div class="media">
<div class="icon-wrap">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="feather feather-user-plus">
<path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
<circle cx="8.5" cy="7" r="4" />
<line x1="20" y1="8" x2="20" y2="14" />
<line x1="23" y1="11" x2="17" y2="11" /></svg>
</div>
<div>
<h3>Sign up</h3>
</div>
</div>
</a>
</div>
<!-- close inner, nav-drop, ac-dropdown -->
</div>
</div>
</div>
</li>
{% endif %}
BEFORE AJAX
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
$(function() {
function csrfSafeMethod(method) {
// These HTTP methods do not require CSRF protection
return /^(GET|HEAD|OPTIONS|TRACE)$/.test(method);
}
// This sets up every ajax call with proper headers.
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
});
BASE GLOBAL NAV JS
================================================================================
drop_trigger.addEventListener('click', function (e) {
if (drop_trigger.classList.contains('is-account')) {
nav_drop.classList.add('is-active');
drop_trigger.classList.add('is-opened');
}
});
document.getElementById('close').addEventListener('click', function (e) {
nav_drop.classList.remove('is-active');
drop_trigger.classList.remove('is-opened');
e.stopPropagation();
});
CLASSIFIEDS
================================================================================
list TEMPLATES:
<link rel="stylesheet" href="{% static 'css/uploader.css' %}" />
<link rel="stylesheet" href="{% static 'css/classified-create.css' %}" />
<script src="{% static 'js/aliyun-oss.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/multipleUploader.js' %}" type="text/javascript"></script>
Classifieds create template:
<div id="compose-card" class="card is-new-content">
<!-- Top tabs -->
<div class="tabs-wrapper">
<div class="tabs is-boxed is-fullwidth">
<ul>
<li class="is-active">
<a>
<i data-feather="edit-3"></i>
<span>
{% trans 'Publish' %}
</span>
</a>
</li>
<!-- Close X button -->
<li class="close-wrap is-hidden">
<span class="close-publish">
<i data-feather="x"></i>
</span>
</li>
</ul>
</div>
<!-- Tab content -->
<div class="alert alert-error is-hidden">
<strong><span id="data-errors"> </span></strong>
</div>
<form action="{% url 'classifieds:write_new' %}" name="classifiedForm" enctype="multipart/form-data"
id="classified-form" method="post" role="form">
{% csrf_token %}
<div class="column">
<div class="form-panel">
<div class="field">
<label>
{% trans 'Title*' %}
</label>
<div class="control">
<input type="text" id="id_title" name="title" maxlength="80" class="input" required
placeholder="Enter your item title">
</div>
</div>
<div class="field">
<label>
{% trans 'Details*' %}
</label>
<div class="control">
<textarea name="details" id="id_details" cols="40" rows="3" maxlength="2000" required
class="textarea"
placeholder="Provide enough details, to make it easier for buyers to understand your item!">
</textarea>
</div>
</div>
<div class="field d-flex justify-content-between">
<div class="">
<label>
{% trans 'Price*' %}
</label>
<small class="form-text text-muted" id="hint_id_price">
{% trans '0 for GIVEAWAY' %} </small>
</div>
<div class="control">
RMB <input type="number" id="id_price" name="price" class="numberinput input w-100" id="id_price"
required step="1.00" value="0" placeholder="Item price">
</div>
</div>
<div class="hidden-fields">
<input type="hidden" id="id_images" name="images" maxlength="3000" class="input" required>
<input type="hidden" id="id_img_errors" name="img_errors" maxlength="2000" class="input">
<input type="hidden" id="id_edited" name="edited" class="input">
<input type="hidden" id="id_status" name="status" maxlength="20" class="input">
</div>
{% if request.user.phone_number.national_number != 13300000000 and request.user.phone_number.national_number >= 1 %}
<div class="field is-flex justify-content-between">
<label>
{% trans 'Include your phone no? ' %}
</label>
<label class="f-switch is-accent">
<input type="checkbox" checked class="is-switch" name="show_phone" id="id_show_phone">
<i></i>
</label>
</div>
{% else %}
<div class="field">
<label for="id_phone_number" class="">
{% trans 'Phone number(optional)' %}
</label>
<input type="tel" name="phone_number" placeholder="Don't enter country code" class="input"
id="id_phone_number">
</div>
{% endif %}
</div>
<div class="field">
<label>
{% trans 'Images*' %}
</label>
<div class="control">
<div id="wrapper" class="mb-4">
<div id="container">
<div id="uploader">
<div class="queueList">
<ul class="filelist"></ul>
</div>
</div>
<div id="statusBar" class="statusBar flex-column align-items-center" style="display:none">
<div class="total-progress">
<div id="totalProgressBar" class="total-progress-bar" role="progressbar"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
<div class="upload-btn d-flex flex-column flex-md-row">
<div class="start-uploader startUploadBtn ml-2 mr-2">
<a id="startUpload" href="javascript:void(0);" class="text">
{% trans 'Upload images' %}
</a>
</div>
<div class="start-uploader addBtn ml-2 mr-2">
<a id="addBtn" href="javascript:void(0);" class="text button">
{% trans 'Add images' %}
</a>
</div>
</div>
</div>
<div class="m-auto justify-content-center d-flex ">
<div id="uploaderPick">
<a id="chooseFile" href="javascript:void(0);" class="text m-auto button">
{% trans 'Add images' %}
</a>
</div>
</div>
<div class="" style="clear: both;">
<p class="text-center">
{% trans 'Notes:' %}
{% trans 'Can select up to 8 multiple images & Max size per image is 13MB' %}
</p>
</div>
</div>
</div>
<div class="container bs-docs-container">
<form id="form">
<input id="image-file" type="file" style="display:none;" multiple="multiple"
accept="image/*" />
</form>
</div>
</div>
</div>
</div>
<div class="buttons">
{% if request.user.is_authenticated %}
<button id="create-btn" type="button"
class="button is-solid accent-button raised create submit-button">{% trans 'Submit' %}</button>
{% else %}
<button id="create-btn" type="button" onclick="window.location.href='/auth/login/'"
class="button is-solid accent-button raised">
{% trans 'Login & Post ' %}
</button>
{% endif %}
<button type="button"
class="ml-4 button is-solid dark-grey-button raised">
<span class="close-wrap">
<span class="close-publish"> {% trans 'Cancel' %} </span> </span>
</button>
</div>
</form>
{{ form.media }}
</div>
</div>
</div>
<div id="classifieds" class="small-cards-listing">
{% include "classifieds/classified_list_ajax.html" %}
</div>
<div class="loading classified-card is-hidden">
<div class="stage">
<div class="dot-pulse"></div>
</div>
</div>
</div>
<!-- /Middle column -->
CSS
stories:
<link href="{% static 'css/uploader.css' %}" rel="stylesheet">
base html:
<link rel="stylesheet" type="text/css" href="{% static 'css/colors.css' %}">
<!-- This file stores project-specific CSS -->
<link href="{% static 'css/obrisk.css' %}" rel="stylesheet">
<link href="{% static 'css/account.css' %}" rel="stylesheet">
component_utils.css
//small
.has-slimscroll-xs {
overflow-x: hidden !important;
&::-webkit-scrollbar {
width: 2px !important;
}
&::-webkit-scrollbar-thumb {
border-radius: 10px !important;
background: rgba(0, 0, 0, 0.2) !important;
}
}
JS
<obrisk.js>
document.querySelector("#notifications").addEventListener('click', function() {
document.querySelector("#recent-notifications").innerHTML = "";
fetch("/ws/notifications/latest-notifications/")
.then(function(response) {
// with the response, parse to text, then pass it along
response.text().then(function(data) {
document.querySelector("#recent-notifications").innerHTML = data;
});
});
}
return false;
});
stories:
<script src="{% static 'js/vendor/infinite.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/stories.js' %}" type="text/javascript"></script>
<script src="{% static 'js/preset.js' %}" type="text/javascript"></script>
<script src="{% static 'js/vendor/fancybox.min.js' %}"></script>
<script src="{% static 'js/lazyload.js' %}"></script>
<!-- Load these when the dom is ready or when user click specific button -->
<script src="{% static 'js/share.js' %}" type="text/javascript"></script>
<script src="{% static 'js/vendor/aliyun-oss.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/multipleUploader.js' %}" type="text/javascript"></script>
##==============End stories============
base html:
<script src="{% static 'js/vendor/jquery.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/global.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
<script src="{% static 'js/fancybox.min.js' %}"></script>
<script src="{% static 'js/lazyload.js' %}"></script>
<!-- Page and UI related js -->
<script src="{% static 'frontend/assets/js/feed.js' %}"></script>
##==============End base html============
nodepath + "webui-popover/dist/jquery.webui-popover.min.js"
nodepath + "quill/dist/quill.min.js",
//Get external js assets
assetspath + "js/fancybox.min.js"
// Compile css from node modules
gulp.task("compile-css", function() {
return gulp
.src([
//nodepath + 'path/to/file.min.css',
nodepath + "webui-popover/dist/jquery.webui-popover.min.css",
nodepath + "quill/dist/quill.core.css",
nodepath + "quill/dist/quill.snow.css",
//Other external css
assetspath + "css/fancybox.min.css"
])
.pipe(concat("app.css"))
.pipe(gulp.dest("../obrisk/static/frontend/assets/css/"));
});
// Compile js from node modules
gulp.task("compile-js", function() {
return gulp
.src([
nodepath + "feather-icons/dist/feather.min.js",
])
.pipe(concat("app.js"))
.pipe(gulp.dest("../obrisk/static/frontend/assets/js/"));
});
<script src="{% static 'js/linkify.min.js' %}" type="text/javascript"></script>
<link href="{% static 'frontend/assets/css/webfont.css' %}" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{% static 'fonts/font-awesome-4.7.0/css/font-awesome.min.css' %}">
//obrisk.messager.views