]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-13766, use new API to load javascript files, fix xhtml strict issues in javascri...
authordongsheng <dongsheng>
Tue, 16 Jun 2009 02:42:32 +0000 (02:42 +0000)
committerdongsheng <dongsheng>
Tue, 16 Jun 2009 02:42:32 +0000 (02:42 +0000)
lang/en_utf8/repository.php
repository/lib.php
repository/repository.src.js

index 28c7d8010c0b6673d2fa937cae35a33647293921..983cbc39612ab71fe64719138b78ee30b7d2f454 100644 (file)
@@ -105,3 +105,4 @@ $string['updown'] = 'Display order';
 $string['upload'] = 'Upload this file';
 $string['uploading'] = 'Uploading...';
 $string['wrongcontext'] = 'You cannot access to this context';
+$string['xhtmlerror'] = 'You are probably using XHTML strict header, some YUI Component doesn\'t work in this mode, please turn it off in moodle';
index 14f1054ce4b29f09d38fb2c2ea55b7b2ae7d09ed..bcd6c3618d0db79ebe071704051532f23b892022 100644 (file)
@@ -1733,7 +1733,7 @@ function repository_setup_default_plugins() {
  * @return array
  */
 function repository_get_client($context, $id = '',  $accepted_filetypes = '*', $returnvalue = '*') {
-    global $CFG, $USER;
+    global $CFG, $USER, $PAGE;
 
     $ft = new file_type_to_ext();
     $image_file_ext = json_encode($ft->get_file_ext(array('image')));
@@ -1799,7 +1799,7 @@ function repository_get_client($context, $id = '',  $accepted_filetypes = '*', $
 .fp-login-form{text-align:center}
 .fp-searchbar{float:right}
 .fp-viewbar{width:300px;float:left}
-.fp-toolbar{padding: .8em;background: #FFFFCC;color:white;text-align:center;margin: 3px}
+.fp-toolbar{padding: .8em;background: #FFFFCC;text-align:center;margin: 3px}
 .fp-toolbar a{padding: 0 .5em}
 .fp-list{list-style-type:none;padding:0;float:left;width:100%;margin:0;}
 .fp-list li{border-bottom:1px dotted gray;margin-bottom: 1em;}
@@ -1829,21 +1829,20 @@ function repository_get_client($context, $id = '',  $accepted_filetypes = '*', $
 </style>
 <![endif]-->
 EOD;
-
+        $PAGE->requires->yui_lib('yahoo');
+        $PAGE->requires->yui_lib('dom');
+        $PAGE->requires->yui_lib('element');
+        $PAGE->requires->yui_lib('event');
+        $PAGE->requires->yui_lib('json');
+        $PAGE->requires->yui_lib('treeview');
+        $PAGE->requires->yui_lib('dragdrop');
+        $PAGE->requires->yui_lib('container');
+        $PAGE->requires->yui_lib('resize');
+        $PAGE->requires->yui_lib('layout');
+        $PAGE->requires->yui_lib('connection');
+        $PAGE->requires->yui_lib('button');
+        $PAGE->requires->yui_lib('selector');
         require_js(array(
-            'yui_yahoo',
-            'yui_dom',
-            'yui_event',
-            'yui_element',
-            'yui_treeview',
-            'yui_dragdrop',
-            'yui_container',
-            'yui_resize',
-            'yui_layout',
-            'yui_connection',
-            'yui_json',
-            'yui_button',
-            'yui_selector',
             'repository/repository.src.js'
         ));
         $lang = array();
@@ -1886,6 +1885,7 @@ EOD;
         $lang['popup']     = get_string('popup', 'repository');
         $lang['upload']    = get_string('upload', 'repository').'...';
         $lang['uploading'] = get_string('uploading', 'repository');
+        $lang['xhtml']     = get_string('xhtmlerror', 'repository');
         $lang = json_encode($lang);
 
         $options = array();
index 1e2f9b6cfa34cdd57f761c6978cde974c799963b..0399ad2d82e30507b2aa9886369dd3f57ce85488 100644 (file)
@@ -338,7 +338,9 @@ repository_client.print_login = function(id, data) {
                 field_id = ' id="'+login[k].id+'"';
             }
             if (login[k].label) {
-                str += '<td align="right"><label'+label_id+'>'+login[k].label+'</label>&nbsp;</td>';
+                str += '<td align="right"><label'+label_id+'>'+login[k].label+'</label> </td>';
+            } else {
+                str += '<td></td>';
             }
             if(login[k].value) {
                 field_value = ' value="'+login[k].value+'"';
@@ -370,7 +372,11 @@ repository_client.print_login = function(id, data) {
         }
     }
     str += '</div>';
-    panel.get('element').innerHTML = str;
+    try {
+        panel.get('element').innerHTML = str;
+    } catch(e) {
+        alert(e.toString()+fp_lang.xhtml);
+    }
     cached_id=id;
     cached_repo_id=data.repo_id;
 }
@@ -445,20 +451,20 @@ repository_client.search = function(id, repo_id) {
 repository_client.loading = function(id, type, name) {
     var panel = new YAHOO.util.Element('panel-'+id);
     panel.get('element').innerHTML = '';
-    var content = document.createElement('div');
-    content.style.textAlign='center';
-    var para = document.createElement('P');
-    var img = document.createElement('IMG');
+    var str = '<div style="text-align:center">';
     if(type=='load') {
-        img.src = moodle_cfg.pixpath+'/i/loading.gif';
-        para.innerHTML = fp_lang.loading;
+        str += '<img src="'+moodle_cfg.pixpath+'/i/loading.gif" />';
+        str += '<p>'+fp_lang.loading+'</p>';
     }else{
-        img.src = moodle_cfg.pixpath+'/i/progressbar.gif';
-        para.innerHTML = fp_lang.copying+' <strong>'+name+'</strong>';
+        str += '<img src="'+moodle_cfg.pixpath+'/i/progressbar.gif" />';
+        str += '<p>'+fp_lang.copying+' <strong>'+name+'</strong></p>';
+    }
+    str += '</div>';
+    try {
+        panel.get('element').innerHTML = str;
+    } catch(e) {
+        alert('sadjfjsalfkj '+ e.toString());
     }
-    content.appendChild(para);
-    content.appendChild(img);
-    panel.get('element').appendChild(content);
 }
 repository_client.view_as_list = function(client_id, data) {
     if (typeof client_id == 'object') {
@@ -604,7 +610,7 @@ repository_client.paging = function(client_id, id) {
     this.fp[client_id].view_staus = 0;
     var fs = this.fp[client_id].fs;
     if(fs.pages) {
-        str += '<div class="fp-paging" id="paging-'+id+'-"'+client_id+'>';
+        str += '<div class="fp-paging" id="paging-'+id+'-'+client_id+'">';
         if(!fs.search_result){
             var action = 'req';
         } else {
@@ -848,9 +854,12 @@ repository_client.print_footer = function(client_id) {
         return;
     }
     if(!fs.nosearch) {
+        var img = document.createElement('img');
+        img.src = moodle_cfg.pixpath+'/a/search.png';
         var search = document.createElement('A');
         search.href = '###';
-        search.innerHTML = '<img src="'+moodle_cfg.pixpath+'/a/search.png" /> '+fp_lang.search;
+        search.appendChild(document.createTextNode(fp_lang.search));
+        oDiv.appendChild(img);
         oDiv.appendChild(search);
         search.onclick = function() {
             repository_client.search_form(client_id, fs.repo_id);
@@ -858,9 +867,12 @@ repository_client.print_footer = function(client_id) {
     }
     // weather we use cache for this instance, this button will reload listing anyway
     if(!fs.norefresh) {
+        var img = document.createElement('img');
+        img.src = moodle_cfg.pixpath+'/a/refresh.png';
         var ccache = document.createElement('A');
-        ccache.href = '###';
-        ccache.innerHTML = '<img src="'+moodle_cfg.pixpath+'/a/refresh.png" /> '+fp_lang.refresh;
+        ccache.href = "###";
+        ccache.appendChild(document.createTextNode(fp_lang.refresh));
+        oDiv.appendChild(img);
         oDiv.appendChild(ccache);
         ccache.onclick = function() {
             var params = [];