Browse Source

Style file inputs (app wide)

Vijayakrishnan 3 years ago
parent
commit
152433d82c
2 changed files with 37 additions and 0 deletions
  1. 21 0
      public/css/style.css
  2. 16 0
      public/js/mc.js

+ 21 - 0
public/css/style.css

@@ -134,6 +134,27 @@ body.stag_rhs_collapsed .app-right-panel {
     height: 24px;
     line-height: 24px;
 }
+.mcp-theme-1 input[type="file"] {
+    position: relative;
+    cursor: pointer;
+    box-shadow: none;
+}
+.mcp-theme-1 input[type="file"]::after {
+    content: attr(selected-file);
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    background: #fff;
+    display: flex;
+    align-items: center;
+    padding: 0 0.5rem;
+    color: #0d59af;
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}
 .mcp-theme-1 *:not(i) {
     font-family: Verdana, sans-serif;
     font-size: 12px;

+ 16 - 0
public/js/mc.js

@@ -50,6 +50,7 @@ $(document).ready(function () {
     initPrimaryForm();
     initPatientPresenceIndicator();
     runMCInitializers();
+    initFileInputs();
 
     // if(typeof initializeCalendar !== 'undefined') {
     //     initializeCalendar();
@@ -172,6 +173,7 @@ function onFastLoaded(_data, _href, _history) {
                 initPrimaryForm();
                 initPatientPresenceIndicator();
                 runMCInitializers();
+                initFileInputs();
                 if (window.top.currentMcUrl.split('?')[0] !== window.top.location.href.split('?')[0]) {
                     $(window).scrollTop(0);
                 }
@@ -382,6 +384,20 @@ function initQuillEdit(_selector = '.note-content[auto-edit]') {
 }
 
 var patientPresenceTimer = false;
+function initFileInputs() {
+    $(document)
+        .off('change', 'input[type="file"]')
+        .on('change', 'input[type="file"]', function(_e) {
+            if(_e.target.files && _e.target.files.length) {
+                $(this).attr('selected-file', _e.target.files[0].name);
+            }
+            else {
+                $(this).attr('selected-file', 'No file chosen');
+            }
+            return false;
+        });
+    $('input[type="file"]').attr('selected-file', 'No file chosen');
+}
 function initPatientPresenceIndicator() {
     return false;
     if (patientPresenceTimer !== false) {