123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /**
- * yvan.iframe.js
- * @author luoyifan
- * 2018-12-27 10:17:00
- */
- 'use strict';
- (function ($) {
- function resizeMe () {
- var $panel = $(this);
- var $iframe = $panel.down('iframe');
- var state = $.data($iframe[0], 'iframe');
- //state.handle.resize();
- }
- function bindEvents (target) {
- var $panel = $(target).parent();
- if ($panel.data().hasOwnProperty('panel')) {
- $panel.panel({ onResize: resizeMe });
- resizeMe.call($panel[0]);
- }
- }
- function show (target) {
- var state = $.data(target, 'iframe');
- var opts = state.options;
- //state.handle.setOption(opts);
- }
- $.fn.iframe = function (options, param) {
- if (typeof options === 'string') {
- return $.fn.iframe.methods[options](this, param);
- }
- options = options || {};
- return this.each(function () {
- var state = $.data(this, 'iframe');
- if (state) {
- $.extend(state.options, options);
- } else {
- state = $.data(this, 'iframe', {
- options: $.extend({}, $.fn.iframe.defaults, options),
- handle: this
- });
- }
- //setSize(this);
- bindEvents(this);
- show(this);
- });
- };
- $.fn.iframe.methods = {
- options: function (jq) {
- return $.data(jq[0], 'iframe').options;
- },
- refresh: function (jq) {
- jq[0].contentWindow.location.reload(true);
- },
- setOption: function (jq, options) {
- return jq.each(function () {
- var state = $.data(this, 'iframe');
- $.extend(state.options, options);
- show(this);
- });
- }
- };
- //扩展到 power.xtype
- $.extend($.fn.power.defaults.xtype, {
- 'iframe': function ($target, item, context) {
- item.id = item.id || $.yvan.createId('iframe');
- var $dom = $('<iframe src="' + item.src +
- '" scrolling="auto" frameborder="0" style="width:100%;height:100%;"></iframe>');
- $.yvan.fillCommonProperties($dom, item);
- $target.append($dom);
- $dom.iframe(item);
- return $dom;
- }
- });
- $.fn.iframe.defaults = {};
- })(jQuery);
|