1 | AJS={};
|
2 | AJS.tools={};
|
3 | AJS.schemas=[];
|
4 | AJS.Application={};
|
5 | AJS.fieldClasses=[];
|
6 | AJS.fieldClassesPathes=[];
|
7 | AJS.templates=[];
|
8 | AJS.ui={};
|
9 | AJS.path={};
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | AJS.config={
|
15 | "api":"http://localhost:9999/",
|
16 | "fileUploadUrl":"http://localhost:9999/upload",
|
17 | "fileDir":"http://localhost:9999/files/",
|
18 | "thumbDir":"http://localhost:9999/files/thumbnail/",
|
19 | "defaultLanguage":"fr",
|
20 | "currentLanguage":"fr",
|
21 | "recordID":"_id",
|
22 | "login":{"mode":"fake"},
|
23 | "debug":false,
|
24 | "dateTimeFormat":"YYYY-MM-DD HH:mm:ss",
|
25 |
|
26 | "tinymce":{"plugins":"code,link,paste",
|
27 | "toolbar":"code | bold italic | alignleft aligncenter alignright alignjustify | link unlink | pastetext | undo redo",
|
28 | "theme": "modern",
|
29 | "skin": "light"}
|
30 | };
|
31 |
|
32 |
|
33 | var consoleHolder = console;
|
34 | function debug(bool){
|
35 | if(!bool){
|
36 | consoleHolder = console;
|
37 | console = {};
|
38 | console.log = function(){};
|
39 | }else
|
40 | console = consoleHolder;
|
41 | }
|
42 |
|
43 | function extractUrlParams() {
|
44 | var t = location.search.substring(1).split('&');
|
45 | var f = [];
|
46 | for (var i=0; i<t.length; i++) {
|
47 | var x = t[ i ].split('=');
|
48 | f[x[0]]=x[1];
|
49 | }
|
50 | return f;
|
51 | }
|
52 |
|
53 | var params=extractUrlParams();
|
54 |
|
55 | AJS.path.customFolder="example";
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | if (params["config"]) {
|
61 |
|
62 | AJS.path.customFolder=params["config"];
|
63 | }
|
64 |
|
65 | AJS.path.customFolderPath="./custom/"+AJS.path.customFolder+"/";
|
66 |
|
67 |
|
68 | var configObj={
|
69 | baseUrl: './',
|
70 | paths: {
|
71 | "css": "./vendor/require/css",
|
72 | "text": "./vendor/require/text",
|
73 | "image": "./vendor/require/image",
|
74 | "ejs": "./vendor/ejs_production",
|
75 | "underscore": './vendor/underscore-min',
|
76 | "lodash": './vendor/lodash.compat.min',
|
77 | "jquery": './vendor/jquery-2.1.0.min',
|
78 | "backbone": './vendor/backbone-min',
|
79 | "marionette" : './vendor/backbone.marionette.min',
|
80 | "backbone.paginator" : './vendor/backbone.paginator.min',
|
81 | 'bootstrap': './vendor/bootstrap/js/bootstrap.min',
|
82 | 'datetimepicker': './vendor/datetime/jquery.datetimepicker',
|
83 | 'backgrid': './vendor/backgrid.min',
|
84 | 'backgrid-paginator': './vendor/backgrid-paginator.min',
|
85 | 'moment': './vendor/moment.min',
|
86 | 'jquery.ui.widget': './vendor/fileupload/jquery.ui.widget',
|
87 | 'jquery.ui': './vendor/jquery-ui.min',
|
88 | 'jquery.iframe-transport': './vendor/fileupload/jquery.iframe-transport',
|
89 | 'jquery.fileupload': './vendor/fileupload/jquery.fileupload',
|
90 | 'moment':"./vendor/moment.min",
|
91 | "tinymcelib":"./vendor/tinymce/tinymce.min",
|
92 | "tinymce":"vendor/tinymce/jquery.tinymce.min",
|
93 | "combodate":'./vendor/combodate',
|
94 | 'tools':'./core/tools',
|
95 | 'switchbutton':'./vendor/jquery.switchButton'
|
96 | },
|
97 | shim: {"./core/application": {
|
98 | deps: ['jquery','underscore','backbone','tools'],
|
99 | },
|
100 | 'switchbutton': {
|
101 | deps:['jquery','jquery.ui','css!./vendor/jquery.switchButton.css']
|
102 | },
|
103 | 'moment': {
|
104 | exports: "moment"
|
105 | },'combodate': {
|
106 | deps: ['jquery'],
|
107 | },'tinymce': {
|
108 | deps: ['jquery','tinymcelib'],
|
109 | },'datetimepicker': {
|
110 | deps: ['jquery','css!./vendor/datetime/jquery.datetimepicker.css'],
|
111 | },
|
112 | 'backbone': {
|
113 |
|
114 | deps: ['jquery','underscore'],
|
115 | exports: "Backbone"
|
116 | }, 'jquery': {
|
117 | exports: "$"
|
118 | },'jquery.ui':{
|
119 | deps: ['jquery']
|
120 | },
|
121 |
|
122 | 'underscore': {
|
123 | exports: "_"
|
124 | },
|
125 | "marionette" : {
|
126 | deps : ['jquery', 'underscore', 'backbone'],
|
127 | exports : 'Marionette'
|
128 | },
|
129 | "jquery.fileupload": {deps: ['jquery.ui','jquery.iframe-transport']},
|
130 | "bootstrap": {deps: ["jquery"]},
|
131 | backgrid: {
|
132 | deps: ['jquery', 'backbone', 'underscore', 'css!./vendor/backgrid.min'],
|
133 | exports: 'Backgrid'
|
134 | }
|
135 | }
|
136 | };
|
137 |
|
138 |
|
139 |
|
140 |
|
141 | require.config(configObj);
|
142 |
|
143 |
|
144 | var editors=["string",
|
145 | "textarea",
|
146 | 'textareasimple',
|
147 | "yesno",
|
148 | "date"
|
149 | ,"datetime",
|
150 | "file",
|
151 | "collection",
|
152 | {name:"collectionembed",path:"collectionembed/collectionembed"},
|
153 | {name:"imagedropdown",path:"imagedropdown/imagedropdown"},
|
154 | "image",
|
155 | "imagecropresize/imagecropresize",
|
156 | "imagescollection",
|
157 | "select",
|
158 | "stringmultilangotf"
|
159 | ,"textareamultilangotf"];
|
160 |
|
161 |
|
162 | var editorsPathesArray=new Array();
|
163 | for (var i=0; i<editors.length; i++) {
|
164 | var editor=editors[i];
|
165 | if (typeof editor=="object") {
|
166 | console.log("PREPARE FIELD EDITOR DEF ",editor.name)
|
167 |
|
168 | AJS.fieldClassesPathes[editor.name]="./editors/"+editor.path;
|
169 | editorsPathesArray.push("./editors/"+editor.path)
|
170 | }
|
171 | if (typeof editor=="string") {
|
172 | console.log("PREPARE FIELD EDITOR DEF ",editor)
|
173 |
|
174 | AJS.fieldClassesPathes[editor]="./editors/"+editor;
|
175 | editorsPathesArray.push("./editors/"+editor)
|
176 | }
|
177 |
|
178 |
|
179 |
|
180 | }
|
181 |
|
182 |
|
183 |
|
184 | require(['require',"./core/helpers/tools","./core/approuter","./core/configloader",'./core/lib/session',"./core/application","./core/auth/index","./core/schemaloader"].concat(editorsPathesArray), function(req) {
|
185 |
|
186 |
|
187 |
|
188 | var AppRouter=req("./core/approuter");
|
189 | AJS.router=AppRouter;
|
190 | AJS.tools=req("./core/helpers/tools");
|
191 | var ConfigLoader=req("./core/configloader");
|
192 | var Session=req("./core/lib/session");
|
193 | var App=req("./core/application");
|
194 | var Authentification=req("./core/auth/index");
|
195 | var SchemaLoader=req("./core/schemaloader");
|
196 |
|
197 |
|
198 |
|
199 |
|
200 | for (var c in AJS.fieldClassesPathes) {
|
201 |
|
202 | AJS.fieldClasses[c]=req(AJS.fieldClassesPathes[c]);
|
203 | }
|
204 |
|
205 |
|
206 |
|
207 |
|
208 | $(document).ready(function() {
|
209 | $('body').empty()
|
210 | var launchApp=function() {
|
211 |
|
212 |
|
213 | var sl=new SchemaLoader({"folder":AJS.path.customFolderPath+"config/"});
|
214 | sl.on('success',function() {
|
215 |
|
216 | var app=new App({"folder":AJS.path.customFolderPath+"config/"});
|
217 | })
|
218 |
|
219 |
|
220 | }
|
221 |
|
222 |
|
223 | var cl=new ConfigLoader({"folder":AJS.path.customFolderPath+"config/"});
|
224 | cl.on('success',function() {
|
225 |
|
226 | var isAuth = Session.get('authenticated');
|
227 |
|
228 |
|
229 |
|
230 | if (isAuth==false || isAuth==null || isAuth=="false"){
|
231 | var auth=new Authentification();
|
232 | $("body").append(auth.$el);
|
233 | auth.on('success',function() {
|
234 | this.$el.remove();
|
235 |
|
236 | launchApp();
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | })
|
242 | }
|
243 | else {
|
244 |
|
245 | launchApp();
|
246 | }
|
247 |
|
248 |
|
249 | })
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 | });
|
258 | });
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|