From 014b894a9f3eb60a04274951633aa5c621024e69 Mon Sep 17 00:00:00 2001 From: Catouse Date: Wed, 16 Apr 2014 10:04:31 +0800 Subject: [PATCH] * added resize plug to ajust iframe modal height automatically. * moved bgiframe plug to seperate file. --- www/js/jquery/bgiframe/min.js | 10 + www/js/jquery/lib.js | 22 +- www/js/my.min.js | 1143 ++++++++++++++++++++++++++++++++- 3 files changed, 1162 insertions(+), 13 deletions(-) create mode 100644 www/js/jquery/bgiframe/min.js diff --git a/www/js/jquery/bgiframe/min.js b/www/js/jquery/bgiframe/min.js new file mode 100644 index 0000000000..7f6f7cc642 --- /dev/null +++ b/www/js/jquery/bgiframe/min.js @@ -0,0 +1,10 @@ +/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * + * $LastChangedDate: 2007-07-22 01:45:56 +0200 (Son, 22 Jul 2007) $ + * $Rev: 2447 $ + * + * Version 2.1.1 + */ +(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports==="object"){module.exports=a}else{a(jQuery)}}}(function(a){a.fn.bgiframe=function(c){c=a.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:true,src:"javascript:false;",conditional:/MSIE 6\.0/.test(navigator.userAgent)},c);if(!a.isFunction(c.conditional)){var e=c.conditional;c.conditional=function(){return e}}var d=a('".format(options)); + + var modalBody = modal.find('.modal-body'); + if(options.cssClass) + { + modal.find('.modal-dialog').addClass(options.cssClass); + } + var frame = document.getElementById(options.name); + frame.onload = frame.onreadystatechange = function() + { + if (this.readyState && this.readyState != 'complete') return; + + modalBody.css('height', options.height - modal.find('.modal-header').outerHeight()); + + try + { + var $frame = $(window.frames[options.name].document); + if($frame.find('#titlebar').length) + { + modal.addClass('with-titlebar'); + if(options.size == 'fullscreen') + { + modalBody.css('height', options.height); + } + } + if(options.height == 'auto') + { + var $framebody = $frame.find('body'); + setTimeout(function() + { + modalBody.css('height', $framebody.addClass('body-modal').outerHeight()); + modal.removeClass('modal-loading'); + }, 100); + + $framebody.resize(function() + { + modalBody.css('height', $framebody.outerHeight()); + }); + } + + var iframe$ = window.frames[options.name].$; + if(iframe$) + { + iframe$.extend({'closeModal': $.closeModal}); + } + } + catch(e){modal.removeClass('modal-loading');} + } + modal.modal('show'); + } + else + { + $('#ajaxModal').load(url, function() + { + /* Set the width of modal dialog. */ + if($e.data('width')) + { + var modalWidth = parseInt($e.data('width')); + $(this).data('width', modalWidth).find('.modal-dialog').css('width', modalWidth); + } + + /* show the modal dialog. */ + $('#ajaxModal').modal('show'); + }); + } + + /* Save the href to rel attribute thus we can save it. */ + $('#ajaxModal').attr('rel', url); + + return false; + }); + } + + function initModalFrame(setting) + { + if($('#ajaxModal').length) + { + /* unbind all events */ + $('#ajaxModal').off('show.bs.modal shown.bs.modal hide.bs.modal hidden.bs.modal'); + } + else + { + /* Addpend modal div. */ + $('').appendTo('body'); + } + + $ajaxModal = $('#ajaxModal'); + $.extend({'closeModal':function(callback) + { + $ajaxModal.on('hidden.bs.modal', callback); + $ajaxModal.modal('hide'); + }}); + + /* rebind events */ + if(!setting) return; + if(setting.afterShow && $.isFunction(setting.afterShow)) $ajaxModal.on('show.bs.modal', setting.afterShow); + if(setting.afterShown && $.isFunction(setting.afterShown)) $ajaxModal.on('shown.bs.modal', setting.afterShown); + if(setting.afterHide && $.isFunction(setting.afterHide)) $ajaxModal.on('hide.bs.modal', setting.afterHide); + if(setting.afterHidden && $.isFunction(setting.afterHidden)) $ajaxModal.on('hidden.bs.modal', setting.afterHidden); + } + + $('[data-toggle=modal], a.iframe').modalTrigger(); +} + +/** + * Set modal for list page. + * + * Open operation pages in modal for list pages, after the modal window close, reload the list content and repace the replaceID. + * + * @param string colorboxClass the class for colorbox binding. + * @param string replaceID the html object to be replaced. + * @access public + * @return void + */ +function setModal4List(colorboxClass, replaceID, callback, width, height) +{ + if(typeof(width) == 'undefined') width = 900 + if(typeof(height) == 'undefined') height = 500 + $('.' + colorboxClass).modalTrigger( + { + width: width, + // height: height, + type: 'iframe', + + afterHide:function() + { + var selfClose = $.cookie('selfClose'); + if(selfClose != 1) return; + saveWindowSize(); + + var link = self.location.href; + $('#' + replaceID).wrap("
"); + $('#tmpDiv').load(link + ' #' + replaceID, function() + { + $('#tmpDiv').replaceWith($('#tmpDiv').html()); + setModal4List(colorboxClass, replaceID, callback, width, height); + + try{$('.colored').colorize();}catch(err){} + $('tfoot td').css('background', 'white').unbind('click').unbind('hover'); + try + { + $(".date").datePicker({createButton:true, startDate:startDate}) + .dpSetPosition($.dpConst.POS_TOP, $.dpConst.POS_RIGHT) + } + catch(err){} + if(typeof(callback) == 'function') callback(); + $.cookie('selfClose', 0); + }); + } + }); +} + +/** + * Set table behavior + * + * @access public + * @return void + */ +function setTableBehavior() +{ + $('#wrap .table:not(.table-data, .table-form, .active-disabled) tbody tr:not(.active-disabled) td').click(function(){$(this).closest('tr').toggleClass('active');}); + $('#wrap .outer > .table, #wrap .outer > form > .table, #wrap .outer > .mian > .table, #wrap .outer > .mian > form > .table, #wrap .outer > .container > .table').not('.table-data, .table-form').addClass('table table-condensed table-hover table-striped table-borderless tablesorter'); +} + +/** + * Make form condensed + * + * @access public + * @return void + */ +function condensedForm() +{ + $('.form-condensed legend').click(function() + { + $(this).closest('fieldset').toggleClass('collapsed'); + }); +} + +/** + * Update data to the target element synchronous. + * + * @access public + * @return void + */ +function setSyncTrigger() +{ + $("[data-sync-target]").on('input propertychange', function() + { + var $this = $(this); + var val = $this.prop('tagName') == 'INPUT' ? $this.val() : $this.html(); + var target = $($this.attr('data-sync-target')); + console.log(target); + if(target.prop('tagName') == 'INPUT') target.val(val); + else target.html(val); + }); +} + + +/* Ping the server every some minutes to keep the session. */ +needPing = true; + +/* When body's ready, execute these. */ +$(document).ready(function() +{ + condensedForm(); + setModal(); + setTableBehavior(); + setForm(); + saveWindowSize(); + setDebugWin('white'); + setOuterBox(); + + setRequiredFields(); + setPlaceholder(); + + setExport(); + setRepoLink(); + + autoCheck(); + toggleSearch(); + toggleTreeBox(); + + setSyncTrigger(); + + hideClearDataLink(); + + $(window).resize(saveWindowSize); // When window resized, call it again. + + if(needPing) setTimeout('setPing()', 1000 * 60); // After 5 minutes, begin ping. + + $('.export').bind('click', function() + { + var checkeds = ''; + $(':checkbox').each(function() + { + if($(this).attr('checked')) + { + var checkedVal = parseInt($(this).val()); + if(checkedVal != 0) checkeds = checkeds + checkedVal + ','; + } + }) + if(checkeds != '') checkeds = checkeds.substring(0, checkeds.length - 1); + $.cookie('checkedItem', checkeds, {expires:config.cookieLife, path:config.webRoot}); + }); +}); + +/* CTRL+g, auto focus on the search box. */ +$(document).bind('keydown', 'Ctrl+g', function(evt) +{ + $('#searchQuery').attr('value', ''); + $('#searchQuery').focus(); + evt.stopPropagation( ); + evt.preventDefault( ); + return false; +}); + +/* left, go to pre object. */ +$(document).bind('keydown', 'left', function(evt) +{ + preLink = ($('#pre').attr("href")); + if(typeof(preLink) != 'undefined') location.href = preLink; +}); + +/* right, go to next object. */ +$(document).bind('keydown', 'right', function(evt) +{ + nextLink = ($('#next').attr("href")); + if(typeof(nextLink) != 'undefined') location.href = nextLink; +});