連日的開發, 修改了幾個問題
包括AJAX errors, IE 相容問題
改變發生錯誤時的顯示方式等等
AJAX 錯誤發生在tabbed_block.js 內,
如果用戶沒有使用jstools 模組就會發生問題
主要因為AJAX 的請求路徑(request url)使用了jstools 的一個add-on, Drupal.url()
原本錯誤地假定Drupal.url 為Drupal 內建(.....名字上的誤會, 但Drupal 的確內建了 Drupal 對象, 只是jstools 加強了Drupal 對象)
及後發覺來自jstools
改用tabbed_block.module 內
<?php
drupal_add_js("var base_path = ".drupal_to_js(base_path()).";" , "inline" )
?>
將base_path 傳到js 內使用
IE href 屬性:
IE 相容問題, 除了CSS 上, tabs 更是使用不能
問題出自tabbed_block.js 一段jquery:
....略, 38行
$(this).click(function(){
click = $(this).children("a").attr("href");
$(click).siblings("div").each(function(){
39行的變數 click, 目的在取出a 的href
用作找回相應的div content
在firefox 上, 值為source code 內的值
但在IE 上, 值為一個絕對路徑(http://example.com/drupal/#fragment-1)
令40行找不到一個 http://example.com 的div
做成錯誤
用javascript 的字符函數取出解決
另, 停用IE anchor:
IE 的anchor 不可以在jquery內用 return false 停用(停止自動滾動)
改用inline 的方式
<a href="#frag1" onclick="return false;">tab head1</a>
在Drupal 內顯示錯誤:
原本為了方便開發
某些可以預計的錯誤使用print_r + exit() 處理
方便分析
但為了一般使用者方便, 及一體性
轉為使用drupal 內建的錯誤顯示方式:
<?php
druapl_set_message( print_r $_POST , "error")
?>
加上注解等等之後
patched 的v0.41 待測試後發佈
下一個將增加的功能有非常多的用戶反映
「tabbed block module 可以使用多於一block」
類似adsense module
但改code 將會頗多, 會待v0.41 穩定下來再開發
After days of development, Tabbed Block module had fixed a couples of bugs,
include AJAX errors, incompatible in IE,
changes in UI when there is error....... etc etc
AJAX error happens inside file tabbed_block.js
If the user do not install jstools modules, problems happen.
It is because AJAX request path use a jstools add-on function call, Drupal.url()
which I assume the function is build-in Drupal (...misunderstand in naming. but Drupal did really have a build-in Drupal object, but jstools expanded it.)
It is solved by tabbed_block.module, a line
<?php
drupal_add_js("var base_path = ".drupal_to_js(base_path()).";" , "inline" )
?>
using it to pass the base path(request path) to js
IE href properties:
incompatible in IE, other than CSS, more important is failure in using tabs.
the bug is a line from jquery from file tabbed_block.js, line 39:
....etc etc, line 38:
$(this).click(function(){
click = $(this).children("a").attr("href");
$(click).siblings("div").each(function(){
line 39 variable click, aim to get the attribute href,
finding the corresponding div
in FF, it returns the value in source code,
while in IE, it return absolute path: (http://example.com/drupal/#fragment-1)
causing line 40 cannot find a div with id http://example.com
it is solved by parsing the return string by string methods in js.
Also, disable IE anchor:
the anchor cannot be disabled by returning false from jquery
but a inline method works:
<a href="#frag1" onclick="return false;">tab head1</a>
Display errors inside Drupal:
originally, becoz of the convience for development,
some predictable errors use print_r + exit() to catch
but as release goes, more focus is put on end-user,
so it changed to Drupal-style:
<?php
druapl_set_message( print_r $_POST , "error")
?>
And some other addings in comments,
patched v0.41 will be release after test
The coming feature that will be added is "multi-block",
like adsense module.
And it is required by many users,
but the change in code will be huge,
so it will start after v0.41 is stable.