2 * Magic3管理機能用JavaScriptライブラリ
6 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8 * @package Magic3 Framework
9 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
10 * @copyright Copyright 2006-2018 Magic3 Project.
11 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @link http://www.magic3.org
17 var _m3AccessPoint; // アクセスポイント(空=PC,m=携帯,s=スマートフォン)
18 var _m3SetUrlCallback; // リンク作成用コールバック
19 var _m3ContentEdited; // 入力コンテンツが変更されたかどうか
20 var _m3CheckContentEdit; // 入力コンテンツの変更をチェックするかどうか
21 var _m3ShowWidgetTool; // ウィジェットツールを表示するかどうか
22 var _m3ConfigWindowMinHeight = 600; // 設定画面の高さ最小値
25 function m3UpdateParentWindow()
27 var href = window.opener.location.href.split('#');
28 window.opener.location.href = href[0];
29 //window.opener.location.href = window.opener.location.href;
32 function m3UpdateParentWindowByConfig(serial)
35 if (window.opener.m3UpdateByConfig) window.opener.m3UpdateByConfig(serial);
36 if (window.opener.m3UpdateByChildWindow) window.opener.m3UpdateByChildWindow(serial);
38 if (window.parent != window.self){ // 呼び出し元がiframeの場合のみ実行
40 if (window.parent.m3UpdateByChildWindow) window.parent.m3UpdateByChildWindow(serial);
42 // iframeから起動元ウィンドウを更新
43 if (window.parent.opener && window.parent.opener.m3UpdateByConfig) window.parent.opener.m3UpdateByConfig(serial);
47 function m3AdjustParentWindow()
50 if (window.parent.m3AdjustWindow) window.parent.m3AdjustWindow();
54 function m3AdjustHeight(obj, min)
60 var app = navigator.appName.charAt(0);
62 if(navigator.userAgent.indexOf('Safari') != -1){
63 height = parent.frames[name].document.body.scrollHeight + 80;
64 }else if (app == "N"){
65 height = parent.frames[name].document.height +80;
68 height = parent.frames[name].document.body.scrollHeight + 80;
78 function m3ShowStandardWindow(url)
80 if (M3_CONFIG_WINDOW_OPEN_TYPE == 0){
81 window.open(url, "", "toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=1050,height=900");
87 function m3ShowConfigWindow(widgetId, configId, serial)
89 if (M3_CONFIG_WINDOW_OPEN_TYPE == 0){
90 window.open(M3_DEFAULT_ADMIN_URL + "?cmd=configwidget&openby=other&widget=" + widgetId +
91 "&_defconfig=" + configId + "&_defserial=" + serial, "config_" + widgetId,
92 "toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=1050,height=900");
94 window.open(M3_DEFAULT_ADMIN_URL + "?cmd=configwidget&openby=other&widget=" + widgetId +
95 "&_defconfig=" + configId + "&_defserial=" + serial, "config_" + widgetId);
99 function m3ShowTemplateConfigWindow(templateId)
101 window.open(M3_DEFAULT_ADMIN_URL + "?cmd=configtemplate&openby=other&template=" + templateId, "configtemplate_" + templateId);
103 // ウィジェット表示微調整用ウィンドウ表示
104 function m3ShowAdjustWindow(configId, serial, pageId, pageSubId)
106 if (M3_CONFIG_WINDOW_OPEN_TYPE == 0){
107 window.open(M3_DEFAULT_ADMIN_URL + "?task=adjustwidget&openby=simple" +
108 "&_defconfig=" + configId + "&_defserial=" + serial + "&_page=" + pageId + "&_sub=" + pageSubId, "adjust_" + serial,
109 "toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=1050,height=900");
111 window.open(M3_DEFAULT_ADMIN_URL + "?task=adjustwidget&openby=simple" +
112 "&_defconfig=" + configId + "&_defserial=" + serial + "&_page=" + pageId + "&_sub=" + pageSubId, "adjust_" + serial);
116 function m3ShowPreviewWindow(type, url)
123 // 小画面デバイス最適化の場合はタブで表示
124 if (M3_SMALL_DEVICE_OPTIMIZE){
125 window.open(url, "");
141 window.open(url, "", "toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
148 function m3LoadOptionUI()
151 $('.modal-header').addClass('bg-primary'); // タイトル背景色
152 if (typeof(BootstrapDialog) != "undefined"){
153 BootstrapDialog.DEFAULT_TEXTS['CANCEL'] = 'キャンセル';
157 m3PrepareProcessModal();
164 function m3ShowProcessModal()
167 $('input,textarea,select').blur();
169 $('#processing-modal').modal('show');
176 function m3HideProcessModal()
178 $('#processing-modal').modal('hide');
185 function m3PrepareProcessModal()
188 if ($('#processing-modal').size() == 0){ // ダイアログが存在しない場合
189 var modal = '<div class="modal modal-processing fade" id="processing-modal" role="dialog" aria-hidden="true" style="display:none;">';
190 modal += '<div class="modal-dialog">';
191 modal += '<div class="modal-content">';
192 modal += '<div class="modal-body">';
193 modal += '<div class="text-center">';
194 modal += '<img src="' + M3_ROOT_URL + '/images/system/processing.gif" class="icon" />';
195 modal += '<h4>処理中</h4>';
201 $("body").append(modal);
207 * @param string type アラートタイプ(空文字列,info,notice,success,failure,warinig,error)
208 * @param string message メッセージ
209 * @param function after_callback コールバック関数
210 * @param string title タイトル
213 function m3Alert(type, message, after_callback, title)
220 dialogType = BootstrapDialog.TYPE_DEFAULT;
223 dialogType = BootstrapDialog.TYPE_INFO;
226 dialogType = BootstrapDialog.TYPE_PRIMARY;
229 dialogType = BootstrapDialog.TYPE_SUCCESS;
232 dialogType = BootstrapDialog.TYPE_WARNING;
235 dialogType = BootstrapDialog.TYPE_WARNING;
238 dialogType = BootstrapDialog.TYPE_DANGER;
241 dialogType = BootstrapDialog.TYPE_DANGER;
244 config['type'] = dialogType;
245 config['message'] = message;
273 if (title) config['title'] = title;
274 if (after_callback) config['callback'] = function(result){ after_callback(); };
276 BootstrapDialog.alert(config);
281 * @param string type アラートタイプ(空文字列,info,notice,success,failure,warinig,error)
282 * @param string message メッセージ
283 * @param function callback ボタンが押されときのコールバック関数(第1引数1にOK(true),キャンセル(false)が渡る。)
284 * @param string title タイトル
287 function m3Confirm(type, message, callback, title)
295 //dialogType = BootstrapDialog.TYPE_DEFAULT;
296 dialogType = BootstrapDialog.TYPE_INFO;
299 dialogType = BootstrapDialog.TYPE_INFO;
302 dialogType = BootstrapDialog.TYPE_PRIMARY;
305 dialogType = BootstrapDialog.TYPE_SUCCESS;
308 dialogType = BootstrapDialog.TYPE_WARNING;
311 dialogType = BootstrapDialog.TYPE_WARNING;
314 dialogType = BootstrapDialog.TYPE_DANGER;
345 new BootstrapDialog({
354 label: BootstrapDialog.DEFAULT_TEXTS.CANCEL,
355 action: function(dialog) {
356 typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
360 label: BootstrapDialog.DEFAULT_TEXTS.OK,
361 cssClass: 'btn-primary',
362 action: function(dialog) {
363 typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
372 * @param function seturl_callback コールバック関数
375 function m3OpenFileBrowser(seturl_callback)
377 $('<div />').dialog({
380 width: $(window).width() * M3_FILEBROWSER_WIDTH_RATIO,
382 $(this).parent().css("padding", "0px");
383 $(this).css("padding", "0px");
385 create: function(event, ui){
387 url : M3_ROOT_URL + '/scripts/elfinder-' + M3_FILEBROWSER_VER + '/php/connector.php?dirtype=file',
391 ui: ['toolbar', 'places', 'tree', 'path', 'stat'],
392 getFileCallback: function(url){
393 seturl_callback(url.url);
394 $('.ui-dialog-titlebar-close[role="button"]').click();
396 }).elfinder('instance');
403 * @param function seturl_callback コールバック関数
406 function m3OpenImageFileBrowser(seturl_callback)
408 $('<div />').dialog({
411 width: $(window).width() * M3_FILEBROWSER_WIDTH_RATIO,
413 $(this).parent().css("padding", "0px");
414 $(this).css("padding", "0px");
416 create: function(event, ui){
418 url : M3_ROOT_URL + '/scripts/elfinder-' + M3_FILEBROWSER_VER + '/php/connector.php?dirtype=image',
422 ui: ['toolbar', 'places', 'tree', 'path', 'stat'],
423 getFileCallback: function(url){
424 seturl_callback(url.url);
425 $('.ui-dialog-titlebar-close[role="button"]').click();
427 }).elfinder('instance');
434 * @param function seturl_callback コールバック関数
437 function m3OpenFlashFileBrowser(seturl_callback)
439 $('<div />').dialog({
442 width: $(window).width() * M3_FILEBROWSER_WIDTH_RATIO,
444 $(this).parent().css("padding", "0px");
445 $(this).css("padding", "0px");
447 create: function(event, ui){
449 url : M3_ROOT_URL + '/scripts/elfinder-' + M3_FILEBROWSER_VER + '/php/connector.php?dirtype=flash',
453 ui: ['toolbar', 'places', 'tree', 'path', 'stat'],
454 getFileCallback: function(url){
455 seturl_callback(url.url);
456 $('.ui-dialog-titlebar-close[role="button"]').click();
458 }).elfinder('instance');
463 * TextAreaをHTMLエディターに変更
465 * @param string id TextAreaタグのIDまたはname
466 * @param bool isMobile 携帯用のツールバー表示
469 function m3_setHtmlEditor(id, isMobile)
471 var oFCKeditor = new FCKeditor(id);
472 oFCKeditor.BasePath = M3_ROOT_URL + '/scripts/fckeditor2.6.6/';
473 oFCKeditor.Config['CustomConfigurationsPath'] = M3_ROOT_URL + '/scripts/m3/fckconfig.js';
474 if (isMobile == null || isMobile == false){
475 oFCKeditor.ToolbarSet = "M3Default"; // ツールバーリソース名
477 oFCKeditor.ToolbarSet = "M3MobileDefault"; // ツールバーリソース名
479 oFCKeditor.Width = "100%";
480 oFCKeditor.Height = "100%";
481 oFCKeditor.Value = 'This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.';
482 oFCKeditor.ReplaceTextarea();
485 * TextAreaをWYSIWYGエディターに変更
487 * @param string id TextAreaタグのIDまたはname
488 * @param int height エディター領域の高さ
489 * @param bool toolbarVisible ツールバーを表示するかどうか
490 * @param string barType ツールバータイプ(full=全項目,layout=レイアウト用,small=小画面デバイス用)
491 * @param int width エディター領域の幅
494 function m3SetWysiwygEditor(id, height, toolbarVisible, barType, width)
496 // CKEditor v 4.4のiPhone,AndroidのWebブラウザのアクセス制限を解除(2017/1/21)
497 if ( !CKEDITOR.env.ie || CKEDITOR.env.version > 7 ) CKEDITOR.env.isCompatible = true;
500 _m3SetAccessPoint(M3_CONFIG_WIDGET_DEVICE_TYPE);
502 if (M3_WYSIWYG_EDITOR == 'ckeditor'){
505 config['customConfig'] = M3_ROOT_URL + '/scripts/m3/ckconfig.js';
506 if (height) config['height'] = height;
507 if (width) config['width'] = width;
508 if (toolbarVisible != null && !toolbarVisible) config['toolbarStartupExpanded'] = false;
514 config['toolbar'] = 'Full';
515 if (typeof(M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES) != "undefined") config['contentsCss'] = M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES;
518 config['toolbar'] = 'Layout';
519 if (typeof(M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES) != "undefined") config['contentsCss'] = M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES;
522 config['toolbar'] = 'Small';
526 config['toolbar'] = 'Full';
527 if (typeof(M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES) != "undefined") config['contentsCss'] = M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES;
529 CKEDITOR.replace(id, config);
531 var oFCKeditor = new FCKeditor(id);
532 oFCKeditor.BasePath = M3_ROOT_URL + '/scripts/fckeditor2.6.6/';
533 oFCKeditor.Config['CustomConfigurationsPath'] = M3_ROOT_URL + '/scripts/m3/fckconfig.js';
534 oFCKeditor.ToolbarSet = "M3Default"; // ツールバーリソース名
535 if (height) oFCKeditor.Height = String(height) + 'px';
536 oFCKeditor.Value = 'This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.';
537 oFCKeditor.ReplaceTextarea();
541 * TextAreaをスクリプト編集エディターに変更
543 * @param string id TextAreaタグのIDまたはname
544 * @param int height エディター領域の高さ
547 function m3SetScriptEditor(id, height)
549 if (typeof CodeMirror == 'undefined') return;
552 obj = document.getElementById(id);
553 if (!obj) obj = document.getElementsByName(id);
554 if (!obj) alert(id + "not found.");
555 var editor = CodeMirror.fromTextArea(obj, {
559 extraKeys: {"Enter": "newlineAndIndentContinueComment"}
561 if (height) editor.setSize('100%', height);
562 /* if (M3_WYSIWYG_EDITOR == 'ckeditor'){
564 config['customConfig'] = M3_ROOT_URL + '/scripts/m3/ckconfig_script.js';
565 if (height) config['height'] = height;
566 CKEDITOR.replace(id, config);
571 * CKEditorツールバー機能の直接実行準備
575 function m3LoadCKTools()
577 var dummyCKParent = $('#_dummy_ck_parent');
578 if (!dummyCKParent[0]){
579 var dummyHtml = '<div id="_dummy_ck_parent"><textarea type="text" id="_dummy_ckeditor" ></textarea></div>';
580 $("body").append(dummyHtml);
582 dummyCKParent = $('#_dummy_ck_parent');
585 // config['customConfig'] = M3_ROOT_URL + '/scripts/m3/ckconfig_direct.js';
586 config['customConfig'] = M3_ROOT_URL + '/scripts/m3/ckconfig.js';
587 config['extraPlugins'] = 'linkinfo';
588 CKEDITOR.replace('_dummy_ckeditor', config);
589 dummyCKParent.hide();
594 * @param int deviceType デバイスタイプ(0=PC,1=携帯,2=スマートフォン)
597 function _m3SetAccessPoint(deviceType)
599 // アクセスポイント(空=PC,m=携帯,s=スマートフォン)取得
613 _m3AccessPoint = accessPoint;
618 * @param int deviceType デバイスタイプ(0=PC,1=携帯,2=スマートフォン)
619 * @param string url URL初期値
620 * @param function seturl_callback コールバック関数
623 function m3CreateLinkUrl(deviceType, url, seturl_callback)
625 // アクセスポイント(空=PC,m=携帯,s=スマートフォン)取得
639 _m3AccessPoint = accessPoint;
641 _m3SetUrlCallback = seturl_callback;
643 var dummyCKParent = $('#_dummy_ck_parent');
644 dummyCKParent.show(); // IE8バグ回避用
645 CKEDITOR.instances['_dummy_ckeditor'].execCommand( 'linkinfo' );
646 dummyCKParent.hide(); // IE8バグ回避用
649 * 「前へ」ボタンのクリックイベントにコールバックを設定
651 * @param function callback コールバック関数
652 * @param string param コールバック用パラメータ
655 function m3SetPrevButtonEvent(callback, param)
657 if (typeof(callback) == 'function'){
658 $('#m3configprev').click(function(){
661 $('.m3configprev').show();
665 * 「次へ」ボタンのクリックイベントにコールバックを設定
667 * @param function callback コールバック関数
668 * @param string param コールバック用パラメータ
671 function m3SetNextButtonEvent(callback, param)
673 if (typeof(callback) == 'function'){
674 $('#m3confignext').click(function(){
677 $('.m3confignext').show();
685 function m3SetSafeContentEdit()
687 _m3ContentEdited = false; // 入力コンテンツが変更されたかどうか
688 _m3CheckContentEdit = true; // 入力コンテンツの変更をチェックするかどうか
690 $(window).bind("beforeunload", function(){
691 // CKEditorの入力内容の変更を確認
692 var ckeChanged = false;
693 if (typeof CKEDITOR !== 'undefined' && CKEDITOR.instances){
694 for (instance in CKEDITOR.instances){
695 ckeChanged = CKEDITOR.instances[instance].checkDirty();
696 if (ckeChanged) break;
700 if (_m3CheckContentEdit && (_m3ContentEdited || ckeChanged)){
701 _m3CheckContentEdit = false;
702 setTimeout(function(){
703 _m3CheckContentEdit = true;
705 return "このページを離れようとしています。";
708 /* $("form input, form select, form textarea").change(function(){
709 _m3ContentEdited = true;
711 // Firefox対応(2015/12/1)
712 $("form input:not(.noeditcheck), form select, form textarea").change(function(){
713 _m3ContentEdited = true;
721 function m3CancelSafeContentEdit()
723 $(window).unbind("beforeunload");
728 * @param object parentObj 親オブジェクトまたはタグID
731 function m3SetHelp(parentObj)
734 if (typeof parentObj == 'string'){
735 parentObj = $('#' + parentObj);
737 if (jQuery().cluetip){
738 parentObj.find('span.m3help').cluetip({ splitTitle: '|', cluezIndex: 2000, hoverIntent:{ sensitivity:1, interval:500, timeout:0 }});
739 parentObj.find('div.m3help').cluetip({ splitTitle: '|', cluezIndex: 2000, hoverIntent:{ sensitivity:1, interval:500, timeout:0 }});
741 if (jQuery().tooltip) parentObj.find('[rel=m3help]').tooltip({ 'delay': { show: 1000, hide: 0 }});
743 if (jQuery().cluetip){
744 $('span.m3help').cluetip({ splitTitle: '|', cluezIndex: 2000, hoverIntent:{ sensitivity:1, interval:500, timeout:0 }});
745 $('div.m3help').cluetip({ splitTitle: '|', cluezIndex: 2000, hoverIntent:{ sensitivity:1, interval:500, timeout:0 }});
747 if (jQuery().tooltip) $('[rel=m3help]').tooltip({ 'delay': { show: 1000, hide: 0 }});
755 function m3SetFileSelectButton()
757 $('.btn-file :file').on('fileselect', function(event, numFiles, label){
758 var input = $(this).parents('.input-group').find(':text'),
759 log = numFiles > 1 ? numFiles + ' files selected' : label;
768 $(document).on('change', '.btn-file :file', function(){
770 numFiles = input.get(0).files ? input.get(0).files.length : 1,
771 label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
772 input.trigger('fileselect', [numFiles, label]);
778 * @param object object テーブルオブジェクトまたはテーブルID文字列
781 function m3SetConfigTable(object)
783 var tableObj; // テーブルオブジェクト
785 if (typeof object == 'string'){
786 //tableObj = document.getElementById(object);
787 tableObj = $('#' + object);
792 tableObj.addClass('table table-condensed table-bordered table-striped m3config_table');
793 tableObj.find('th').addClass('info'); // ヘッダ部
795 tableObj.find('textarea').addClass('form-control');
796 tableObj.find('select').addClass('form-control');
797 tableObj.find('input[type=text]').addClass('form-control');
798 tableObj.find('input[type=password]').addClass('form-control');
803 * @param object object テーブルオブジェクトまたはテーブルID文字列
806 function m3SetConfigSubTable(object)
808 var tableObj; // テーブルオブジェクト
810 if (typeof object == 'string'){
811 //tableObj = document.getElementById(object);
812 tableObj = $('#' + object);
817 tableObj.addClass('table table-condensed table-bordered table-striped');
818 tableObj.find('th').addClass('info'); // ヘッダ部
820 tableObj.find('select').addClass('form-control');
821 tableObj.find('input[type=text]').addClass('form-control');
826 * @param object object テーブルオブジェクトまたはテーブルID文字列
829 function m3SetModalTable(object)
831 var tableObj; // テーブルオブジェクト
833 if (typeof object == 'string'){
834 tableObj = document.getElementById(object);
839 $(tableObj).addClass('table table-condensed table-bordered table-striped m3config_modal_table');
840 $(tableObj).find('th').addClass('info'); // ヘッダ部
845 * @param object object テーブルオブジェクトまたはテーブルID文字列
846 * @param function reorder_callback 並び替え時コールバック関数
847 * @return bool true=作成成功、false=作成失敗
849 function m3SetDragDropTable(object, reorder_callback)
851 if (!jQuery().tableDnD) return false;
853 var tableObj; // テーブルオブジェクト
855 if (typeof object == 'string'){
856 tableObj = $('#' + object);
862 tableObj.find('tr').attr('id',function(i){
863 return 'm3drag_rowid_' + i;
868 onDrop: function(table, row){
869 _setupDragDropTable(tableObj, reorder_callback);
871 dragHandle: ".m3drag_handle"
873 tableObj.find('tr.m3drag_row').hover(function(){
874 $(this.cells[0]).addClass('m3drag_current');
876 $(this.cells[0]).removeClass('m3drag_current');
880 tableObj.find('tr .m3drag_delrow').off('click').on('click', function(){
881 var rowObj = $(this);
883 m3Confirm('waring', '項目を削除しますか?', function(result){
885 rowObj.parents('.m3drag_row').fadeTo(400, 0, function(){
888 _setupDragDropTable(tableObj, reorder_callback);
896 _setupDragDropTable(tableObj, reorder_callback);
899 m3SetConfigSubTable(tableObj);
909 * @param object object テーブルオブジェクトまたはテーブルID文字列
910 * @param function callback コールバック関数
913 function _setupDragDropTable(object, callback)
916 object.find('tr .m3drag_rowno').each(function(index){
917 $(this).text(index + 1);
921 if (typeof(callback) == 'function') callback();
924 * ドラッグ&ドロップファイルアップロード機能を作成
926 * @param string id 表示領域タグID
927 * @param string url アップロード先URL
928 * @param function callback 成功時コールバック関数
929 * @param string extensions アップロード許可するファイルの拡張子を「,」区切りで列挙
930 * @return bool true=作成成功、false=作成失敗
932 function m3CreateDragDropUploadFile(id, url, callback, extensions)
934 if (!jQuery().uploadFile) return false;
936 if (!extensions) extensions = 'png,gif,jpg,jpeg';
938 var artisteerStyle = false;
939 var bootstrapStyle = true;
941 $('#' + id).uploadFile({
943 allowedTypes: extensions,
944 showFileCounter: false, // ファイルNoなし
946 artisteerStyle: artisteerStyle,
947 bootstrapStyle: bootstrapStyle,
952 customErrorKeyStr: 'error',
957 onSuccess:function(files, data)
959 if (typeof(callback) == 'function') callback(files, data);
967 * @param string switchButtonClass 切り替えボタンのクラス
970 function m3SetupWidgetTool(switchButtonClass)
972 $('.' + switchButtonClass).each(function ()
975 var $widget = $(this);
976 var $button = $widget.find('button');
977 var $checkbox = $widget.find('input:checkbox');
978 var color = $button.data('color'),
981 icon: 'glyphicon glyphicon-check'
984 icon: 'glyphicon glyphicon-unchecked'
989 $button.on('click', function ()
991 // チェックボックスの状態を変更し、ボタンを再描画
992 $checkbox.prop('checked', !$checkbox.is(':checked'));
993 // $checkbox.triggerHandler('change');
999 $checkbox.on('change', function ()
1005 function updateButton()
1007 var isChecked = $checkbox.is(':checked');
1009 // Set the button's state
1010 $button.data('state', (isChecked) ? "on" : "off");
1012 // Set the button's icon
1013 $button.find('.state-icon').removeClass().addClass('state-icon ' + settings[$button.data('state')].icon);
1015 // Update the button's color
1017 $button.removeClass('btn-default').addClass('btn-' + color + ' active');
1019 $button.removeClass('btn-' + color + ' active').addClass('btn-default');
1024 function updateWidgetTool()
1026 var isChecked = $checkbox.is(':checked');
1028 _m3ShowWidgetTool = true; // ウィジェットツールを表示するかどうか
1031 $.cookie('M3WIDGETTOOL', 'on', { expires: 30 });
1033 _m3ShowWidgetTool = false; // ウィジェットツールを表示するかどうか
1036 $.cookie('M3WIDGETTOOL', 'off', { expires: 30 });
1043 var status = $.cookie('M3WIDGETTOOL');
1044 if (status == "undefined") status = 'on'; // 初期値設定
1045 if (status == 'on'){
1046 $checkbox.prop('checked', true);
1048 $checkbox.prop('checked', false);
1055 // Inject the icon if applicable
1056 if ($button.find('.state-icon').length == 0){
1057 $button.prepend('<i class="state-icon ' + settings[$button.data('state')].icon + '"></i> ');
1066 * @param string showButtonId 表示ボタンのタグID
1067 * @param string hideButtonId 非表示ボタンのタグID
1068 * @param string optionAreaClass 表示制御する領域のクラス
1069 * @param bool isShow 拡張領域の初期状態(true=表示、false=非表示)
1072 function m3CreateOptionButton(showButtonId, hideButtonId, optionAreaClass, isShow)
1076 $('.' + optionAreaClass).slideDown(300);
1077 $('#' + showButtonId).css({'display':'none'});
1078 $('#' + hideButtonId).css({'display':'block'});
1080 $('.' + optionAreaClass).slideUp(300);
1081 $('#' + showButtonId).css({'display':'block'});
1082 $('#' + hideButtonId).css({'display':'none'});
1085 $('#' + showButtonId).click(function(){
1086 $('.' + optionAreaClass).slideDown(300);
1087 $('#' + showButtonId).css({'display':'none'});
1088 $('#' + hideButtonId).css({'display':'block'});
1091 m3AdjustParentWindow();
1094 $('#' + hideButtonId).click(function(){
1095 $('.' + optionAreaClass).slideUp(300);
1096 $('#' + showButtonId).css({'display':'block'});
1097 $('#' + hideButtonId).css({'display':'none'});
1100 m3AdjustParentWindow();
1110 //** jQuery Scroll to Top Control script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
1111 //** Available/ usage terms at http://www.dynamicdrive.com (March 30th, 09')
1112 //** v1.1 (April 7th, 09'):
1113 //** 1) Adds ability to scroll to an absolute position (from top of page) or specific element on the page instead.
1114 //** 2) Fixes scroll animation not working in Opera.
1116 //startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
1117 //scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
1118 setting: {startline:100, scrollto: 0, scrollduration:1000, fadeduration:[500, 100]},
1119 controlHTML: '<img src="' + M3_ROOT_URL + '/images/system/gotop48.png" style="width:48px; height:48px" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
1120 controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
1121 anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links
1123 state: {isvisible:false, shouldvisible:false},
1125 scrollup:function(){
1126 if (!this.cssfixedsupport) //if control is positioned using JavaScript
1127 this.$control.css({ opacity:0 }); //hide control immediately after clicking it
1128 var dest = isNaN(this.setting.scrollto) ? this.setting.scrollto : parseInt(this.setting.scrollto);
1129 if (typeof dest == "string" && $('#'+dest).length == 1) //check element set by string exists
1130 dest=$('#'+dest).offset().top;
1133 this.$body.animate({ scrollTop: dest }, this.setting.scrollduration);
1136 keepfixed:function(){
1137 var $window=$(window);
1138 var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx;
1139 var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety;
1140 this.$control.css({ left:controlx+'px', top:controly+'px' });
1143 togglecontrol:function(){
1144 var scrolltop = $(window).scrollTop();
1145 if (!this.cssfixedsupport) this.keepfixed();
1146 this.state.shouldvisible = (scrolltop >= this.setting.startline) ? true : false;
1147 if (this.state.shouldvisible && !this.state.isvisible){
1148 this.$control.stop().animate({ opacity:1 }, this.setting.fadeduration[0]);
1149 this.state.isvisible = true;
1151 else if (this.state.shouldvisible == false && this.state.isvisible){
1152 this.$control.stop().animate({ opacity:0 }, this.setting.fadeduration[1]);
1153 this.state.isvisible = false;
1158 $(document).ready(function($){
1159 var mainobj = scrolltotop;
1160 var iebrws = document.all;
1161 mainobj.cssfixedsupport = !iebrws || iebrws && document.compatMode == "CSS1Compat" && window.XMLHttpRequest; //not IE or IE7+ browsers in standards mode
1162 mainobj.$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
1163 mainobj.$control = $('<div id="topcontrol">' + mainobj.controlHTML + '</div>')
1164 .css({ position:mainobj.cssfixedsupport ? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer' })
1165 .attr({ title:'先頭へスクロール' })
1166 .click(function(){ mainobj.scrollup(); return false; })
1168 if (document.all && !window.XMLHttpRequest && mainobj.$control.text() != '') //loose check for IE6 and below, plus whether control contains any text
1169 mainobj.$control.css({ width:mainobj.$control.width() }); //IE6- seems to require an explicit width on a DIV containing text
1170 mainobj.togglecontrol();
1171 $('a[href="' + mainobj.anchorkeyword + '"]').click(function(){
1175 $(window).bind('scroll resize', function(e){
1176 mainobj.togglecontrol();
1187 $(window).load( function(){ m3SetHelp(); });