彈出層-非jquery

 轉自http://www.iteye.com/topic/1117866 本人備忘 感謝原作

 

[img][/img]先讓我們看看他提供的幾種皮膚吧











功能:
Java代碼 複製代碼
  1. 1. 傳入字符串   
  2. art.dialog({   
  3.     content: '我支持HTML'  
  4. });  
1. 傳入字符串
art.dialog({
    content: '我支持HTML'
});

效果:

Java代碼 複製代碼 收藏代碼
  1. 2. 傳入HTMLElement   
  2. 備註:1、元素不是複製而是完整移動到對話框中,所以原有的事件與屬性都將會保留 2、如果隱藏元素被傳入到對話框,會設置display:block屬性顯示該元素 3、對話框關閉的時候元素將恢復到原來在頁面的位置,style display屬性也將恢復   
  3.   
  4. ********************************************************************************************   
  5. 只前這個東東也是朋友完我的,後來經剛剛一位朋友提醒,我google一下,現在完整的教程都在裏面,所有包都在裏面。   
  6. 我也不好意思,現在補充下。呵呵,因爲不算晚吧。   
  7. art.dialog({   
  8.     content: document.getElementById('demoCode_content_DOM'),   
  9.     id: 'EF893L'  
  10. });  
2. 傳入HTMLElement
備註:1、元素不是複製而是完整移動到對話框中,所以原有的事件與屬性都將會保留 2、如果隱藏元素被傳入到對話框,會設置display:block屬性顯示該元素 3、對話框關閉的時候元素將恢復到原來在頁面的位置,style display屬性也將恢復

********************************************************************************************
只前這個東東也是朋友完我的,後來經剛剛一位朋友提醒,我google一下,現在完整的教程都在裏面,所有包都在裏面。
我也不好意思,現在補充下。呵呵,因爲不算晚吧。
art.dialog({
    content: document.getElementById('demoCode_content_DOM'),
    id: 'EF893L'
});

效果:把指定的div加載到這個彈框上

Java代碼 複製代碼 收藏代碼
  1. 標題 [title]   
  2. art.dialog({   
  3.     title: 'hello world!'  
  4. });  
標題 [title]
art.dialog({
    title: 'hello world!'
});

效果:
Java代碼 複製代碼 收藏代碼
  1. 確定取消按鈕 [ok & cancel]   
  2. 備註:回調函數this指向擴展接口,如果返回false將阻止對話框關閉   
  3. art.dialog({   
  4.     content: '如果定義了回調函數纔會出現相應的按鈕',   
  5.     ok: function () {   
  6.         this.title('3秒後自動關閉').time(3);   
  7.         return false;   
  8.     },   
  9.     cancelVal: '關閉',   
  10.     cancel: true //爲true等價於function(){}   
  11. });  
確定取消按鈕 [ok & cancel]
備註:回調函數this指向擴展接口,如果返回false將阻止對話框關閉
art.dialog({
    content: '如果定義了回調函數纔會出現相應的按鈕',
    ok: function () {
    	this.title('3秒後自動關閉').time(3);
        return false;
    },
    cancelVal: '關閉',
    cancel: true //爲true等價於function(){}
});

效果:
Java代碼 複製代碼 收藏代碼
  1. 自定義按鈕 [button]   
  2. 備註:回調函數this指向擴展接口,如果返回false將阻止對話框關閉;button參數對應的擴展方法名稱也是"button"  
  3. art.dialog({   
  4.     id: 'testID',   
  5.     content: 'hello world!',   
  6.     button: [   
  7.         {   
  8.             name: '同意',   
  9.             callback: function () {   
  10.                 this.content('你同意了').time(2);   
  11.                 return false;   
  12.             },   
  13.             focus: true  
  14.         },   
  15.         {   
  16.             name: '不同意',   
  17.             callback: function () {   
  18.                 alert('你不同意')   
  19.             }   
  20.         },   
  21.         {   
  22.             name: '無效按鈕',   
  23.             disabled: true  
  24.         },   
  25.         {   
  26.             name: '關閉我'  
  27.         }   
  28.     ]   
  29. });  
自定義按鈕 [button]
備註:回調函數this指向擴展接口,如果返回false將阻止對話框關閉;button參數對應的擴展方法名稱也是"button"
art.dialog({
    id: 'testID',
    content: 'hello world!',
    button: [
        {
            name: '同意',
            callback: function () {
                this.content('你同意了').time(2);
                return false;
            },
            focus: true
        },
        {
            name: '不同意',
            callback: function () {
                alert('你不同意')
            }
        },
        {
            name: '無效按鈕',
            disabled: true
        },
        {
            name: '關閉我'
        }
    ]
});

效果:
Java代碼 複製代碼 收藏代碼
  1. 定時關閉的消息 [time]   
  2. art.dialog({   
  3.     time: 2,   
  4.     content: '兩秒後關閉'  
  5. });  
定時關閉的消息 [time]
art.dialog({
    time: 2,
    content: '兩秒後關閉'
});

效果:2秒後關閉這個只有看纔看得到效果截圖不行

Java代碼 複製代碼 收藏代碼
  1. 定義消息圖標 [icon]   
  2. 請查看skin/icons目錄下的圖標   
  3. art.dialog({   
  4.     icon: 'succeed',   
  5.     content: '我可以定義消息圖標哦'  
  6. });  
定義消息圖標 [icon]
請查看skin/icons目錄下的圖標
art.dialog({
    icon: 'succeed',
    content: '我可以定義消息圖標哦'
});

圖標有好幾種就拿這個success效果圖給大家看下:

Java代碼 複製代碼 收藏代碼
  1. 鎖屏 [lock & background & opacity]   
  2. art.dialog({   
  3.     lock: true,   
  4.     background: '#600'// 背景色   
  5.     opacity: 0.87,  // 透明度   
  6.     content: '中斷用戶在對話框以外的交互,展示重要操作與消息',   
  7.     icon: 'error',   
  8.     ok: function () {   
  9.         art.dialog({content: '再來一個鎖屏', lock: true});   
  10.         return false;   
  11.     },   
  12.     cancel: true  
  13. });  
鎖屏 [lock & background & opacity]
art.dialog({
    lock: true,
    background: '#600', // 背景色
    opacity: 0.87,	// 透明度
    content: '中斷用戶在對話框以外的交互,展示重要操作與消息',
    icon: 'error',
    ok: function () {
        art.dialog({content: '再來一個鎖屏', lock: true});
        return false;
    },
    cancel: true
});

效果:這是個鎖屏的你可自定義背景顏色和圖標等等一些屬性

Java代碼 複製代碼 收藏代碼
  1. 自定義座標 [left & top]   
  2. art.dialog({   
  3.     left: 100,   
  4.     top: '60%',   
  5.     content: '我改變座標了'  
  6. });  
自定義座標 [left & top]
art.dialog({
    left: 100,
    top: '60%',
    content: '我改變座標了'
});

效果:自定義座標 傳X,Y就可以啦

Java代碼 複製代碼 收藏代碼
  1. 創建一個全屏對話框   
  2. art.dialog({   
  3.     width: '100%',   
  4.     height: '100%',   
  5.     left: '0%',   
  6.     top: '0%',   
  7.     fixed: true,   
  8.     resize: false,   
  9.     drag: false  
  10. })  
創建一個全屏對話框
art.dialog({
    width: '100%',
    height: '100%',
    left: '0%',
    top: '0%',
    fixed: true,
    resize: false,
    drag: false
})


Java代碼 複製代碼 收藏代碼
  1. 右下角滑動通知   
  2. artDialog.notice = function (options) {   
  3.     var opt = options || {},   
  4.         api, aConfig, hide, wrap, top,   
  5.         duration = 800;   
  6.            
  7.     var config = {   
  8.         id: 'Notice',   
  9.         left: '100%',   
  10.         top: '100%',   
  11.         fixed: true,   
  12.         drag: false,   
  13.         resize: false,   
  14.         follow: null,   
  15.         lock: false,   
  16.         init: function(here){   
  17.             api = this;   
  18.             aConfig = api.config;   
  19.             wrap = api.DOM.wrap;   
  20.             top = parseInt(wrap[0].style.top);   
  21.             hide = top + wrap[0].offsetHeight;   
  22.                
  23.             wrap.css('top', hide + 'px')   
  24.                 .animate({top: top + 'px'}, duration, function () {   
  25.                     opt.init && opt.init.call(api, here);   
  26.                 });   
  27.         },   
  28.         close: function(here){   
  29.             wrap.animate({top: hide + 'px'}, duration, function () {   
  30.                 opt.close && opt.close.call(this, here);   
  31.                 aConfig.close = $.noop;   
  32.                 api.close();   
  33.             });   
  34.                
  35.             return false;   
  36.         }   
  37.     };     
  38.        
  39.     for (var i in opt) {   
  40.         if (config[i] === undefined) config[i] = opt[i];   
  41.     };   
  42.        
  43.     return artDialog(config);   
  44. };   
  45. 調用示例:   
  46. art.dialog.notice({   
  47.     title: '萬象網管',   
  48.     width: 220,// 必須指定一個像素寬度值或者百分比,否則瀏覽器窗口改變可能導致artDialog收縮   
  49.     content: '尊敬的顧客朋友,您IQ卡餘額不足10元,請及時充值',   
  50.     icon: 'face-sad',   
  51.     time: 5  
  52. });  
右下角滑動通知
artDialog.notice = function (options) {
    var opt = options || {},
        api, aConfig, hide, wrap, top,
        duration = 800;
        
    var config = {
        id: 'Notice',
        left: '100%',
        top: '100%',
        fixed: true,
        drag: false,
        resize: false,
        follow: null,
        lock: false,
        init: function(here){
            api = this;
            aConfig = api.config;
            wrap = api.DOM.wrap;
            top = parseInt(wrap[0].style.top);
            hide = top + wrap[0].offsetHeight;
            
            wrap.css('top', hide + 'px')
                .animate({top: top + 'px'}, duration, function () {
                    opt.init && opt.init.call(api, here);
                });
        },
        close: function(here){
            wrap.animate({top: hide + 'px'}, duration, function () {
                opt.close && opt.close.call(this, here);
                aConfig.close = $.noop;
                api.close();
            });
            
            return false;
        }
    };	
    
    for (var i in opt) {
        if (config[i] === undefined) config[i] = opt[i];
    };
    
    return artDialog(config);
};
調用示例:
art.dialog.notice({
    title: '萬象網管',
    width: 220,// 必須指定一個像素寬度值或者百分比,否則瀏覽器窗口改變可能導致artDialog收縮
    content: '尊敬的顧客朋友,您IQ卡餘額不足10元,請及時充值',
    icon: 'face-sad',
    time: 5
});

效果:模仿網吧右下角通知  帶動畫效果5秒後自動消失

Java代碼 複製代碼 收藏代碼
  1. 跨域訪問   
  2. 跨域訪問無法自適應大小,也無法進行父頁面與子頁面數據交換   
  3. art.dialog.open('http://www.connect.renren.com/igadget/renren/index.html',   
  4.     {title: '人人網', width: 320, height: 400});  
跨域訪問
跨域訪問無法自適應大小,也無法進行父頁面與子頁面數據交換
art.dialog.open('http://www.connect.renren.com/igadget/renren/index.html',
    {title: '人人網', width: 320, height: 400});

效果:
Java代碼 複製代碼 收藏代碼
  1. 加載googleMAP   
  2. art.dialog.open('googleMaps.html');  
加載googleMAP
art.dialog.open('googleMaps.html');

效果圖



對啦忘記說啦要換皮膚只要換上下面圖片上的css文件名就可以啦



****************************************************************
功能太多啦我手軟啦 不寫啦  直接說怎麼用吧
1.導入<script src="artDialog/artDialog.js?skin=default"></script>
2.加上
Java代碼 複製代碼 收藏代碼
  1. (function (config) {   
  2.     config['lock'] = true;   
  3.     config['fixed'] = true;   
  4.     config['okVal'] = 'Ok';   
  5.     config['cancelVal'] = 'Cancel';   
  6.     // [more..]   
  7. })(art.dialog.defaults);//這個是用哪個主題有很多主題的你把名字打上就行啦  
(function (config) {
    config['lock'] = true;
    config['fixed'] = true;
    config['okVal'] = 'Ok';
    config['cancelVal'] = 'Cancel';
    // [more..]
})(art.dialog.defaults);//這個是用哪個主題有很多主題的你把名字打上就行啦




**********************這是googleMap的代碼Copy就行啦沒有問題有問題給我留言不懂就問只要你問我就說***********************************
Java代碼 複製代碼 收藏代碼
  1. <!doctype html>   
  2. <html>   
  3.     <head>   
  4.     <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />   
  5.     <style>   
  6. html { height: 100% }   
  7. body { height: 100%; margin: 0; padding: 0; background-color: #FFF }   
  8. #map_canvas { height: 100% }   
  9. </style>   
  10.     <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=zh_CN"></script>   
  11.     <script>    
  12.         var map, geocoder;   
  13.         function initialize() {   
  14.             var latlng = new google.maps.LatLng(39.904214116.407413);   
  15.             var options = {   
  16.                 zoom: 11,   
  17.                 center: latlng,   
  18.                 disableDefaultUI: true,   
  19.                 panControl: true,   
  20.                 zoomControl: true,   
  21.                 mapTypeControl: true,   
  22.                 scaleControl: true,   
  23.                 streetViewControl: false,   
  24.                 overviewMapControl: true,   
  25.                 mapTypeId: google.maps.MapTypeId.ROADMAP   
  26.             };   
  27.             map = new google.maps.Map(document.getElementById("map_canvas"), options);   
  28.             geocoder = new google.maps.Geocoder();   
  29.             geocoder.geocode({latLng: latlng}, function(results, status) {   
  30.                 if (status == google.maps.GeocoderStatus.OK) {   
  31.                     if (results[3]) {   
  32.                         document.getElementById("map_address").value = results[3].formatted_address;   
  33.                     }   
  34.                 }   
  35.             });   
  36.                
  37.             var dialog = art.dialog.open.api;   
  38.             dialog.title('google mpas')   
  39.             .size(558360)   
  40.             .button({name: '截圖', callback: function () {   
  41.                 var center = map.getCenter().lat() + ',' + map.getCenter().lng(),   
  42.                     zoom = map.getZoom(),   
  43.                     maptype = map.getMapTypeId(),   
  44.                     url = 'http://maps.googleapis.com/maps/api/staticmap';   
  45.                     url += '?center=' + encodeURIComponent(center);   
  46.                     url += '&zoom=' + encodeURIComponent(zoom);   
  47.                     url += '&size=558x360';   
  48.                     url += '&maptype=' + encodeURIComponent(maptype);   
  49.                     url += '&markers=' + encodeURIComponent(center);   
  50.                     url += '&language=zh_CN';   
  51.                     url += '&sensor=false';   
  52.                    
  53.                 art.dialog.through({title: false, content: '<img src="' + url + '" />', padding: 0, width: 558, height: 360, lock: true});   
  54.                    
  55.                 return false;   
  56.             }, focus: true})   
  57.             .position('50%''goldenRatio');   
  58.                
  59.             document.getElementById("map-search-sumbit").onclick = function () {   
  60.                 var input = document.getElementById('map_address');   
  61.                 search(input.value);   
  62.             };   
  63.         }   
  64.         function search(address) {   
  65.             if (!map) return;   
  66.             geocoder.geocode({address : address}, function(results, status) {   
  67.                 if (status == google.maps.GeocoderStatus.OK) {   
  68.                     map.setZoom(11);   
  69.                     map.setCenter(results[0].geometry.location);   
  70.                     var marker = new google.maps.Marker({   
  71.                         map: map,   
  72.                         position: results[0].geometry.location   
  73.                     });   
  74.                 } else {   
  75.                     alert("Invalid address: " + address);   
  76.                 }   
  77.             });   
  78.         }   
  79.     </script>   
  80.     </head>   
  81.     <body onLoad="initialize();" style="font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial;">   
  82.     <div style="width:100%; height:100%">   
  83.       <table style="width:100%;height:100%;">   
  84.         <tr>   
  85.           <td style="height:38px"><div style="margin:5px;">地址:  <input id="map_address"  value="" style="width:200px; padding:4px;"> <button id="map-search-sumbit">搜 索</button></div></td>   
  86.         </tr>   
  87.         <tr>   
  88.           <td style="height:100%"><div id="map_canvas" style="height:100%; margin:0 5px"></div></td>   
  89.         </tr>   
  90.       </table>   
  91.     </div>   
  92. </body>   
  93. </html>  
<!doctype html>
<html>
	<head>
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style>
html { height: 100% }
body { height: 100%; margin: 0; padding: 0; background-color: #FFF }
#map_canvas { height: 100% }
</style>
	<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=zh_CN"></script>
	<script> 
		var map, geocoder;
		function initialize() {
			var latlng = new google.maps.LatLng(39.904214, 116.407413);
			var options = {
				zoom: 11,
				center: latlng,
				disableDefaultUI: true,
				panControl: true,
				zoomControl: true,
				mapTypeControl: true,
				scaleControl: true,
				streetViewControl: false,
				overviewMapControl: true,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			};
			map = new google.maps.Map(document.getElementById("map_canvas"), options);
			geocoder = new google.maps.Geocoder();
			geocoder.geocode({latLng: latlng}, function(results, status) {
				if (status == google.maps.GeocoderStatus.OK) {
					if (results[3]) {
						document.getElementById("map_address").value = results[3].formatted_address;
					}
				}
			});
			
			var dialog = art.dialog.open.api;
			dialog.title('google mpas')
			.size(558, 360)
			.button({name: '截圖', callback: function () {
				var center = map.getCenter().lat() + ',' + map.getCenter().lng(),
					zoom = map.getZoom(),
					maptype = map.getMapTypeId(),
					url = 'http://maps.googleapis.com/maps/api/staticmap';
					url += '?center=' + encodeURIComponent(center);
					url += '&zoom=' + encodeURIComponent(zoom);
					url += '&size=558x360';
					url += '&maptype=' + encodeURIComponent(maptype);
					url += '&markers=' + encodeURIComponent(center);
					url += '&language=zh_CN';
					url += '&sensor=false';
				
				art.dialog.through({title: false, content: '<img src="' + url + '" />', padding: 0, width: 558, height: 360, lock: true});
				
				return false;
			}, focus: true})
			.position('50%', 'goldenRatio');
			
			document.getElementById("map-search-sumbit").onclick = function () {
				var input = document.getElementById('map_address');
				search(input.value);
			};
		}
		function search(address) {
			if (!map) return;
			geocoder.geocode({address : address}, function(results, status) {
				if (status == google.maps.GeocoderStatus.OK) {
					map.setZoom(11);
					map.setCenter(results[0].geometry.location);
					var marker = new google.maps.Marker({
						map: map,
						position: results[0].geometry.location
					});
				} else {
					alert("Invalid address: " + address);
				}
			});
		}
	</script>
	</head>
	<body onLoad="initialize();" style="font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial;">
    <div style="width:100%; height:100%">
      <table style="width:100%;height:100%;">
        <tr>
          <td style="height:38px"><div style="margin:5px;">地址:  <input id="map_address"  value="" style="width:200px; padding:4px;"> <button id="map-search-sumbit">搜 索</button></div></td>
        </tr>
        <tr>
          <td style="height:100%"><div id="map_canvas" style="height:100%; margin:0 5px"></div></td>
        </tr>
      </table>
    </div>
</body>
</html>


還有可以失現很多功能有些功能是我擴展的,改天再說吧,好累。有問題記得給我留言哦,js 和 css在附件裏googlemap代碼我粘貼出來啦記得COpy祝你好運
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章