forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomize_settings_native.php
129 lines (118 loc) · 5.02 KB
/
customize_settings_native.php
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
<link href="<?php echo getCDN(); ?>node_modules/croppie/croppie.css" rel="stylesheet" type="text/css"/>
<script src="<?php echo getCDN(); ?>node_modules/croppie/croppie.min.js" type="text/javascript"></script>
<div class="panel panel-default">
<div class="panel-heading"><?php echo __('Title and Logo'); ?> </div>
<div class="panel-body">
<form id="updateConfigForm">
<div class="row">
<div class="col-md-6">
<label class="col-md-4 control-label"><?php echo __("Web site title"); ?></label>
<div class="col-md-8 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-globe"></i></span>
<input id="inputWebSiteTitle" placeholder="<?php echo __("Web site title"); ?>" class="form-control" type="text" value="<?php echo $config->getWebSiteTitle(); ?>" maxlength="45" >
</div>
</div>
</div>
<div class="col-md-6">
<label class="col-md-4 control-label">
<?php echo __("Your Logo"); ?> (250x70)
</label>
<div class="col-md-8 ">
<div id="croppieLogo"></div>
<a id="logo-btn" class="btn btn-default btn-xs btn-block"><?php echo __("Upload a logo"); ?></a>
</div>
<input type="file" id="logo" value="Choose a Logo" accept="image/*" style="display: none;" />
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<button type="submit" class="btn btn-block btn-primary btn-lg" ><?php echo __("Save"); ?> <span class="fa fa-save"></span></button>
</div>
</div>
</form>
</div>
</div>
<script>
var logoCrop;
var logoSmallCrop;
var theme;
function readFile(input, c) {
console.log("read file");
if ($(input)[0].files && $(input)[0].files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
c.croppie('bind', {
url: e.target.result
}).then(function () {
console.log('jQuery bind complete');
});
}
reader.readAsDataURL($(input)[0].files[0]);
} else {
avideoAlert("Sorry - you're browser doesn't support the FileReader API");
}
}
var logoImgBase64;
$(document).ready(function () {
// start croppie logo
$('#logo').on('change', function () {
readFile(this, logoCrop);
});
$('#logo-btn').on('click', function (ev) {
$('#logo').trigger("click");
});
$('#logo-result-btn').on('click', function (ev) {
logoCrop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (resp) {
});
});
logoCrop = $('#croppieLogo').croppie({
url: '<?php echo $global['webSiteRootURL'], $config->getLogo(); ?>?'+Math.random(),
enableExif: true,
enforceBoundary: false,
mouseWheelZoom: false,
viewport: {
width: 250,
height: 70
},
boundary: {
width: 250,
height: 70
}
});
setTimeout(function () {
logoCrop.croppie('setZoom', 1);
}, 1000);
$('#updateConfigForm').submit(function (evt) {
evt.preventDefault();
modal.showPleaseWait();
$('#tabRegularLink').tab('show');
logoCrop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (resp) {
logoImgBase64 = resp;
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>admin/customize_settings_nativeUpdate.json.php',
data: {
"logoImgBase64": logoImgBase64,
"webSiteTitle": $('#inputWebSiteTitle').val(),
},
type: 'post',
success: function (response) {
if (response.status === "1") {
avideoAlert("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your configurations has been updated!"); ?>", "success");
} else {
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo __("Your configurations has NOT been updated!"); ?>", "error");
}
modal.hidePleaseWait();
}
});
});
});
});
</script>