From: dongsheng Date: Tue, 16 Jun 2009 02:42:32 +0000 (+0000) Subject: "MDL-13766, use new API to load javascript files, fix xhtml strict issues in javascri... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=aa8ce6e3fd3a2c97d83c7fb4c7e6c3a116c39d4d;p=moodle.git "MDL-13766, use new API to load javascript files, fix xhtml strict issues in javascript, but YUI cannot work in xml strict mode, so do not true on xml strict option in moodle if you want to use file picker" --- diff --git a/lang/en_utf8/repository.php b/lang/en_utf8/repository.php index 28c7d8010c..983cbc3961 100644 --- a/lang/en_utf8/repository.php +++ b/lang/en_utf8/repository.php @@ -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'; diff --git a/repository/lib.php b/repository/lib.php index 14f1054ce4..bcd6c3618d 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -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 = '*', $ 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(); diff --git a/repository/repository.src.js b/repository/repository.src.js index 1e2f9b6cfa..0399ad2d82 100644 --- a/repository/repository.src.js +++ b/repository/repository.src.js @@ -338,7 +338,9 @@ repository_client.print_login = function(id, data) { field_id = ' id="'+login[k].id+'"'; } if (login[k].label) { - str += ''+login[k].label+' '; + str += ''+login[k].label+' '; + } else { + str += ''; } if(login[k].value) { field_value = ' value="'+login[k].value+'"'; @@ -370,7 +372,11 @@ repository_client.print_login = function(id, data) { } } str += ''; - 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 = '
'; if(type=='load') { - img.src = moodle_cfg.pixpath+'/i/loading.gif'; - para.innerHTML = fp_lang.loading; + str += ''; + str += '

'+fp_lang.loading+'

'; }else{ - img.src = moodle_cfg.pixpath+'/i/progressbar.gif'; - para.innerHTML = fp_lang.copying+' '+name+''; + str += ''; + str += '

'+fp_lang.copying+' '+name+'

'; + } + str += '
'; + 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 += '
'; + str += '
'; 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 = ' '+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 = ' '+fp_lang.refresh; + ccache.href = "###"; + ccache.appendChild(document.createTextNode(fp_lang.refresh)); + oDiv.appendChild(img); oDiv.appendChild(ccache); ccache.onclick = function() { var params = [];