Skip to content

Instantly share code, notes, and snippets.

@helloGoGo
Created March 8, 2017 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helloGoGo/d3907e496a904e0cb0992585a8062a39 to your computer and use it in GitHub Desktop.
Save helloGoGo/d3907e496a904e0cb0992585a8062a39 to your computer and use it in GitHub Desktop.
"common_dialog.js"を使用したダイアログ表示
<script>
$(function() {
$('#open_hoge_dialog').click(function() {
HogeFugaDialog.open(this.id);
});
$('#open_fuga_dialog').click(function() {
HogeFugaDialog.open(this.id);
});
});
</script>
<input type="button" id="open_hoge_dialog" value="hoge"/>
<input type="button" id="open_fuga_dialog" value="fuga"/>
<div id="hoge_dialog" style="display:none">
<span></span>
</div>
<div id="fuga_dialog" style="display:none">
<span></span>
</div>
/**
* HogeFugaダイアログの表示制御を行う
*/
var HogeFugaDialog = {
/**
* 個別設定を定義する
*/
dialogOpt: {
open_hoge_dialog: {
id: '#hoge_dialog',
},
open_fuga_dialog: {
id: '#fuga_dialog',
position: {
my: 'left top',
at: 'center bottom',
of: '#open_fuga_dialog'
},
}
},
/**
* ダイアログを表示する
* @param {string} id 表示するダイアログを決定するid
*/
open: function(id) {
switch (id) {
case 'open_hoge_dialog':
this.initHogeDialog();
break;
case 'open_fuga_dialog':
this.initFugaDialog();
break;
}
CommonDialog.init(this.dialogOpt[id]);
CommonDialog.open();
},
//-------------------------------------------
// initializer
//-------------------------------------------
/**
* hoge
*/
initHogeDialog: function() {
$('#hoge_dialog').children('span').text('hoge dialog');
},
/**
* fuga
*/
initFugaDialog: function() {
$('#fuga_dialog').children('span').text('fuga dialog');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment