Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cdb38f5a

Von Sven Schöling vor mehr als 3 Jahren hinzugefügt

  • ID cdb38f5ab6cf03f2fb40bcfaa463dea7914dc4f3
  • Vorgänger 40d375b6
  • Nachfolger e543253c

ImageUpload: local storage erste Version

Unterschiede anzeigen:

js/kivi.Materialize.js
3 3

  
4 4
  ns.init = function() {
5 5
    ns.reinit_widgets();
6
  }
6
  };
7 7

  
8
  ns.build_i18n = function(locale) {
8
  ns.build_i18n = function() {
9 9
    return {
10 10
      months: [
11 11
        kivi.t8('January'),
......
63 63
      // Accessibility labels
64 64
      labelMonthNext: kivi.t8('Next month'),
65 65
      labelMonthPrev: kivi.t8('Previous month')
66
    }
67
  }
66
    };
67
  };
68 68

  
69 69
  ns.reinit_widgets = function() {
70 70
    $('.sidenav').sidenav();
......
76 76
      i18n: ns.build_i18n()
77 77
    });
78 78
    $('.modal').modal();
79
    $('.materialboxed').materialbox();
79 80
    M.updateTextFields();
80
  }
81
  };
81 82

  
82 83
  // alternative for kivi.popup_dialog.
83 84
  // opens materialize modal instead.
84 85
  //
85 86
  // differences: M.modal can not load external content, so it needs to be fetched manually and inserted into the DOM.
86 87
  ns.popup_dialog = function(params) {
87
    console.log(params);
88 88
    params            = params        || { };
89 89
    let id            = params.id     || 'jqueryui_popup_dialog';
90 90
    let $div;
......
94 94
        // unlike classic layout, there is not fixed size, and M.modal is always... modal
95 95
        onCloseStart: custom_close
96 96
      },
97
        // User supplied options:
97
      // User supplied options:
98 98
      params.dialog || { },
99 99
      { // Options that must not be changed:
100 100
        // close options already work
......
110 110
          params.data = undefined;
111 111
          ns.popup_dialog(params);
112 112
        },
113
        error: function(x, status, error) { console.log(error); },
113
        error: function(x, status, error) { console.error(error); },
114 114
        dataType: 'text',
115 115
      });
116 116
      return 1;
......
118 118

  
119 119
    if (params.html) {
120 120
      $div = $('<div>');
121
      $div.attr('id', id)
121
      $div.attr('id', id);
122 122
      $div.addClass("modal");
123 123
      let $modal_content = $('<div>');
124 124
      $modal_content.addClass('modal-content');
......
126 126
      $div.append($modal_content);
127 127
      $('body').append($div);
128 128
      kivi.reinit_widgets();
129
      dialog_params.onCloseEnd = function() { $div.remove(); }
129
      dialog_params.onCloseEnd = function() { $div.remove(); };
130 130

  
131 131
      $div.modal(dialog_params);
132

  
133 132
    } else if(params.id) {
134 133
      $div = $('#' + params.id);
135 134
    } else {
......
140 139
    $div.modal('open');
141 140

  
142 141
    return true;
142
  };
143

  
144
  /**
145
   * upload file to local storage for later sync
146
   *
147
   * should be used with P.M.file_upload(..., local=>1)
148
   */
149
  ns.LocalFileUpload = function(options) {
150
    this.storage_token = options.storage_token; // used in localstorage to retrieve the file
151
    this.dom_selector  = options.dom_selector;  // file inputs to listen on
152

  
153
    this.init();
154
  };
155

  
156
  ns.LocalFileUpload.prototype = {
157
    init: function() {
158
      $(this.dom_selector).change(this.handle_file_upload);
159
    },
160
    handle_file_upload: function() {
161

  
162
    },
163
    load_files: function() {
164
      return JSON.parse(localStorage.getImte(this.storage_token));
165
    },
166
    save_files: function() {
167
      return JSON.parse(localStorage.getImte(this.storage_token));
168
    },
169

  
170
  };
143 171

  
144
  }
145 172
});

Auch abrufbar als: Unified diff