JavaScript + Ajax 実践サンプル集 (1276本以上) ◇編集して実行可能◇
jQueryを使い倒せ! jQueryでAjaxを実装するための基礎知識と実践サンプルを一挙公開中... powered by asp.net 3.5
ホーム
jQuery
jQuery プラグイン
jQuery UI
人気順
カテゴリ
キーワード
クール
新着
ツリー
jQuery PDF
ホット
サイト情報
サイトマップ
★ 新着サンプルトップ50のRSSを購読する
◆ DHTMLサンプル(基礎)のRSSを購読する
◆ DHTMLサンプル(応用)のRSSを購読する
◆ AJAXサンプルのRSSを購読する
◆ その他サンプルのRSSを購読する
◆ BOM(Browser Object Model)のRSSを購読する
◆ DOM(Document Object Model)のRSSを購読する
Droppable Photo Manager
説明
コード
分割コード
関連書籍
コメント投稿
このサンプルは、jQueryのdraggable, droppable, resizable, dialogプラグインを使用してシンプルなフォトマネージャを実装しています。イメージのズームアイコンをクリックするとモダル型ダイアログを表示して拡大表示します。ダイアログはドラッグして移動したり、リサイズすることができます。ゴミ箱のアイコンをクリックすると右側の「ゴミ箱」に入れます。イメージをドラッグ&ドロップしてゴミ箱に入れることもできます。 ゴミ箱からリサイクルのアイコンをクリックすると元に復元されます。ゴミ箱からドラッグ&ドロップして取り出すこともできます。
このサンプルを編集して試してみる
jQuery Plugin UI - droppable simple photo manager
Sea 1
View larger
Delete image
Sea 2
View larger
Delete image
Tree 1
View larger
Delete image
Tree 2
View larger
Delete image
Trash
Trash
外部スクリプト
CSS部
HEAD部
BODY部
ボックス内のコードを外部ファイル(*.js)、またはHTMLドキュメントの<HEAD>セクションの<script>タグ内にコピー&ペーストしてください。
$(function() { var $gallery = $('#gallery'), $trash = $('#trash'); $('li', $gallery).draggable({ cancel: 'a.ui-icon', // clicking an icon won't initiate dragging revert: 'invalid', // when not dropped, the item will revert back to its initial position containment: $('#demo-frame').length ? '#demo-frame' : 'document', // stick to demo-frame if present helper: 'clone', cursor: 'move' }); $trash.droppable({ accept: '#gallery > li', activeClass: 'ui-state-highlight', drop: function(ev, ui) { deleteImage(ui.draggable); } }); $gallery.droppable({ accept: '#trash li', activeClass: 'custom-state-active', drop: function(ev, ui) { recycleImage(ui.draggable); } }); // image deletion function var recycle_icon = '
Recycle image
'; function deleteImage($item) { $item.fadeOut(function() { var $list = $('ul', $trash).length ? $('ul', $trash) : $('
').appendTo($trash); $item.find('a.ui-icon-trash').remove(); $item.append(recycle_icon).appendTo($list).fadeIn(function() { $item.animate({ width: '48px' }).find('img').animate({ height: '36px' }); }); }); } // image recycle function var trash_icon = '
Delete image
'; function recycleImage($item) { $item.fadeOut(function() { $item.find('a.ui-icon-refresh').remove(); $item.css('width', '96px').append(trash_icon).find('img').css('height', '72px').end().appendTo($gallery).fadeIn(); }); } // image preview function, demonstrating the ui.dialog used as a modal window function viewLargerImage($link) { var src = $link.attr('href'); var title = $link.siblings('img').attr('alt'); var $modal = $('img[src$="' + src + '"]'); $modal.length ? $modal.dialog('open') : $('
').attr('src', src).appendTo('body').dialog({ title: title, width: '400px', modal: 'true', overlay: { backgroundColor: '#000', opacity: 0.5 } }); } // resolve the icons behavior with event delegation $('ul.gallery > li').click(function(ev) { var $item = $(this); var $target = $(ev.target); if ($target.is('a.ui-icon-trash')) { deleteImage($item); } else if ($target.is('a.ui-icon-zoomin')) { viewLargerImage($target); } else if ($target.is('a.ui-icon-refresh')) { recycleImage($item); } return false; }); });
ボックス内のスタイルシート(CSS)を外部ファイル(*.css)、またはHTMLドキュメントの<HEAD>セクションの<style>タグ内にコピー&ペーストしてください。
#gallery { float: left; width: 65%; min-height: 12em; } * html #gallery { height: 12em; } /* IE6 */ .gallery.custom-state-active { background: #eee; } .gallery li { float: left; width: 96px; padding: 0.4em; margin: 0 0.4em 0.4em 0; text-align: center; } .gallery li h5 { margin: 0 0 0.4em; cursor: move; } .gallery li a { float: right; } .gallery li a.ui-icon-zoomin { float: left; } .gallery li img { width: 100%; cursor: move; } #trash { float: right; width: 32%; min-height: 18em; padding: 1%; } * html #trash { height: 18em; } /* IE6 */ #trash h4 { line-height: 16px; margin: 0 0 0.4em; } #trash h4 .ui-icon { float: left; } #trash .gallery h5 { display: none; }
ボックス内のコードをHTMLドキュメントの<HEAD>セクションにコピー&ペーストしてください。
ボックス内のコードをHTMLドキュメントの<BODY>セクションにコピー&ペーストしてください。
Sea 1
View larger
Delete image
Sea 2
View larger
Delete image
Tree 1
View larger
Delete image
Tree 2
View larger
Delete image
Trash
Trash
コメント・提案の投稿!
名前
メール
件名
本文
送信中です...
ASP.NET 3.5
|
Akio's Blog