/[drupal]/contributions/modules/webfm_images/webfm_images.js
ViewVC logotype

Contents of /contributions/modules/webfm_images/webfm_images.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Thu Jan 31 17:22:50 2008 UTC (21 months, 4 weeks ago) by robmilne
Branch: MAIN
CVS Tags: DRUPAL-5--1-2, HEAD
Changes since 1.2: +1 -1 lines
File MIME type: text/javascript
fix $Id:$
1 /* $Id:$ */
2 /* namespace */
3 function webfmImages() {}
4
5 if (Drupal.jsEnabled) {
6 $(window).load(webfmImagesGetMenusAjax);
7 }
8
9 webfmImages.ajaxUrl = function() {
10 var path = getBaseUrl() + "/?q=";
11 return path += (typeof getModUrl == "undefined") ? "webfm_images_js" : getModUrl();
12 }
13
14 function webfmImagesGetMenusAjax() {
15 var url = webfmImages.ajaxUrl();
16 Webfm.progressObj.show(Webfm.js_msg["work"], "blue");
17 var postObj = {action:encodeURIComponent("get_menus")};
18 Webfm.HTTPPost(url, webfmImages.GetMenusCallback, '', postObj);
19 }
20
21 webfmImages.GetMenusCallback = function(string, xmlhttp, obj) {
22 Webfm.progressObj.hide();
23 Webfm.alrtObj.msg();
24 if (xmlhttp.status == 200) {
25 var result = Drupal.parseJson(string);
26 // Webfm.dbgObj.dbg("GetMenusCallback:", Webfm.dump(result));
27 if (result.status) {
28 var menus = [];
29 menus = result.data;
30 for(var i = 0; i < menus.length; i++) {
31 Webfm.menuHT.put('file', new Webfm.menuElement("Resize to "+menus[i], webfmImages.menuResize, webfmImages.menuTest));
32 }
33 } else {
34 Webfm.alrtObj.msg(result.data);
35 }
36 } else {
37 Webfm.alrtObj.msg(Webfm.js_msg["ajax-err"]);
38 }
39 }
40
41 webfmImages.menuResize = function(obj){
42 var url = webfmImages.ajaxUrl();
43 var path = obj.element.title;
44 Webfm.progressObj.show(Webfm.js_msg["work"], "blue");
45 var postObj = {action:encodeURIComponent(this.desc), filepath:encodeURIComponent(path)};
46 Webfm.dbgObj.dbg("postObj:", Webfm.dump(postObj));
47 Webfm.HTTPPost(url, webfmImages.ResizeCallback, obj, postObj);
48 }
49
50 webfmImages.ResizeCallback = function(string, xmlhttp, obj) {
51 Webfm.progressObj.hide();
52 Webfm.alrtObj.msg();
53 if (xmlhttp.status == 200) {
54 var result = Drupal.parseJson(string);
55 // Webfm.dbgObj.dbg("resize result:", Webfm.dump(result));
56 if (result.status) {
57 Webfm.dirListObj.refresh();
58 // Webfm.alrtObj.str_arr(result.data);
59 } else {
60 Webfm.alrtObj.msg(result.data);
61 }
62 } else {
63 Webfm.alrtObj.msg(Webfm.js_msg["ajax-err"]);
64 }
65 }
66
67 webfmImages.menuTest = function(obj) {
68 switch(obj.ext.toLowerCase()) {
69 case 'jpg':
70 case 'jpeg':
71 case 'png':
72 case 'bmp':
73 case 'gif':
74 return true;
75 default:
76 return false;
77 }
78 }

  ViewVC Help
Powered by ViewVC 1.1.2