1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- angular.module('kityminderEditor')
- .provider('config', function() {
- this.config = {
-
- ctrlPanelMin: 250,
-
- ctrlPanelWidth: parseInt(window.localStorage.__dev_minder_ctrlPanelWidth) || 250,
-
- dividerWidth: 3,
-
- defaultLang: 'zh-cn',
-
- zoom: [10, 20, 30, 50, 80, 100, 120, 150, 200],
-
- imageUpload: 'server/imageUpload.php'
- };
- this.set = function(key, value) {
- var supported = Object.keys(this.config);
- var configObj = {};
-
- if (typeof key === 'object') {
- configObj = key;
- }
- else {
- configObj[key] = value;
- }
- for (var i in configObj) {
- if (configObj.hasOwnProperty(i) && supported.indexOf(i) !== -1) {
- this.config[i] = configObj[i];
- }
- else {
- console.error('Unsupported config key: ', key, ', please choose in :', supported.join(', '));
- return false;
- }
- }
- return true;
- };
- this.$get = function () {
- var me = this;
- return {
- get: function (key) {
- if (arguments.length === 0) {
- return me.config;
- }
- if (me.config.hasOwnProperty(key)) {
- return me.config[key];
- }
- console.warn('Missing config key pair for : ', key);
- return '';
- }
- };
- }
- });
|