From 02afd8a32edb13ea7fc2266ac80092ea15c0930c Mon Sep 17 00:00:00 2001 From: Alvin Li Date: Wed, 9 Oct 2013 15:52:53 +0800 Subject: * treat 'apps/utils' as regular django app; which used to store general tools for used in other apps * moved 'templatetags' from 'apps/indicator' to 'apps/utils' * '.gitignore' to ignore 'fixtures_bak' * moved js plugins from 'apps/indicator/static/plugins' to 'staticfiles/plugins' apps/recommend: * updated 'recommend.models'; o commented 'recommend.models.ResearchCombination' (not used) * implemented views 'add_edit_blog_info' and 'ajax_add_edit_configs'; * added pages 'templates/recommend/add_edit_blog_info.html', 'add_edit_blog_info_error.html'; o related css and javascripts files * added 'tools.py'; * added 'utils/tools.py' for placing generic functions; * deleted 'initial_data.json' (mv 'fixtures' to 'fixtures_bak'); * small fixes to 'indicator.models', 'sciblog.models' and 'sfaccount.views' * fixed automatically show 'proper_nouns' annotation in blog: recovered the line 'import signals' in 'sciblog.models' * added 'is_ok()' method for 'recommend.models.ResearchConfig'; --- .../static/javascripts/add_edit_blog_info.js | 330 +++++++++++++++++++++ 1 file changed, 330 insertions(+) create mode 100644 97suifangqa/apps/recommend/static/javascripts/add_edit_blog_info.js (limited to '97suifangqa/apps/recommend/static/javascripts') diff --git a/97suifangqa/apps/recommend/static/javascripts/add_edit_blog_info.js b/97suifangqa/apps/recommend/static/javascripts/add_edit_blog_info.js new file mode 100644 index 0000000..1d994e5 --- /dev/null +++ b/97suifangqa/apps/recommend/static/javascripts/add_edit_blog_info.js @@ -0,0 +1,330 @@ +// +// js for 'add_edit_blog_info' page +// +// 2013/10/08 +// + +// a list contains all the configs data objects +var research_configs_list = new Array(); + +$(document).ready(function() { + // make a configs list from 'research_configs {{{ + var obj_keys = Object.keys(research_configs); + for (var i=0; i   '; + }; + $("#cate_btns").html(cate_btns_html); + // button actions + $('#cate_btns input[type="button"]').on("click", document, function() { + // unselect all buttons + //console.log(this); + $('#cate_btns input[type="button"]').removeClass("selected"); + $('#cate_btns input[type="button"]').addClass("unselected"); + $(this).removeClass("unselected"); + $(this).addClass("selected"); + // unselect buttons of combinations + $('#comb_divs input[type="button"]').removeClass("selected"); + $('#comb_divs input[type="button"]').addClass("unselected"); + // hide configs div's + $('#conf_divs .conf_comb').hide(); + // display category of combinations + var cate_id = $(this).attr('id').replace('btn_cate_', ''); + $('#comb_divs .comb').hide(); + $('#div_comb_'+cate_id).show(); + }); + // }}} + + // indicator combinations div's and buttons {{{ + var comb_divs_html = ''; + for (var i=1; i<=rind_num; i++) { + var id = 'div_comb_'+i; + comb_divs_html += '\n'; + }; + $("#comb_divs").html(comb_divs_html); + // button actions + $('#comb_divs input[type="button"]').on("click", document, function() { + // unselect all buttons + $('#comb_divs input[type="button"]').removeClass("selected"); + $('#comb_divs input[type="button"]').addClass("unselected"); + $(this).removeClass("unselected"); + $(this).addClass("selected"); + // display configs of the combination + var comb_id = $(this).attr('id'); + $('#conf_divs .conf_comb').hide(); + $('#div_conf_'+comb_id).show(); + }); + // }}} + + // config div's & info input {{{ + var conf_divs_html = ''; + for (var i=0; i