Skip to content

Instantly share code, notes, and snippets.

(function($){
// 記事編集画面のカスタマイズ
if (mtappVars.screen_id == 'edit-entry') {
if (mtappVars.site.customfields.blog_is_jpen) {
// 英文タイトルのスタイルを設定
$('#customfield_entry_title_en').addClass('title').attr('placeholder', '英文タイトル');
// フィールドの表示/非表示を切り替えられなくする
$(('#entry_fields-field')).hide();
@tinybeans
tinybeans / user.js
Created April 16, 2020 04:15
MTAppInCats と MTAppTabs の組み合わせの代替案
(function($){
// $.MTAppCategorySwitch({
// selector: {
// 'init': '#title-field',
// 'hide':
// '#text-field,#excerpt-field,#customfield_entryogimage-field,#customfield_entryeyecatch-field,#customfield_entryappendix-field,#customfield_entrycontact-field,#customfield_entrylinkurl-field',
// 'cat49':
// '#title-field,#text-field,#excerpt-field,#customfield_entryogimage-field,#customfield_entryeyecatch-field,#customfield_entryappendix-field,#customfield_entrycontact-field',
// 'cat50':
@tinybeans
tinybeans / user.js
Created February 8, 2019 02:25
サイトに埋め込むパーツを「MTAppjQuery 2 +コンテンツデータ」で管理してみよう
(function($){
// 特定のコンテンツタイプだけにカスタマイズを適用する
if (mtappVars.type.indexOf('content_data') !== -1 && mtappVars.content_type_id == 5) {
// コンテンツフィールドのIDを指定します。
// ブラウザの開発者ツールで入力欄(今回は「オススメ書籍一覧」」フィールドのテキストエリア)を確認し、
// <input type="text" name="content-field-47" となっている 47 部分が該当します。
const contentFieldId = '47';
mtappVars.DataAPI.getContentData(31, 3, 3, function (res) {
const cd = jQuery.extend({}, res);
for (let i = 0; i < cd.data.length; i++) {
if (cd.data[i].label === "取扱店舗") {
cd.data[i].data = null;
}
}
mtappVars.DataAPI.updateContentData(31, 3, 3, cd, function (newCd) {
console.log(newCd);
});
@tinybeans
tinybeans / MTAppListingMultiBlog.js
Created July 14, 2016 04:28
MTAppListing で Data API で複数のブログから取得した記事を扱うサンプル
(function($){
// MTAppjQuery v1.9.0 以前のバージョンの場合は下記が必要
$.extend({
objectSort: function(array, key, order, type) {
order = (order === 'ascend') ? -1 : 1;
array.sort(function(obj1, obj2){
var v1 = obj1[key];
var v2 = obj2[key];
if (type === 'numeric') {
@tinybeans
tinybeans / MTAppListingEntryGroup.js
Created July 13, 2016 23:20
MTAppListing でブログ記事グループ的なことをやってみる(カテゴリ追加)
(function($){
// 元記事:http://bit-part.net/blog/2015/01/mtapplisting.html
$('#customfield_bpentrylist').MTAppListing({
url: '<mt:Var name="config.CGIPath"><mt:Var name="config.DataAPIScript">/v1/sites/<mt:BlogID>/entries',
data: {
limit: 9999999,
// categories を追加します
fields: 'id,title,categories'
},
@tinybeans
tinybeans / MTAppAssetFields.js
Last active August 12, 2016 12:26
MTAppAssetFields.js
(function($){
// ---------------------------------------------------------------------
// $(foo).MTAppAssetFields();
// ---------------------------------------------------------------------
// Latest update: 2016/07/01
//
// input:text で MT 標準の「アイテム」ダイアログを利用できるようにします。
// id, filename, url, thumnail(imageのみ)の値を JSON で保存します。
// ---------------------------------------------------------------------
@tinybeans
tinybeans / MTAppTemplateSelectorWidget.js
Last active June 24, 2016 01:26
$.MTAppTemplateSelectorWidget();
(function($){
// ---------------------------------------------------------------------
// $.MTAppTemplateSelectorWidget();
// ---------------------------------------------------------------------
// Latest update: 2016/06/24
//
// テンプレートの編集画面に、テンプレート一覧のドロップダウンリストウィジェットを追加し、
// 選択したテンプレートの編集画面にジャンプします。
//
<mt:EntryJSONTableItems>
<mt:IfEntryJSONTableItem key=“foo">
<mt:EntryJSONTableItem key=“foo”>
</mt:IfEntryJSONTableItem>
<mt:Else>
do something when items is empty
</mt:EntryJSONTableItems>
@tinybeans
tinybeans / 0_reuse_code.js
Created March 10, 2016 05:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console